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): strip client_metadata from converse additionalModelRequestFields
milanab1161344199
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.pyindex 395d99a4caa..9e40cb5ee5b 100644--- a/litellm/llms/bedrock/chat/converse_transformation.py+++ b/litellm/llms/bedrock/chat/converse_transformation.py@@ -1324,6 +1324,7 @@ class AmazonConverseConfig(BaseConfig):)additional_request_params.pop("parallel_tool_calls", None)+ additional_request_params.pop("client_metadata", None)# Only set the topK value in for models that support itadditional_request_params.update(self._handle_top_k_value(model, inference_params, drop_params))diff --git a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.pyindex 63f895e1819..bd68857d664 100644--- a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py+++ b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py@@ -979,6 +979,30 @@ def test_config_blocks_do_not_leak_into_inference_config():assert data["serviceTier"] == {"type": "priority"}+def test_client_metadata_stripped_from_converse_request():+ """``client_metadata`` sent by codex must not reach Bedrock as a passthrough model field.++ Converse forwards ``additionalModelRequestFields`` verbatim to the model, and Anthropic+ rejects the request with "client_metadata: Extra inputs are not permitted".+ """+ config = AmazonConverseConfig()++ data = config._transform_request_helper(+ model="anthropic.claude-opus-4-8",+ system_content_blocks=[],+ optional_params={+ "maxTokens": 16,+ "anthropic_beta": ["computer-use-2025-01-24"],+ "client_metadata": {"originator": "codex_cli_rs"},+ },+ messages=None,+ )++ fields = data.get("additionalModelRequestFields", {})+ assert "client_metadata" not in fields+ assert fields["anthropic_beta"] == ["computer-use-2025-01-24"]++def test_parallel_tool_calls_config_kept_for_sonnet_5(monkeypatch):old_env = os.environ.get("LITELLM_LOCAL_MODEL_COST_MAP")old_cost = litellm.model_cost