diff --git a/litellm/utils.py b/litellm/utils.py index 72423f8483..dfacefe697 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.py index 70818af547..27e6363e53 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