The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Enhance Bedrock Provider Configuration and Header Management
Jugal Bhatt4201f0aa7972
diff --git a/docs/my-website/docs/providers/bedrock.md b/docs/my-website/docs/providers/bedrock.mdindex 13fe93ec60d..1356ec1744e 100644--- a/docs/my-website/docs/providers/bedrock.md+++ b/docs/my-website/docs/providers/bedrock.md@@ -687,6 +687,9 @@ model_list:model: bedrock/converse/anthropic.claude-3-5-sonnet-20241022-v2:0extra_headers:anthropic-beta: "computer-use-2024-10-22,context-1m-2025-08-07"++general_settings:+ forward_client_headers_to_llm_api: true # 👈 Required for client-side header forwarding```**Set on Request**@@ -711,6 +714,10 @@ response = client.chat.completions.create()```+:::info+**For client-side header forwarding**: When using the proxy and sending `anthropic-beta` headers from the client (like the OpenAI SDK), you need to enable `forward_client_headers_to_llm_api: true` in your proxy's `general_settings`. This tells the proxy to extract headers from HTTP requests and forward them to the underlying LLM provider.+:::+</TabItem></Tabs>diff --git a/litellm/llms/bedrock/chat/converse_handler.py b/litellm/llms/bedrock/chat/converse_handler.pyindex 4cbc0fe3cbe..15a5002f0e4 100644--- a/litellm/llms/bedrock/chat/converse_handler.py+++ b/litellm/llms/bedrock/chat/converse_handler.py@@ -189,6 +189,7 @@ class BedrockConverseLLM(BaseAWSLLM):headers=headers,)data = json.dumps(request_data)+prepped = self.get_request_headers(credentials=credentials,aws_region_name=litellm_params.get("aws_region_name") or "us-west-2",@@ -395,6 +396,7 @@ class BedrockConverseLLM(BaseAWSLLM):headers=extra_headers,)data = json.dumps(_data)+prepped = self.get_request_headers(credentials=credentials,aws_region_name=aws_region_name,diff --git a/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py b/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.pyindex 742e9285126..08a0690716b 100644--- a/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py+++ b/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py@@ -190,13 +190,15 @@ class AmazonInvokeConfig(BaseConfig, BaseAWSLLM):] = True # cohere requires stream = True in inference paramsrequest_data = {"prompt": prompt, **inference_params}elif provider == "anthropic":- return litellm.AmazonAnthropicClaudeConfig().transform_request(+ transformed_request = litellm.AmazonAnthropicClaudeConfig().transform_request(model=model,messages=messages,optional_params=optional_params,litellm_params=litellm_params,headers=headers,)++ return transformed_requestelif provider == "nova":return litellm.AmazonInvokeNovaConfig().transform_request(model=model,diff --git a/litellm/main.py b/litellm/main.pyindex 339d9e14406..a923aa2fcec 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -2981,7 +2981,7 @@ def completion( # type: ignore # noqa: PLR0915logger_fn=logger_fn,encoding=encoding,logging_obj=logging,- extra_headers=extra_headers,+ extra_headers=headers, # Use merged headers instead of original extra_headerstimeout=timeout,acompletion=acompletion,client=client,