feat(gpt-5): Add supports_none_reasoning_effort and supports_xhigh_reasoning_effort to model cost map#22953
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR replaces hardcoded model-name checks ( However, two issues need to be addressed before merging:
Confidence Score: 2/5
|
| Filename | Overview |
|---|---|
| model_prices_and_context_window.json | Critical regression: supports_web_search: true was accidentally removed from gpt-5.1, gpt-5.1-2025-11-13, and gpt-5.1-chat-latest when adding the new reasoning-effort flags. The backup file has the correct edit; the main file does not. |
| litellm/model_prices_and_context_window_backup.json | Correctly adds supports_none_reasoning_effort and supports_xhigh_reasoning_effort to all GPT-5 model entries without accidentally removing any existing fields. |
| litellm/llms/openai/chat/gpt_5_transformation.py | Good refactor replacing hardcoded model-name checks with a dynamic model-map lookup via _supports_factory. However, the new helper doesn't strip provider/routing prefixes (e.g. gpt5_series/) before calling _supports_factory, which can silently return False for valid Azure-routed models. |
| litellm/llms/azure/chat/gpt_5_transformation.py | Correctly replaces is_model_gpt_5_1_model with _supports_reasoning_effort_level, but inherits the prefix-stripping gap from the OpenAI class — Azure deployment names passed with the gpt5_series/ prefix won't resolve correctly in the model map. |
| litellm/types/utils.py | Clean addition of supports_none_reasoning_effort and supports_xhigh_reasoning_effort as optional bool fields to ProviderSpecificModelInfo. |
| tests/test_litellm/llms/openai/test_gpt5_transformation.py | Tests are updated to reflect the new model-map-based detection. However, gpt-5.3-chat-latest is silently dropped from the temperature-restriction test loop, reducing regression coverage. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User calls with model + reasoning_effort] --> B{Is model GPT-5?}
B -- No --> C[Standard path]
B -- Yes --> D[_supports_reasoning_effort_level]
D --> E[_supports_factory]
E --> F[litellm.get_llm_provider]
F --> G{Provider resolved?}
G -- "openai/azure (normal model name)" --> H[_get_model_info_helper]
G -- "gpt5_series/ prefix (unrecognized)" --> I[Exception → returns False ⚠️]
H --> J{Key in model_cost?}
J -- Yes --> K[Return flag value]
J -- No --> L[Bare model key fallback]
L --> M[Return flag or False]
K --> N{supports_none?}
M --> N
N -- True --> O[Allow flexible temperature\nAllow logprobs\nAllow reasoning_effort=none]
N -- False --> P[Drop or raise UnsupportedParamsError]
D2[supports_xhigh check] --> E2[_supports_factory]
E2 --> Q{Model in map with xhigh=true?}
Q -- Yes --> R[Allow reasoning_effort=xhigh]
Q -- No --> S[Drop or raise error]
Comments Outside Diff (3)
-
model_prices_and_context_window.json, line 514-516 (link)supports_web_searchaccidentally removed from gpt-5.1 entriesWhen adding the new
supports_none_reasoning_effort/supports_xhigh_reasoning_effortfields, the existing"supports_web_search": trueproperty was dropped forgpt-5.1,gpt-5.1-2025-11-13, andgpt-5.1-chat-latest. Contrast with the backup file where the same edit was done correctly (the new keys were appended without touchingsupports_web_search).Affected entries (all in
model_prices_and_context_window.json):gpt-5.1(~line 514)gpt-5.1-2025-11-13(~line 524)gpt-5.1-chat-latest(~line 534)
The diff for
gpt-5.1shows:- "supports_web_search": true + "supports_none_reasoning_effort": true, + "supports_xhigh_reasoning_effort": false
supports_web_search: trueneeds to be kept alongside the new keys: -
tests/test_litellm/llms/openai/test_gpt5_transformation.py, line 922-923 (link)gpt-5.3-chat-latestsilently dropped from temperature-restriction testgpt-5.3-chat-latestwas removed from the loop without explanation. The model map entry forgpt-5.3-chat-latesthassupports_none_reasoning_effort: false, so strict temperature behavior (temperature != 1→UnsupportedParamsError) should still apply — yet the test no longer verifies this. Removing it reduces regression coverage for that model and makes it harder to catch future accidental relaxations.Consider keeping
gpt-5.3-chat-latestin the loop or adding a comment explaining why its behavior is now covered elsewhere. -
litellm/llms/openai/chat/gpt_5_transformation.py, line 58-62 (link)gpt5_series/prefix not stripped before model map lookupThe removed helpers (
is_model_gpt_5_1_model,is_model_gpt_5_1_codex_max_model) all didmodel.split("/")[-1]to handle provider-prefixed model strings. The new_supports_reasoning_effort_levelpasses the rawmodelvalue directly to_supports_factory, which in turn callslitellm.get_llm_provider(model=model, ...).In the Azure layer (
AzureOpenAIGPT5Config), the model string can arrive with agpt5_series/prefix (e.g.gpt5_series/gpt-5.1) becausetransform_requestis the only method that strips it —get_supported_openai_paramsandmap_openai_paramsdo not. Sincegpt5_seriesis not a recognized LiteLLM provider,get_llm_providerwill either raise (caught by thetry/exceptand returnsFalse) or resolve to a provider with no matching cost entry. Either way,_supports_reasoning_effort_levelsilently returnsFalsefor anygpt5_series/-prefixed model.The regression: on Azure, models routed via the
gpt5_series/prefix will no longer havereasoning_effort='none'or'xhigh'recognized, causing unexpected errors or silent parameter drops.Consider normalizing the model name before calling
_supports_factory(extracting only the last path segment, just like the old helpers did) to fix this.
Last reviewed commit: 6ba2e9f
…asoning_effort to model cost map - Shift from hardcoded model checks to dynamic lookup via _supports_factory - Add supports_none_reasoning_effort for gpt-5.1/5.2/5.4 chat variants - Add supports_xhigh_reasoning_effort for gpt-5.1-codex-max, gpt-5.2, gpt-5.4+ - Update model_prices_and_context_window.json and backup - Add ProviderSpecificModelInfo types for new fields - Fix Azure: use _supports_reasoning_effort_level instead of removed is_model_gpt_5_1_model Made-with: Cursor
9f2c6c6 to
6ba2e9f
Compare
feat(gpt-5): Add supports_none_reasoning_effort and supports_xhigh_reasoning_effort to model cost map
Summary
Shifts GPT-5 reasoning effort detection from hardcoded model checks to dynamic lookup via the model cost map.
Changes
supports_none_reasoning_effortandsupports_xhigh_reasoning_effortto all GPT-5 model entriesis_model_gpt_5_1_model,is_model_gpt_5_1_codex_max_modelwith_supports_reasoning_effort_level()using_supports_factory_supports_reasoning_effort_levelfor reasoning_effort='none' and logprobs logicProviderSpecificModelInfoinlitellm/types/utils.pytest_gpt5_1_model_detectionto assert model map lookup behaviorModels affected
Testing
All 44 tests pass.
Made with Cursor