Skip to content

[Bug]: anthropic-beta Headers Not Forwarded to Bedrock Provider #15622

@JVenberg

Description

@JVenberg

What happened?

When sending requests with anthropic-beta headers (e.g., context-1m-2025-08-07 for extended context windows) through the LiteLLM proxy to AWS Bedrock, the headers are not being forwarded to the underlying provider. This prevents users from utilizing extended context features available in Anthropic Claude models on Bedrock.

Expected Behavior

The anthropic-beta header should be forwarded from the proxy to Bedrock when making requests, enabling extended context window functionality (1M+ tokens).

Actual Behavior

The anthropic-beta header is dropped during the request forwarding process. Requests to Bedrock are made without the necessary headers, resulting in standard context limits being applied instead of extended limits.

Reproduction Steps

  1. Configure LiteLLM proxy with a Bedrock model (e.g., anthropic.claude-3-5-sonnet-20241022-v2:0)
  2. Make a request through the proxy using the Anthropic SDK client:
from anthropic import Anthropic

client = Anthropic(api_key=api_key, base_url="http://proxy-url:4000")
extra_headers = {"anthropic-beta": "context-1m-2025-08-07"}

message = client.messages.create(
    model="bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0",
    max_tokens=1024,
    messages=[{"role": "user", "content": "test prompt"}],
    extra_headers=extra_headers,
)
  1. Observe that the request is processed with standard context limits rather than extended limits

Root Cause

The ProviderSpecificHeader mechanism in the proxy only supported single provider matching:

  • Headers were stored with custom_llm_provider="anthropic"
  • When Bedrock made the actual request, it looked for custom_llm_provider="bedrock"
  • String mismatch caused headers to be dropped

This affected cross-provider scenarios where the same header needs to work across multiple providers (Anthropic, Bedrock, Vertex AI, etc.).

Relevant log output

Are you a ML Ops Team?

Yes

What LiteLLM version are you on ?

v1.78.0.rc.2

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