-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
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
- Configure LiteLLM proxy with a Bedrock model (e.g.,
anthropic.claude-3-5-sonnet-20241022-v2:0) - 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,
)- 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