diff --git a/litellm/llms/openai/chat/gpt_transformation.py b/litellm/llms/openai/chat/gpt_transformation.py index 16fd042cb2f..d116e749e9a 100644 --- a/litellm/llms/openai/chat/gpt_transformation.py +++ b/litellm/llms/openai/chat/gpt_transformation.py @@ -175,6 +175,9 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig): model_specific_params.append( "user" ) # user is not a param supported by all openai-compatible endpoints - e.g. azure ai + + if litellm.utils.supports_reasoning(model=model, custom_llm_provider="openai") and not model.startswith("gpt-5-chat"): + model_specific_params.append("reasoning_effort") return base_params + model_specific_params def _map_openai_params( diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 73f46bd2181..a4a03e20c85 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -162,6 +162,8 @@ class ProviderSpecificModelInfo(TypedDict, total=False): supports_none_reasoning_effort: bool | None supports_minimal_reasoning_effort: bool | None supports_low_reasoning_effort: bool | None + supports_medium_reasoning_effort: bool | None + supports_high_reasoning_effort: bool | None supports_xhigh_reasoning_effort: bool | None supports_max_reasoning_effort: bool | None supports_output_config: bool | None diff --git a/litellm/utils.py b/litellm/utils.py index 802dc151428..20b80d651b0 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2722,6 +2722,20 @@ def supports_reasoning(model: str, custom_llm_provider: str | None = None) -> bo return _supports_factory(model=model, custom_llm_provider=custom_llm_provider, key="supports_reasoning") +def supports_medium_reasoning_effort(model: str, custom_llm_provider: str | None = None) -> bool: + """ + Check if the given model supports medium reasoning effort and return a boolean value. + """ + return _supports_factory(model=model, custom_llm_provider=custom_llm_provider, key="supports_medium_reasoning_effort") + + +def supports_high_reasoning_effort(model: str, custom_llm_provider: str | None = None) -> bool: + """ + Check if the given model supports high reasoning effort and return a boolean value. + """ + return _supports_factory(model=model, custom_llm_provider=custom_llm_provider, key="supports_high_reasoning_effort") + + def supports_native_structured_output(model: str, custom_llm_provider: str | None = None) -> bool: """ Check if the given model supports native structured outputs and return a boolean value. diff --git a/tests/test_litellm/test_reasoning_effort_config.py b/tests/test_litellm/test_reasoning_effort_config.py new file mode 100644 index 00000000000..db1009868bf --- /dev/null +++ b/tests/test_litellm/test_reasoning_effort_config.py @@ -0,0 +1,47 @@ +import pytest +import litellm +from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig +from litellm.utils import ( + supports_reasoning, + supports_medium_reasoning_effort, + supports_high_reasoning_effort, +) + + +def test_openai_gpt_config_supported_params_includes_reasoning_effort_when_supported(): + config = OpenAIGPTConfig() + + litellm.register_model({ + "custom-reasoning-model": { + "max_tokens": 4096, + "input_cost_per_token": 0.00001, + "output_cost_per_token": 0.00002, + "litellm_provider": "openai", + "mode": "chat", + "supports_reasoning": True, + "supports_medium_reasoning_effort": True, + "supports_high_reasoning_effort": True, + } + }) + + supported_params = config.get_supported_openai_params(model="custom-reasoning-model") + assert "reasoning_effort" in supported_params + assert supports_reasoning("custom-reasoning-model", custom_llm_provider="openai") is True + assert supports_medium_reasoning_effort("custom-reasoning-model", custom_llm_provider="openai") is True + assert supports_high_reasoning_effort("custom-reasoning-model", custom_llm_provider="openai") is True + + +def test_supports_medium_and_high_reasoning_effort_helpers(): + litellm.register_model({ + "plain-chat-model": { + "max_tokens": 4096, + "input_cost_per_token": 0.00001, + "output_cost_per_token": 0.00002, + "litellm_provider": "openai", + "mode": "chat", + "supports_reasoning": False, + } + }) + + assert supports_medium_reasoning_effort("plain-chat-model", custom_llm_provider="openai") is False + assert supports_high_reasoning_effort("plain-chat-model", custom_llm_provider="openai") is False