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]

Fix _supports_reasoning_effort_level for responses bridge

Sameer Kankutea5bec4911fdd
diff --git a/litellm/main.py b/litellm/main.py
index f2ce894ba38..395a8b08387 100644
--- a/litellm/main.py
+++ b/litellm/main.py
@@ -1356,6 +1356,13 @@ def completion( # type: ignore # noqa: PLR0915
api_key=api_key,
)
+ ## RESPONSES API BRIDGE LOGIC ## - check early and normalize model name
+ responses_api_model_info, model = responses_api_bridge_check(
+ model=model,
+ custom_llm_provider=custom_llm_provider,
+ web_search_options=web_search_options,
+ )
+
if not _should_allow_input_examples(
custom_llm_provider=custom_llm_provider, model=model
):
@@ -1591,14 +1598,8 @@ def completion( # type: ignore # noqa: PLR0915
timeout=timeout,
)
- ## RESPONSES API BRIDGE LOGIC ## - check if model has 'mode: responses' in litellm.model_cost map
- model_info, model = responses_api_bridge_check(
- model=model,
- custom_llm_provider=custom_llm_provider,
- web_search_options=web_search_options,
- )
- if model_info.get("mode") == "responses":
+ if responses_api_model_info.get("mode") == "responses":
from litellm.completion_extras import responses_api_bridge
return responses_api_bridge.completion(
diff --git a/tests/llm_translation/test_openai.py b/tests/llm_translation/test_openai.py
index 9e6e5bb3695..acbb9c51366 100644
--- a/tests/llm_translation/test_openai.py
+++ b/tests/llm_translation/test_openai.py
@@ -1454,3 +1454,29 @@ def test_gpt_5_web_search():
for chunk in response:
print("chunk: ", chunk)
+
+
+def test_responses_gpt54_with_xhigh_reasoning():
+ """
+ Ensure chat->responses bridge sends the correct request payload for
+ openai/responses/gpt-5.4 with reasoning_effort="xhigh".
+ """
+ with patch("litellm.responses") as mock_responses:
+ # Stop execution right after request generation to avoid external API calls.
+ mock_responses.side_effect = RuntimeError("stop_after_request_build")
+
+ with pytest.raises(Exception):
+ litellm.completion(
+ model="openai/responses/gpt-5.4",
+ messages=[{"role": "user", "content": "What is 2+2?"}],
+ reasoning_effort="xhigh",
+ max_tokens=100,
+ )
+
+ mock_responses.assert_called_once()
+ request_body = mock_responses.call_args.kwargs
+
+ # The responses prefix should be stripped before routing.
+ assert request_body["model"] == "gpt-5.4"
+ # chat-completions reasoning_effort must map to Responses API reasoning.
+ assert request_body["reasoning"] == {"effort": "xhigh"}