Skip to content

Add day 0 support for gpt-5.4#22916

Merged
Sameerlite merged 2 commits intomainfrom
litellm_gpt-5.4_day_0
Mar 5, 2026
Merged

Add day 0 support for gpt-5.4#22916
Sameerlite merged 2 commits intomainfrom
litellm_gpt-5.4_day_0

Conversation

@Sameerlite
Copy link
Collaborator

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Mar 5, 2026 6:12pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 5, 2026

Greptile Summary

This PR adds day-0 support for gpt-5.4 by registering two new model entries in pricing/context-window JSON files, extending GPT-5 classification helpers, and adding a blog post.

Key blockers:

  • No tests added — The pre-submission checklist explicitly requires "Adding at least 1 test" as a hard requirement. Existing test files (tests/test_litellm/llms/openai/test_gpt5_transformation.py and tests/test_litellm/llms/azure/chat/test_azure_gpt5_transformation.py) already cover gpt-5.2 scenarios; tests covering gpt-5.4 classification paths (e.g., is_model_gpt_5_1_model("gpt-5.4") returning true, map_openai_params with reasoning_effort="xhigh") must be added before merge.

  • Hardcoded model checks violate no-hardcoding rule — Lines 65-69 and 82 in gpt_5_transformation.py use direct startswith("gpt-5.4") pattern matching instead of reading capabilities from the JSON via helper functions (custom rule 2605a1b1). This pattern will require code changes for every future model revision (e.g., gpt-5.5, gpt-5.4-turbo) instead of allowing JSON-only updates.

  • is_model_gpt_5_2_model method name is semantically incorrect — Returns True for both gpt-5.2 and gpt-5.4, misleading future maintainers. Downstream callers in Azure config silently apply gpt-5.2 parameter handling to gpt-5.4 without explicit indication.

  • Documentation error in blog post — Docker image tag references gpt-4o instead of a release containing gpt-5.4 support.

Not flagged (speculative in prior reviews):

  • mode field differs between gpt-5.4 ("responses") and gpt-5.2 ("chat")
  • supported_output_modalities differs (gpt-5.4 has ["text"] only)
    These observations are factually accurate but lacked concrete evidence that they are incorrect, rather than intentional differences reflecting actual API behavior.

Confidence Score: 1/5

  • Not safe to merge — required tests are missing, and architectural violations of the custom no-hardcoding rule remain unresolved.
  • The PR fails two blocking requirements: (1) The pre-submission checklist mandates at least one test as a hard requirement; no gpt-5.4 tests exist in the codebase. (2) The hardcoded startswith("gpt-5.4") checks in gpt_5_transformation.py directly violate custom rule 2605a1b1, which explicitly requires model capabilities to be read from JSON via helper functions, not embedded in transformation code. Additionally, the is_model_gpt_5_2_model method is semantically incorrect (returns true for both gpt-5.2 and gpt-5.4 despite its name), and the blog post references the wrong Docker image tag. None of these issues have been addressed since they were flagged in prior review threads.
  • litellm/llms/openai/chat/gpt_5_transformation.py (hardcoding violations + semantic issue with method naming), test files (missing gpt-5.4 test coverage), docs/my-website/blog/gpt_5_4/index.md (incorrect Docker image tag)

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Model String"] --> B{"is_model_gpt_5_1_model?"}
    B -->|startswith gpt-5.1| C["True — full sampling params allowed"]
    B -->|startswith gpt-5.2, no pro, no -chat| C
    B -->|startswith gpt-5.4, no pro, no -chat| C
    B -->|other gpt-5 models| D["False — logprobs/top_p/top_logprobs removed"]

    A --> E{"is_model_gpt_5_2_model?"}
    E -->|startswith gpt-5.2| F["True — xhigh effort + Azure logprobs"]
    E -->|startswith gpt-5.4| F
    E -->|other| G["False"]

    F --> H{"Azure path?"}
    H -->|Yes| I["logprobs added back to supported params"]
    H -->|No — OpenAI| J["xhigh reasoning_effort allowed"]
    
    K["⚠️ Issue: Both methods use hardcoded startswith checks<br/>violating no-hardcoding rule 2605a1b1"]
    L["⚠️ Issue: is_model_gpt_5_2_model returns true for gpt-5.4<br/>despite its name — semantically incorrect"]
Loading

Last reviewed commit: 3b457b5

Comment on lines +65 to +70
is_gpt_5_4 = (
model_name.startswith("gpt-5.4")
and "pro" not in model_name
and not model_name.startswith("gpt-5.4-chat")
)
return is_gpt_5_1 or is_gpt_5_2 or is_gpt_5_4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded model name violates no-hardcoding rule

The custom rule for this repository explicitly prohibits hardcoding model-specific flags directly in transformation code. Instead, capabilities should be read from model_prices_and_context_window.json via helper functions like get_model_info or supports_reasoning().

gpt-5.4 is already added to the JSON with "supports_reasoning": true, "supports_tool_choice": true, etc. The code should leverage those fields rather than adding another startswith("gpt-5.4") guard. This means every future model revision (e.g. gpt-5.5, gpt-5.4-turbo) will again require a code change instead of a JSON update.

The same hardcoded pattern also exists in is_model_gpt_5_2_model (line 82) and propagates to the Azure config at litellm/llms/azure/chat/gpt_5_transformation.py:49,51.

Context Used: Rule from dashboard - What: Do not hardcode model-specific flags in the codebase. Instead, put them in model_prices_and_co... (source)

Comment on lines 79 to +82
def is_model_gpt_5_2_model(cls, model: str) -> bool:
"""Check if the model is a gpt-5.2 variant (including pro)."""
model_name = model.split("/")[-1]
return model_name.startswith("gpt-5.2")
return model_name.startswith("gpt-5.2") or model_name.startswith("gpt-5.4")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_model_gpt_5_2_model now incorrectly returns True for gpt-5.4

The method is named is_model_gpt_5_2_model but now returns True for gpt-5.4 models too:

return model_name.startswith("gpt-5.2") or model_name.startswith("gpt-5.4")

This is semantically wrong and will be a source of confusion for future contributors who call is_model_gpt_5_2_model(model) and expect it to only match gpt-5.2 family models. All downstream callers in azure/chat/gpt_5_transformation.py (lines 49 and 51) now silently treat gpt-5.4 as gpt-5.2 without any indication that this is intentional.

If gpt-5.4 needs the same logprobs/xhigh treatment as gpt-5.2, a more maintainable approach would be to introduce a separate is_model_gpt_5_4_model method and update the call-sites explicitly, or better, to consolidate these checks into a single capability-based helper that reads from model info.

Comment on lines 20811 to 20852
"supports_web_search": true
},
"gpt-5.4": {
"cache_read_input_token_cost": 2.5e-07,
"cache_read_input_token_cost_priority": 5e-07,
"input_cost_per_token": 2.5e-06,
"input_cost_per_token_priority": 5e-06,
"litellm_provider": "openai",
"max_input_tokens": 272000,
"max_output_tokens": 128000,
"max_tokens": 128000,
"mode": "responses",
"output_cost_per_token": 1.5e-05,
"output_cost_per_token_priority": 3e-05,
"supported_endpoints": [
"/v1/chat/completions",
"/v1/batch",
"/v1/responses"
],
"supported_modalities": [
"text",
"image"
],
"supported_output_modalities": [
"text",
"image"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_pdf_input": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_service_tier": true,
"supports_vision": true
},
"gpt-5-pro": {
"input_cost_per_token": 1.5e-05,
"input_cost_per_token_batches": 7.5e-06,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mode field differs from gpt-5.2

gpt-5.4 is registered with "mode": "responses", while gpt-5.2 (line 20618) uses "mode": "chat". If the mode field drives routing or feature detection elsewhere in LiteLLM, this inconsistency could cause gpt-5.4 to behave differently from gpt-5.2 in ways that aren't related to their actual API differences.

If gpt-5.4 genuinely operates only via the /v1/responses endpoint, this is correct — but it's worth double-checking because both models list /v1/chat/completions under supported_endpoints.

Comment on lines +31 to +33
docker pull ghcr.io/berriai/litellm:v1.81.14-stable.gpt-4o
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker image tag references wrong model

The Docker image pulled and run in the usage example is tagged v1.81.14-stable.gpt-4o, which refers to GPT-4o, not GPT-5.4. This should either be a generic/latest tag or updated to a tag that actually contains GPT-5.4 support.

Suggested change
docker pull ghcr.io/berriai/litellm:v1.81.14-stable.gpt-4o
```
docker pull ghcr.io/berriai/litellm:main-latest

@Sameerlite Sameerlite merged commit 8dca085 into main Mar 5, 2026
30 of 89 checks passed
Comment on lines +65 to +70
is_gpt_5_4 = (
model_name.startswith("gpt-5.4")
and "pro" not in model_name
and not model_name.startswith("gpt-5.4-chat")
)
return is_gpt_5_1 or is_gpt_5_2 or is_gpt_5_4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded model-specific flag violates the no-hardcoding rule. Custom rule [2605a1b1] explicitly requires putting model capabilities in model_prices_and_context_window.json and reading them via helper functions like supports_reasoning(), not via startswith() checks in the transformation code. This pattern propagates further to is_model_gpt_5_2_model() (line 82) and the Azure config. Future model revisions (e.g., gpt-5.5, gpt-5.4-turbo) will again require code changes instead of just updating the JSON.

If gpt-5.4 needs the same parameter handling as gpt-5.2 and gpt-5.1, add the necessary capability fields to its JSON entry and use a helper function to check them.

Context Used: Rule from dashboard - What: Do not hardcode model-specific flags in the codebase. Instead, put them in model_prices_and_co... (source)

Comment on lines 79 to +82
def is_model_gpt_5_2_model(cls, model: str) -> bool:
"""Check if the model is a gpt-5.2 variant (including pro)."""
model_name = model.split("/")[-1]
return model_name.startswith("gpt-5.2")
return model_name.startswith("gpt-5.2") or model_name.startswith("gpt-5.4")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name is_model_gpt_5_2_model() is semantically incorrect — it now returns True for both gpt-5.2 and gpt-5.4 models:

return model_name.startswith("gpt-5.2") or model_name.startswith("gpt-5.4")

This misleads future contributors who expect the method to only match gpt-5.2 variants. Downstream callers in azure/chat/gpt_5_transformation.py (lines 49, 51) silently apply gpt-5.2 parameter handling (logprobs support) to gpt-5.4 without explicit indication.

Consider either introducing a separate is_model_gpt_5_4_model() method with explicit call-site updates, or consolidating into a single capability-based helper that reads from model info.

## Docker Image

```bash
docker pull ghcr.io/berriai/litellm:v1.81.14-stable.gpt-4o
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker image tag references GPT-4o instead of GPT-5.4. The tag v1.81.14-stable.gpt-4o explicitly names gpt-4o, which conflicts with this blog post documenting gpt-5.4 support. Update to a release tag that actually contains gpt-5.4 support, or use a generic/latest tag if the appropriate release doesn't exist yet.

@vincentkoc
Copy link
Contributor

Related follow-up: #22734 adds the remaining ChatGPT OAuth aliases (chatgpt/gpt-5.4, chatgpt/gpt-5.4-pro, and GPT-5.3 aliases) plus gpt-5.4-pro model map/test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants