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): drop thinking/reasoning_effort in converse mapping for DeepSeek
Devin AIf4ad6b0f0bd1
diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.pyindex 08f44d5b1b1..d7ee15cedd7 100644--- a/litellm/llms/bedrock/chat/converse_transformation.py+++ b/litellm/llms/bedrock/chat/converse_transformation.py@@ -857,6 +857,9 @@ class AmazonConverseConfig(BaseConfig):drop_params: bool,) -> dict:is_thinking_enabled = self.is_thinking_enabled(non_default_params)+ accepts_thinking_param = self._model_accepts_anthropic_thinking_param(+ model=model, base_model=BedrockModelInfo.get_base_model(model)+ )for param, value in non_default_params.items():if param == "response_format" and isinstance(value, dict):@@ -906,7 +909,12 @@ class AmazonConverseConfig(BaseConfig):optional_params["_parallel_tool_use_config"] = {"tool_choice": {"disable_parallel_tool_use": disable_parallel}}- if param == "thinking":+ if param == "thinking" and not accepts_thinking_param:+ verbose_logger.debug(+ "Dropping unsupported `thinking` param for Bedrock model=%s; it reasons natively and rejects it.",+ model,+ )+ elif param == "thinking":if (isinstance(value, dict)and value.get("type") == "adaptive"@@ -929,6 +937,11 @@ class AmazonConverseConfig(BaseConfig):litellm.verbose_logger.warning(DROP_UNSUPPORTED_ADAPTIVE_THINKING_WARNING, model)else:optional_params["thinking"] = value+ elif param == "reasoning_effort" and isinstance(value, str) and not accepts_thinking_param:+ verbose_logger.debug(+ "Dropping unsupported `reasoning_effort` param for Bedrock model=%s; it reasons natively and rejects it.",+ model,+ )elif param == "reasoning_effort" and isinstance(value, str):self._handle_reasoning_effort_parameter(model=model, reasoning_effort=value, optional_params=optional_paramsdiff --git a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.pyindex f7e2716bd19..93455f00143 100644--- a/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py+++ b/tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py@@ -605,6 +605,34 @@ def test_bedrock_deepseek_r1_thinking_dropped_does_not_leak_into_request():assert "thinking" not in request.get("additionalModelRequestFields", {})[email protected]("param", ["thinking", "reasoning_effort"])+def test_bedrock_deepseek_r1_reasoning_params_not_forwarded_by_map(param):+ """Even when map_openai_params is called directly (bypassing the supported-params+ gate), DeepSeek R1 must not forward the Anthropic-shaped thinking/reasoning_effort+ into additionalModelRequestFields, since Bedrock rejects it with a 400."""+ config = AmazonConverseConfig()+ model = "bedrock/converse/us.deepseek.r1-v1:0"+ value = {"type": "enabled", "budget_tokens": 1024} if param == "thinking" else "high"++ optional_params = config.map_openai_params(+ non_default_params={param: value, "max_tokens": 100},+ optional_params={},+ model=model,+ drop_params=False,+ )+ assert "thinking" not in optional_params+ assert "reasoning_effort" not in optional_params++ request = config._transform_request(+ model=model,+ messages=[{"role": "user", "content": "Say hi in one word."}],+ optional_params=optional_params,+ litellm_params={},+ headers={},+ )+ assert request.get("additionalModelRequestFields") is None++def test_get_supported_openai_params_bedrock_converse():"""Test that all documented bedrock converse models have the same set of supported openai params when using