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: use DeepSeekChatConfig instead of OpenAIConfig for deepseek provider (#22971)
Yangqian Yan7f5d5c5c6ea3
diff --git a/litellm/utils.py b/litellm/utils.pyindex 72423f84831..dfacefe6971 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -4491,7 +4491,7 @@ def get_optional_params( # noqa: PLR0915),)elif custom_llm_provider == "deepseek":- optional_params = litellm.OpenAIConfig().map_openai_params(+ optional_params = litellm.DeepSeekChatConfig().map_openai_params(non_default_params=non_default_params,optional_params=optional_params,model=model,diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex 70818af547f..27e6363e53d 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -3473,6 +3473,53 @@ class TestDropParamsWithPromptCacheKey:assert result.get("temperature") == 0.7+class TestGetOptionalParamsDeepSeek:+ """Tests that deepseek provider uses DeepSeekChatConfig for parameter mapping."""++ def test_deepseek_supports_thinking_param(self):+ """+ Verify that get_optional_params for deepseek accepts the 'thinking' param,+ which is only supported by DeepSeekChatConfig, not OpenAIConfig.+ """+ from litellm.utils import get_optional_params++ result = get_optional_params(+ model="deepseek-reasoner",+ custom_llm_provider="deepseek",+ thinking={"type": "enabled"},+ )+ assert result.get("thinking") == {"type": "enabled"}++ def test_deepseek_supports_reasoning_effort_param(self):+ """+ Verify that get_optional_params for deepseek accepts 'reasoning_effort',+ which is only supported by DeepSeekChatConfig, not OpenAIConfig.+ """+ from litellm.utils import get_optional_params++ result = get_optional_params(+ model="deepseek-reasoner",+ custom_llm_provider="deepseek",+ reasoning_effort="high",+ )+ assert result.get("thinking") == {"type": "enabled"}++ def test_deepseek_thinking_strips_budget_tokens(self):+ """+ DeepSeekChatConfig strips budget_tokens from thinking param.+ This would not happen with OpenAIConfig.+ """+ from litellm.utils import get_optional_params++ result = get_optional_params(+ model="deepseek-reasoner",+ custom_llm_provider="deepseek",+ thinking={"type": "enabled", "budget_tokens": 5000},+ )+ assert "budget_tokens" not in result.get("thinking", {})+ assert result.get("thinking") == {"type": "enabled"}++class TestIsStreamingRequest:def test_stream_true_in_kwargs(self):assert _is_streaming_request(kwargs={"stream": True}, call_type="acompletion") is True