Skip to content

[Bug]: Unable to use Claude Code BYOK when ANTHROPIC_AUTH_TOKEN is set/with non-anthropic claude model providers #24436

Description

@saraangelmurphy

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

A bug happened!

I am trying to set up LiteLLM with my company's claude enterprise subscription. Prior to purchasing claude enterprise, we used LiteLLM with Claude Code successfully, with models from both Anthropic, as well as from AWS Bedrock, GCP Vertex, and Azure OpenAI.

I'm running litellm in kubernetes with two pods in HA using an in-cluster redis for synchronization.

I'm trying to set up LiteLLM and Claude Code now using the OAuth token from the /login command from Claude Code.

This... sometimes works! However, it seems to work very inconsistently, and I am unable to easily swap between Claude models (using my subscription OR API billing), Claude models from Bedrock and Vertext (using API billing), and non-Claude models (using API billing).

Steps to Reproduce

  1. set up the relevant anthropic models. In general, assume that I have set up claude-<opus/sonnet>-<4-5/4-6>, claude-haiku-4-5 with both the anthropic provider and vertex/bedrock.
general_settings:
  allow_requests_on_db_unavailable: true
  database_connection_pool_limit: 10
  forward_client_headers_to_llm_api: true
  forward_llm_provider_auth_headers: true
  master_key: os.environ/LITELLM_MASTER_KEY
  proxy_batch_write_at: 60
  store_model_in_db: true
litellm_settings:
  cache: true
  cache_params:
    host: os.environ/REDIS_HOST
    password: os.environ/redis-password
    port: os.environ/REDIS_PORT
    ttl: 600
    type: redis
  callbacks:
  - batch_redis_requests
  - prometheus
  drop_params: true
  enable_caching_on_provider_specific_optional_params: true
  enable_preview_features: true
  json_logs: false
  key_generation_settings:
    personal_key_generation:
      required_params:
      - duration
  num_retries: 2
  prometheus_initialize_budget_metrics: true
  request_timeout: 600
  turn_off_message_logging: true
model_list:
- litellm_params:
    model: '*'
  model_name: '*'
- litellm_params:
    model: anthropic/claude-opus-4-6
  model_info:
    access_groups:
    - Standard Model Group
    mode: chat
  model_name: claude-opus-4-6
- litellm_params:
    model: anthropic/claude-opus-4-6-20260205
  model_info:
    access_groups:
    - Standard Model Group
    mode: chat
  model_name: claude-opus-4-6-20260205
- litellm_params:
    model: vertex_ai/gemini-3.1-pro-preview
    use_in_pass_through: true
    vertex_credentials: os.environ/GOOGLE_SA_KEYFILE_PATH
    vertex_location: global
    vertex_project: <my-gcp-project-id>
  model_info:
    access_groups:
    - Standard Model Group
    mode: chat
  model_name: gemini-3.1-pro-preview
- litellm_params:
    api_base: <my azure openai endpoint>
    api_key: os.environ/BV-OPENAI-GPT-KEY
    api_version: os.environ/AZURE_OPENAI_INFERENCE_API_VERSION
    model: azure/gpt-5.2
  model_info:
    access_groups:
    - Standard Model Group
    base_model: azure/gpt-5.2
    mode: chat
  model_name: gpt-5.2
- litellm_params:
    cache_control_injection_points:
    - location: message
      role: system
    model: vertex_ai/claude-sonnet-4-6
    use_in_pass_through: true
    vertex_credentials: os.environ/GOOGLE_SA_KEYFILE_PATH
    vertex_location: global
    vertex_project: <my gcp project id>
  model_info:
    access_groups:
    - Standard Model Group
    mode: chat
  model_name: claude-sonnet-4-6
- litellm_params:
    cache_control_injection_points:
    - location: message
      role: system
    model: vertex_ai/claude-opus-4-6
    use_in_pass_through: true
    vertex_credentials: os.environ/GOOGLE_SA_KEYFILE_PATH
    vertex_location: global
    vertex_project: <my gcp project>
  model_info:
    access_groups:
    - Standard Model Group
    mode: chat
  model_name: claude-opus-4-6
  1. set the envvars:
export ANTHROPIC_BASE_URL=https://litellm.example.com
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-6
export ANTHROPIC_AUTH_TOKEN=sk-1234
export ANTHROPIC_CUSTOM_HEADERS="x-litellm-api-key: Bearer sk-1234"
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
  1. run claude --debug
  2. run /login with your anthropic credentials, which returns successfully
  3. If ANTHROPIC_AUTH_TOKEN is unset, then:
  • I think the issue depends on whether LiteLLM decides to route the request to the Anthropic instance of claude-opus-4-6/claude-sonnet-4-6 vs the bedrock/vertex instances
  • requests to claude-opus-4-6 fail with the following BaseLLMException.
Please run /login · API Error: 403 {"error":{"message":"{\"message\":\"Invalid key=value pair (missing equal-sign) in Authorization header (hashed with SHA-256 and encoded with Base64): '<redacted>.\"}. Received Model
     Group=claude-opus-4-6\nAvailable Model Group Fallbacks=None","type":"None","param":"None","code":"403"}}
  • requests to anthropic models that are non-default but are present in the model_prices_and_context_window.json (e.g. claude-opus-4-6-20260205 or claude-haiku-4-5-20251001 ) fail with Model 'claude-opus-4-6-20260205' not found.
  • requests to non-anthropic models like gemini-3.1-flash-lite-preview work when running /model gemini-3.1-flash-lite-preview
  • Switching back to claude models is inconsistent.
  • /model claude-haiku-4-5, /model claude-sonnet-4-6, and /model claude-sonnet-4-5 all fail with Please run /login
  • /model claude-opus-4-6 fails with API error: 403 {"error":{"message":"{"message":"Invalid key=value pair (missing equal-sign) in Authorization header (hashed with SHA-256 and encoded with Base64): '<snip>'."}. Received Model Group=claude-opus-4-6\nAvailable Model Group Fallbacks=None","type":"None","param":"None","code":"403"}} but no Please run /login error
  • /model claude-opus-4-5 works, bizarrely.
  • all of these models work some of the time. I occasionally get back correct results, but frequently get the Invalid key=value pair error as well.
  1. If ANTHROPIC_AUTH_TOKEN is set, then:
  • /model and picking the default model works, uses anthropic/claude-opus-4-6
  • /model and picking Sonnet (1M context) works
  • requests to models like claude-haiku-4-5-20251001 fail with Authentication failed. Please check your API credentials. and 401 errors with the text Message: {"type":"error","error":{"type":"authentication_error","message":"x-api-key header is required"},"request_id":"req_011CZLUcjtvRigLeHDYhr3aU"} in the proxy logs
  • Requests to models like gemini-3.1-pro-preview work fine.
  • Requests are routed to bedrock/vertex even after running /login, unless bedrock and vertex claude models are disabled.
  • Calls to bedrock and vertex models fail with API error: 403 {"error":{"message":"{"message":"Invalid key=value pair (missing equal-sign) in Authorization header (hashed with SHA-256 and encoded with Base64): 'BnNmwEPz6udl6PPQjBc79nhwawpKIppOZa0kHg5vTpg='."}. Received Model Group=claude-sonnet-4-5-bedrock\nAvailable Model Group Fallbacks=None","type":"None","param":"None","code":"403"}} when claude code thinks I'm in Claude Enterprise mode, and of course work fine when it's not trying to send my anthropic oauth token instead of litellm's bedrock/vertex creds. It is again inconsistent as to when LiteLLM does that or not.

Relevant log output

{"message":"Invalid key=value pair (missing equal-sign) in Authorization header (hashed with SHA-256 and encoded with Base64): 'nAMAupSMCgnLYhCwe9U7NxImj3fxMrOJZ8X1E/XwEOQ='."}

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.3

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions