Day 0: gpt 5.4 mini and nano support#23958
Day 0: gpt 5.4 mini and nano support#23958Sameerlite merged 15 commits intoBerriAI:litellm_dev_sameer_16_march_weekfrom
Conversation
Add _is_reasoning_effort_level_explicitly_disabled to use opt-out semantics for minimal effort: unknown/unlisted models pass through, only blocked when the model map explicitly sets supports_minimal_reasoning_effort=false. xhigh keeps opt-in semantics (must be explicitly supported). Adds test for unknown-model passthrough and explicit-disabled detection. Made-with: Cursor
…, add xhigh tests - Remove unused _get_model_info_helper import - Normalize model via get_llm_provider in _is_reasoning_effort_level_explicitly_disabled so provider-prefixed names (openai/gpt-5.4-mini) resolve correctly - Add test_gpt5_4_mini_allows_reasoning_effort_xhigh - Add test_gpt5_4_nano_allows_reasoning_effort_xhigh - Add test_gpt5_4_mini_provider_prefixed_rejects_minimal - Extend test_gpt5_minimal_explicitly_disabled_check for openai/gpt-5.4-mini
Greptile SummaryThis PR adds Day-0 support for Key changes:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/llms/openai/chat/gpt_5_transformation.py | Adds minimal reasoning-effort guard with opt-out semantics; fixes pre-existing xhigh bug by now popping from both non_default_params and optional_params. Logic is sound; minor naming inconsistency in is_model_gpt_5_2_model now covers gpt-5.4-mini/nano. |
| litellm/utils.py | New _is_explicitly_disabled_factory helper correctly mirrors _supports_factory with opt-out (explicit-false-only) semantics, including the two-stage bare-model-key fallback and exception guard. |
| model_prices_and_context_window.json | Adds gpt-5.4-mini and gpt-5.4-nano with correct supports_xhigh/none_reasoning_effort: true and supports_minimal_reasoning_effort: false. Also adds supports_minimal_reasoning_effort: true to ~25 existing models — redundant under the opt-out semantics and could pass minimal through to models that don't actually support it. |
| tests/test_litellm/llms/openai/test_gpt5_transformation.py | Comprehensive mock-only tests cover xhigh allow/reject/drop, minimal allow/reject/drop, dict-format effort normalization, provider-prefixed model lookup, and the unknown-model pass-through invariant. All consistent with the new model map entries. |
| litellm/model_prices_and_context_window_backup.json | Identical changes to the primary model cost file; same redundant supports_minimal_reasoning_effort: true additions to existing models. |
| docs/my-website/blog/gpt_5_4_mini_nano/index.md | New blog post documenting gpt-5.4-mini and gpt-5.4-nano usage; content is accurate relative to the model map additions. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[map_openai_params called] --> B{effective_effort?}
B -- xhigh --> C{_supports_reasoning_effort_level?\nopt-in: explicit True required}
C -- supported --> D[pass xhigh through]
C -- not supported --> E{drop_params?}
E -- yes --> F[pop from non_default_params\nAND optional_params]
E -- no --> G[raise UnsupportedParamsError]
B -- minimal --> H{_is_reasoning_effort_level_explicitly_disabled?\nopt-out: explicit False required}
H -- explicitly disabled\ni.e. supports_minimal=false in map --> I{drop_params?}
I -- yes --> J[pop from non_default_params\nAND optional_params]
I -- no --> K[raise UnsupportedParamsError]
H -- not disabled\nmissing key OR true --> L[pass minimal through]
B -- other / none / null --> M[continue normal flow]
Comments Outside Diff (2)
-
litellm/llms/openai/chat/gpt_5_transformation.py, line 78-81 (link)Misleading method name covers gpt-5.4 variants
is_model_gpt_5_2_modelreturnsTruefor any model starting withgpt-5.4(including the newly-addedgpt-5.4-miniandgpt-5.4-nano), but the name implies it only covers the 5.2 family. While this predates this PR, the addition of newgpt-5.4-*models makes the confusion worse. If this method is called by external or downstream code to gate 5.2-specific behaviour, it will silently include the new mini/nano variants in that gate. Consider renaming it tois_model_gpt_5_2_or_later_modelor splitting the gpt-5.4 branch into its own predicate to avoid unintended side-effects. -
model_prices_and_context_window.json, line 328-370 (link)supports_minimal_reasoning_effort: trueadditions are redundantThe opt-out semantics of
_is_explicitly_disabled_factorytreat a missing key identically to an explicittrue— unknown models pass through. Adding"supports_minimal_reasoning_effort": trueto every pre-existing model (gpt-5.1, gpt-5.2, gpt-5-pro, gpt-5-codex, gpt-5-nano, etc.) is therefore a no-op from a runtime perspective; it neither protects nor enables anything.The real risk is the reverse: if any of those models actually do not support
minimalin the live API (e.g. gpt-5-codex, gpt-5.1-codex), they now have an explicittruethat will passminimalthrough to OpenAI, potentially surfacing a 400 from the upstream API rather than a clean LiteLLM error. Given the number of models touched (~25), it is worth double-checking each one before merging.The only entries that carry real meaning are the explicit
falsevalues ongpt-5.4-miniandgpt-5.4-nano, which correctly blockminimal.
Last reviewed commit: "Add test for reasoni..."
2d02eaa
into
BerriAI:litellm_dev_sameer_16_march_week
…reasoning effort handling (BerriAI#23958)
Relevant issues
All the prices are correct and checked based on the website: https://developers.openai.com/api/docs/models/gpt-5.4-mini
Both of these models support xhigh and none and have been tested locally.
No actual test has been added for this model as that would concur cost, and as we have verified that these models work locally without any error based on all the info in the model cost map
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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 reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🆕 New Feature
Changes