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
fix(bedrock): forward anthropic-beta headers verbatim on the Claude platform messages path
mateo-berrie51ccbc759bb
diff --git a/litellm/llms/bedrock/claude_platform/messages_transformation.py b/litellm/llms/bedrock/claude_platform/messages_transformation.pyindex 3add682ef6d..1e3eea075f3 100644--- a/litellm/llms/bedrock/claude_platform/messages_transformation.py+++ b/litellm/llms/bedrock/claude_platform/messages_transformation.py@@ -12,6 +12,9 @@ from .common_utils import BedrockClaudePlatformMixin, strip_claude_platform_routclass BedrockClaudePlatformMessagesConfig(BedrockClaudePlatformMixin, AnthropicMessagesConfig):+ def should_filter_anthropic_beta_headers(self) -> bool:+ return False+def validate_anthropic_messages_environment(self,headers: dict,diff --git a/tests/test_litellm/llms/bedrock/test_claude_platform_provider.py b/tests/test_litellm/llms/bedrock/test_claude_platform_provider.pyindex dbded8e0a2e..40f78c84ca3 100644--- a/tests/test_litellm/llms/bedrock/test_claude_platform_provider.py+++ b/tests/test_litellm/llms/bedrock/test_claude_platform_provider.py@@ -313,6 +313,41 @@ async def test_anthropic_messages_routes_bedrock_claude_platform_to_messages_apiassert requests[0]["body"]["model"] == "claude-sonnet-4-6"+async def test_anthropic_messages_bedrock_claude_platform_forwards_anthropic_beta_verbatim():+ import litellm++ requests = []++ async def mock_post(self, url, data=None, headers=None, **kwargs):+ requests.append(_capture_request(url=url, headers=headers or {}, data=data))+ return _anthropic_response(url)++ try:+ with patch(+ "litellm.llms.custom_httpx.http_handler.AsyncHTTPHandler.post",+ new=mock_post,+ ):+ await litellm.anthropic_messages(+ model="bedrock/claude_platform/claude-sonnet-4-6",+ messages=[{"role": "user", "content": "hello"}],+ max_tokens=10,+ mcp_servers=[{"type": "url", "url": "https://mcp.example.com/mcp", "name": "example"}],+ api_base="https://aws-external-anthropic.us-west-2.api.aws",+ api_key="fake-platform-key",+ workspace_id="wrkspc_test",+ extra_headers={"anthropic-beta": "prompt-caching-scope-2026-01-05,mcp-client-2025-11-20"},+ )+ finally:+ await litellm.close_litellm_async_clients()++ assert len(requests) == 1+ assert requests[0]["headers"]["anthropic-beta"] == "mcp-client-2025-11-20,prompt-caching-scope-2026-01-05"+ assert requests[0]["body"]["mcp_servers"] == [+ {"type": "url", "url": "https://mcp.example.com/mcp", "name": "example"}+ ]++def test_sigv4_no_duplicate_content_type_when_caller_sets_lowercase():"""Regression: get_anthropic_headers() supplies "content-type" (lowercase).diff --git a/tests/unit/llms/github_copilot/messages/test_github_copilot_messages_transformation.py b/tests/unit/llms/github_copilot/messages/test_github_copilot_messages_transformation.pyindex 9e9760650cf..ed67c33e04c 100644--- a/tests/unit/llms/github_copilot/messages/test_github_copilot_messages_transformation.py+++ b/tests/unit/llms/github_copilot/messages/test_github_copilot_messages_transformation.py@@ -272,13 +272,11 @@ def test_github_copilot_config_disables_anthropic_beta_filtering():because github_copilot has no entry in the beta headers config; a regressionhere would silently disable header-gated Anthropic features for Copilot."""from litellm.anthropic_beta_headers_manager import update_headers_with_filtered_beta- from litellm.llms.anthropic.experimental_pass_through.messages.transformation import (- AnthropicMessagesConfig,- )+ from litellm.llms.azure_ai.anthropic.messages_transformation import AzureAnthropicMessagesConfigconfig = GithubCopilotAnthropicMessagesConfig()assert config.should_filter_anthropic_beta_headers() is False- assert AnthropicMessagesConfig().should_filter_anthropic_beta_headers() is True+ assert AzureAnthropicMessagesConfig().should_filter_anthropic_beta_headers() is Trueconfig.authenticator = MagicMock()config.authenticator.get_api_key.return_value = "gh.test-key"diff --git a/tests/unit/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.py b/tests/unit/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.pyindex 67a56fdcd79..07f06c9084c 100644--- a/tests/unit/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.py+++ b/tests/unit/llms/openai_like/messages/test_openai_like_anthropic_messages_transformation.py@@ -268,12 +268,10 @@ def test_request_maps_reasoning_effort_to_thinking(config):def test_passthrough_disables_anthropic_beta_filtering(config):- from litellm.llms.anthropic.experimental_pass_through.messages.transformation import (- AnthropicMessagesConfig,- )+ from litellm.llms.azure_ai.anthropic.messages_transformation import AzureAnthropicMessagesConfigassert config.should_filter_anthropic_beta_headers() is False- assert AnthropicMessagesConfig().should_filter_anthropic_beta_headers() is True+ assert AzureAnthropicMessagesConfig().should_filter_anthropic_beta_headers() is Truedef test_anthropic_beta_survives_provider_filter_on_passthrough_path(config):