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(gpt5): treat missing supports_minimal_reasoning_effort as supported
Sameer Kankute52bf372319b9
diff --git a/litellm/llms/openai/chat/gpt_5_transformation.py b/litellm/llms/openai/chat/gpt_5_transformation.pyindex 8522a97a387..6291f4232d5 100644--- a/litellm/llms/openai/chat/gpt_5_transformation.py+++ b/litellm/llms/openai/chat/gpt_5_transformation.py@@ -3,7 +3,7 @@from typing import Optional, Unionimport litellm-from litellm.utils import _supports_factory+from litellm.utils import _get_model_cost_key, _get_model_info_helper, _supports_factoryfrom .gpt_transformation import OpenAIGPTConfig@@ -113,6 +113,28 @@ class OpenAIGPT5Config(OpenAIGPTConfig):key=f"supports_{level}_reasoning_effort",)+ @classmethod+ def _is_reasoning_effort_level_explicitly_disabled(+ cls, model: str, level: str+ ) -> bool:+ """Return True only when the model map explicitly sets the capability to False.++ Unlike ``_supports_reasoning_effort_level`` (which requires an explicit True),+ this method returns True only when ``supports_{level}_reasoning_effort`` is+ explicitly set to ``False`` in the model map. A missing key is treated as+ supported (i.e. this method returns False = not disabled).++ Use this for opt-out checks where unknown models should be allowed through.+ """+ try:+ key = f"supports_{level}_reasoning_effort"+ cost_key = _get_model_cost_key(model)+ entry = litellm.model_cost.get(cost_key or model) or {}+ val = entry.get(key)+ return val is False+ except Exception:+ return False+def get_supported_openai_params(self, model: str) -> list:if self.is_model_gpt_5_search_model(model):return [@@ -200,9 +222,8 @@ class OpenAIGPT5Config(OpenAIGPTConfig):if "reasoning_effort" in optional_params:optional_params["reasoning_effort"] = normalized- if effective_effort is not None and (- effective_effort == "xhigh" or effective_effort == "minimal"- ):+ if effective_effort == "xhigh":+ # xhigh is an opt-in capability: only allow if model explicitly supports it.if not self._supports_reasoning_effort_level(model, effective_effort):if litellm.drop_params or drop_params:non_default_params.pop("reasoning_effort", None)@@ -213,6 +234,19 @@ class OpenAIGPT5Config(OpenAIGPTConfig):),status_code=400,)+ elif effective_effort == "minimal":+ # minimal is opt-out: unknown models pass through; only block when+ # the model map explicitly sets supports_minimal_reasoning_effort=false.+ if self._is_reasoning_effort_level_explicitly_disabled(model, effective_effort):+ if litellm.drop_params or drop_params:+ non_default_params.pop("reasoning_effort", None)+ else:+ raise litellm.utils.UnsupportedParamsError(+ message=(+ f"reasoning_effort={effective_effort} is not supported for this model."+ ),+ status_code=400,+ )################################################################# max_tokens is not supported for gpt-5 models on OpenAI APIdiff --git a/tests/test_litellm/llms/openai/test_gpt5_transformation.py b/tests/test_litellm/llms/openai/test_gpt5_transformation.pyindex 8ae9bf48a62..535fba16140 100644--- a/tests/test_litellm/llms/openai/test_gpt5_transformation.py+++ b/tests/test_litellm/llms/openai/test_gpt5_transformation.py@@ -409,6 +409,41 @@ def test_gpt5_supports_reasoning_effort_level_minimal(gpt5_config: OpenAIGPT5Conassert not gpt5_config._supports_reasoning_effort_level("gpt-5.4-nano", "minimal")+def test_gpt5_minimal_explicitly_disabled_check(gpt5_config: OpenAIGPT5Config):+ """_is_reasoning_effort_level_explicitly_disabled returns True only for explicit False entries.++ Models with supports_minimal_reasoning_effort=false → disabled.+ Models with supports_minimal_reasoning_effort=true (or missing) → not disabled.+ """+ assert gpt5_config._is_reasoning_effort_level_explicitly_disabled(+ "gpt-5.4-mini", "minimal"+ )+ assert gpt5_config._is_reasoning_effort_level_explicitly_disabled(+ "gpt-5.4-nano", "minimal"+ )+ assert not gpt5_config._is_reasoning_effort_level_explicitly_disabled(+ "gpt-5.4", "minimal"+ )+ assert not gpt5_config._is_reasoning_effort_level_explicitly_disabled(+ "gpt-5.4-pro", "minimal"+ )+++def test_gpt5_unknown_model_passes_through_minimal(config: OpenAIConfig):+ """Unknown/unlisted gpt-5 models should pass reasoning_effort='minimal' through.++ Missing supports_minimal_reasoning_effort key is treated as supported,+ not as unsupported, to avoid breaking custom or newly-announced models.+ """+ params = config.map_openai_params(+ non_default_params={"reasoning_effort": "minimal"},+ optional_params={},+ model="gpt-5.4-turbo-preview",+ drop_params=False,+ )+ assert params["reasoning_effort"] == "minimal"++def test_gpt5_normalizes_reasoning_effort_dict_with_summary(config: OpenAIConfig):"""Dict with summary/generate_summary is normalized for chat completions."""params = config.map_openai_params(