Skip to content

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]

Add test for reasoning effort none

Sameer Kankuteecb8c05d37ef
diff --git a/litellm/llms/openai/chat/gpt_5_transformation.py b/litellm/llms/openai/chat/gpt_5_transformation.py
index 60a21e19a9f..bd726e7933b 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, Union
import litellm
-from litellm.utils import _get_model_cost_key, _supports_factory
+from litellm.utils import _is_explicitly_disabled_factory, _supports_factory
from .gpt_transformation import OpenAIGPTConfig
@@ -125,20 +125,12 @@ class OpenAIGPT5Config(OpenAIGPTConfig):
supported (i.e. this method returns False = not disabled).
Use this for opt-out checks where unknown models should be allowed through.
- Normalizes the model via get_llm_provider so provider-prefixed names
- (e.g. openai/gpt-5.4-mini) resolve correctly.
"""
- try:
- normalized_model, _, _, _ = litellm.get_llm_provider(
- model=model, custom_llm_provider=None
- )
- key = f"supports_{level}_reasoning_effort"
- cost_key = _get_model_cost_key(normalized_model)
- entry = litellm.model_cost.get(cost_key or normalized_model) or {}
- val = entry.get(key)
- return val is False
- except Exception:
- return False
+ return _is_explicitly_disabled_factory(
+ model=model,
+ custom_llm_provider=None,
+ key=f"supports_{level}_reasoning_effort",
+ )
def get_supported_openai_params(self, model: str) -> list:
if self.is_model_gpt_5_search_model(model):
@@ -245,6 +237,7 @@ class OpenAIGPT5Config(OpenAIGPTConfig):
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)
+ optional_params.pop("reasoning_effort", None)
else:
raise litellm.utils.UnsupportedParamsError(
message=(
diff --git a/litellm/utils.py b/litellm/utils.py
index 81d749ab821..cc7956576d9 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -2576,6 +2576,47 @@ def _supports_factory(model: str, custom_llm_provider: Optional[str], key: str)
return False
+def _is_explicitly_disabled_factory(
+ model: str, custom_llm_provider: Optional[str], key: str
+) -> bool:
+ """Return True only when the model map explicitly sets *key* to ``False``.
+
+ This is the opt-out mirror of :func:`_supports_factory`. Where
+ ``_supports_factory`` requires an explicit ``True`` to return ``True``,
+ this function requires an explicit ``False``. A missing key (``None``)
+ is treated as *not* disabled so that unknown or newly-added models are
+ allowed through without any model-map entry.
+
+ Uses the same ``get_llm_provider`` → ``_get_model_info_helper`` chain as
+ ``_supports_factory`` so caching, fallback, and normalisation improvements
+ apply here automatically.
+ """
+ try:
+ model, custom_llm_provider, _, _ = litellm.get_llm_provider(
+ model=model, custom_llm_provider=custom_llm_provider
+ )
+ model_info = _get_model_info_helper(
+ model=model, custom_llm_provider=custom_llm_provider
+ )
+ val = model_info.get(key)
+ if val is False:
+ return True
+ if val is None:
+ bare_model_key = _get_model_cost_key(model)
+ if bare_model_key is not None:
+ bare_entry = litellm.model_cost.get(bare_model_key) or {}
+ if bare_entry.get(key) is False:
+ return True
+ return False
+ except Exception as e:
+ verbose_logger.debug(
+ f"Model not found or error in checking {key} disabled state. "
+ f"You passed model={model}, custom_llm_provider={custom_llm_provider}. "
+ f"Error: {str(e)}"
+ )
+ return False
+
+
def supports_audio_input(model: str, custom_llm_provider: Optional[str] = None) -> bool:
"""Check if a given model supports audio input in a chat completion call"""
return _supports_factory(
diff --git a/tests/test_litellm/llms/openai/test_gpt5_transformation.py b/tests/test_litellm/llms/openai/test_gpt5_transformation.py
index a173d2015bc..14e392a0998 100644
--- a/tests/test_litellm/llms/openai/test_gpt5_transformation.py
+++ b/tests/test_litellm/llms/openai/test_gpt5_transformation.py
@@ -3,6 +3,7 @@ import pytest
import litellm
from litellm.llms.openai.chat.gpt_5_transformation import OpenAIGPT5Config
from litellm.llms.openai.openai import OpenAIConfig
+from litellm.utils import _is_explicitly_disabled_factory
@pytest.fixture()
@@ -485,6 +486,22 @@ def test_gpt5_minimal_explicitly_disabled_check(gpt5_config: OpenAIGPT5Config):
)
+def test_is_explicitly_disabled_factory_minimal():
+ """_is_explicitly_disabled_factory returns True only for explicit False entries.
+
+ Verifies the shared helper used by _is_reasoning_effort_level_explicitly_disabled
+ directly — so future changes to the helper are caught without going through the
+ method wrapper.
+ """
+ key = "supports_minimal_reasoning_effort"
+ assert _is_explicitly_disabled_factory("gpt-5.4-mini", None, key)
+ assert _is_explicitly_disabled_factory("gpt-5.4-nano", None, key)
+ assert _is_explicitly_disabled_factory("openai/gpt-5.4-mini", None, key)
+ assert not _is_explicitly_disabled_factory("gpt-5.4", None, key)
+ assert not _is_explicitly_disabled_factory("gpt-5.4-pro", None, key)
+ assert not _is_explicitly_disabled_factory("gpt-5.4-turbo-preview", None, key)
+
+
def test_gpt5_unknown_model_passes_through_minimal(config: OpenAIConfig):
"""Unknown/unlisted gpt-5 models should pass reasoning_effort='minimal' through.