fix(responses-api): apply GPT-5 temperature validation - #24371
Merged
Chesars merged 3 commits intoMar 22, 2026
Merged
Conversation
The Responses API map_openai_params passed all params through without applying model-specific validation. GPT-5 models (except gpt-5-chat) only accept temperature=1 unless reasoning.effort="none" on models that support it (5.1, 5.2, 5.4). Reuse the existing OpenAIGPT5Config logic from chat completions to validate temperature in the Responses API path. With drop_params=True, unsupported temperature values are silently dropped; without it, UnsupportedParamsError is raised. Fixes BerriAI#16090
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Contributor
Greptile SummaryThis PR adds GPT-5 temperature validation to the Responses API Changes:
Notes:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/llms/openai/responses/transformation.py | Adds GPT-5 temperature validation to map_openai_params, mirroring the chat completions path. Logic is correct and consistent; minor concern around hardcoded model detection (reusing existing helper) and a behavior-level change in exception type (UnsupportedParamsError raised earlier instead of API-level 400). |
| tests/test_litellm/llms/openai/test_gpt5_transformation.py | Adds 7 new unit tests covering drop, reject, and allow paths for several model variants. All tests are pure in-memory (no network calls), satisfying the test-folder constraint. Missing a reject-path test for supports-none models (e.g. gpt-5.1 + effort='high' + drop_params=False), but this was noted in previous review threads. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[map_openai_params called] --> B{is_model_gpt_5_model?}
B -- No --> Z[return params as-is]
B -- Yes --> C{temperature in params\nAND temperature != 1?}
C -- No --> Z
C -- Yes --> D[extract reasoning.effort]
D --> E{_supports_reasoning_effort_level\nlevel='none'?}
E -- Yes, supports_none=True --> F{effort == 'none'\nOR effort is None?}
F -- Yes --> Z[return params with temperature]
F -- No --> G{drop_params\nOR litellm.drop_params?}
E -- No, supports_none=False --> G
G -- Yes --> H[pop temperature from params]
H --> Z
G -- No --> I[raise UnsupportedParamsError 400]
Reviews (3): Last reviewed commit: "fix: improve error message for supports-..." | Re-trigger Greptile
…rature Add tests for the gpt-5.1/5.2/5.4 reasoning.effort interaction: - gpt-5.1 with no reasoning allows flexible temperature - gpt-5.1 with effort='high' drops temperature - gpt-5.4 with effort='none' allows flexible temperature
Chesars
merged commit Mar 22, 2026
16c48b4
into
BerriAI:litellm_staging_03_22_2026
37 of 39 checks passed
Chesars
added a commit
that referenced
this pull request
Apr 16, 2026
- factory.py: fix _sort_bedrock_assistant_content_blocks to treat cachePoint blocks with the same sort key as toolUse so Python's stable sort keeps each cachePoint paired with its preceding toolUse block (PR #24368) - responses/transformation.py: remove cyclic import of OpenAIGPT5Config inside map_openai_params; add _is_gpt_5_model and _supports_reasoning_effort_none static methods that replicate the same logic without the import cycle. _is_gpt_5_model now also excludes pass-through models from other providers (e.g. perplexity/openai/gpt-5.2) that contain 'gpt-5' in their name but should not be subject to OpenAI GPT-5 temperature restrictions (PR #24371)
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
…temperature-drop-params fix(responses-api): apply GPT-5 temperature validation
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
- factory.py: fix _sort_bedrock_assistant_content_blocks to treat cachePoint blocks with the same sort key as toolUse so Python's stable sort keeps each cachePoint paired with its preceding toolUse block (PR BerriAI#24368) - responses/transformation.py: remove cyclic import of OpenAIGPT5Config inside map_openai_params; add _is_gpt_5_model and _supports_reasoning_effort_none static methods that replicate the same logic without the import cycle. _is_gpt_5_model now also excludes pass-through models from other providers (e.g. perplexity/openai/gpt-5.2) that contain 'gpt-5' in their name but should not be subject to OpenAI GPT-5 temperature restrictions (PR BerriAI#24371)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Fixes #16090
Pre-Submission checklist
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewType
🐛 Bug Fix
Changes
The Responses API
map_openai_paramspassed all params through without model-specific validation. GPT-5 models (except gpt-5-chat) only accepttemperature=1unlessreasoning.effort="none"on models that support it (5.1, 5.2, 5.4). The chat completions path already validates this, but the Responses API path did not.Tests added
test_responses_gpt5_drop_temperature— drop_params drops temperature!=1test_responses_gpt5_reject_temperature— raises error without drop_paramstest_responses_gpt5_allow_temperature_1— temperature=1 always allowedtest_responses_gpt5_mini_drop_temperature— gpt-5-mini also dropstest_responses_gpt5_chat_allow_temperature— gpt-5-chat not restricted