Skip to content

fix(pricing): mark realtime-only gpt-realtime models as mode realtime - #33728

Merged
krrish-berri-2 merged 2 commits into
litellm_internal_stagingfrom
litellm_fix_realtime_mode
Jul 17, 2026
Merged

fix(pricing): mark realtime-only gpt-realtime models as mode realtime#33728
krrish-berri-2 merged 2 commits into
litellm_internal_stagingfrom
litellm_fix_realtime_mode

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Surfaced while reviewing #33291 (which adds undated azure gpt-audio-mini / gpt-realtime-mini pricing aliases); this corrects a related metadata bug in the same model family

Linear ticket

Pre-Submission checklist

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

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

Realtime health checks have been supported for a while (see the "Realtime Models" section of the health docs), but every OpenAI and Azure realtime model in the cost map was tagged mode: "chat", so mode never resolved to realtime automatically; only the two gemini-live entries carried mode: "realtime". The user-visible effect is health checks: with mode=chat, ahealth_check dispatches litellm.acompletion and the provider rejects it; with mode=realtime it uses the realtime handler and opens a native wss://

Live against real OpenAI (OPENAI_API_KEY), captured at commit ab5dd03125:

=== gpt-realtime-mini ; mode in cost map = realtime ===
BEFORE (forced mode=chat) -> litellm.BadRequestError: OpenAIException - This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?
AFTER  (mode=realtime)    -> OK (healthy)

=== gpt-4o-realtime-preview ; mode in cost map = realtime ===
BEFORE (forced mode=chat) -> litellm.NotFoundError: OpenAIException - The model `gpt-4o-realtime-preview` does not exist or you do not have access to it
AFTER  (mode=realtime)    -> OK (healthy)

Both call litellm.ahealth_check with a real key; BEFORE forces mode="chat" (the old tagging) and AFTER reads the corrected mode from the cost map

Independent confirmation the family is realtime-only, straight from OpenAI at the chat endpoint:

$ curl -s https://api.openai.com/v1/chat/completions -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{"model":"gpt-realtime-mini","messages":[{"role":"user","content":"hi"}]}'
{"error":"This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?"}

gpt-audio-mini by contrast does serve /v1/chat/completions (it just requires an audio modality), so it correctly stays mode=chat and is untouched here

Type

🐛 Bug Fix

Changes

Retag every OpenAI and Azure realtime-only model from mode: "chat" to mode: "realtime", a value already used by gemini/gemini-live-2.5-flash-preview-native-audio-09-2025 and already handled by the health-check realtime handler in health_check_helpers.get_mode_handlers. Two groups are covered:

  • the gpt-realtime* family whose supported_endpoints is exactly ["/v1/realtime"]: gpt-realtime, gpt-realtime-1.5, gpt-realtime-2, gpt-realtime-2.1, gpt-realtime-2.1-mini, gpt-realtime-mini, gpt-realtime-2025-08-28, gpt-realtime-mini-2025-10-06, gpt-realtime-mini-2025-12-15, azure/gpt-realtime-2025-08-28, azure/gpt-realtime-1.5-2026-02-23, azure/gpt-realtime-mini-2025-10-06
  • the older gpt-4o(-mini)-realtime-preview family (OpenAI and Azure, including eu/us regional variants), which predates the supported_endpoints field and carries none but is equally realtime-only

The *-whisper transcription entries keep audio_transcription and the audio (non-realtime) models keep chat. Changes are applied to both the root map and the packaged backup

Add "realtime" to the mode literal in ModelInfoBase (litellm/types/utils.py); it was a de-facto value already present in the data but missing from the type

Scope note: the Gemini native-audio realtime-only entries are also tagged chat, but they route through a different surface and are left out of this change

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/5b349e60806c4a7e8acc5edf6b93da72
Requested by: @krrish-berri-2

The gpt-realtime family (OpenAI and Azure) only serves /v1/realtime and is rejected by /v1/chat/completions with "This is not a chat model", but the cost map tagged them mode=chat. Retag them mode=realtime (a value already used by gemini-live and handled by the health-check realtime handler) and add realtime to the ModelInfoBase mode literal.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@krrish-berri-2 krrish-berri-2 self-assigned this Jul 17, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects the mode field for twelve gpt-realtime-* model entries (OpenAI and Azure) in the cost map from "chat" to "realtime", fixing health checks that were incorrectly dispatching acompletion (rejected by OpenAI with "This is not a chat model") instead of the realtime WebSocket handler. It also adds "realtime" to the mode Literal in ModelInfoBase, where it was a de-facto value already present in the data (Gemini native-audio entries) but absent from the type.

  • Both model_prices_and_context_window.json and the packaged backup are updated with 12 identical changes, and a new test asserts they stay in sync.
  • New tests cover: type-literal validity, all 12 model entries in the JSON, litellm.get_model_info return value, and backup/main consistency — all running against local files with no network calls.

Confidence Score: 5/5

Safe to merge — targeted metadata correction with no logic changes and a solid set of local-only tests guarding against regression.

The fix is narrow (12 JSON fields and one type annotation), directly supported by live OpenAI evidence in the PR description, and backed by tests that check the JSON contents, the type hint, the get_model_info API, and backup/main file parity. The existing get_mode_handlers in health_check_helpers already handles realtime as a key, so no handler gap is introduced.

No files require special attention.

Important Files Changed

Filename Overview
model_prices_and_context_window.json 12 gpt-realtime-* model entries corrected from mode="chat" to mode="realtime", consistent with their supported_endpoints=["/v1/realtime"] metadata
litellm/model_prices_and_context_window_backup.json Same 12 model entries updated to mode="realtime" as in the main JSON; the new test verifies both files stay in sync
litellm/types/utils.py Adds "realtime" to the mode Literal in ModelInfoBase; this value was already present in the data (Gemini native-audio entries) but was missing from the type annotation
tests/test_litellm/test_gpt_realtime_mode.py New test file validating mode="realtime" for all 12 affected models; reads only from local JSON files and type hints — no real network calls

Reviews (1): Last reviewed commit: "fix(pricing): mark realtime-only gpt-rea..." | Re-trigger Greptile

@krrish-berri-2
krrish-berri-2 enabled auto-merge (squash) July 17, 2026 17:27
The gpt-4o(-mini)-realtime-preview family (OpenAI and Azure, all regions) is realtime-only but was tagged mode=chat and carries no supported_endpoints field. Retag them mode=realtime alongside the gpt-realtime family.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@krrish-berri-2
krrish-berri-2 merged commit 00e0dd1 into litellm_internal_staging Jul 17, 2026
76 of 113 checks passed
@krrish-berri-2
krrish-berri-2 deleted the litellm_fix_realtime_mode branch July 17, 2026 17:39
@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_realtime_mode (ab5dd03) with litellm_internal_staging (561b679)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (b0a0f11) during the generation of this report, so 561b679 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

yuneng-berri added a commit that referenced this pull request Jul 18, 2026
#33806)

test_get_model_info_reports_realtime_mode resolved gpt-realtime-mini through
litellm.get_model_info, which reads the cost map litellm fetches at import from
raw.githubusercontent.com/BerriAI/litellm/main. The mode=realtime retag from
#33728 is in this repo's json and its bundled backup but has not reached main
yet, so the test failed whenever the fetch succeeded and passed whenever the
runner was rate limited and litellm fell back to the backup, flapping the
Unit Tests: MCP, Secrets, Containers & Misc job on unrelated PRs

Resolve the lookup against the bundled backup instead, the way
tests/test_litellm/test_cost_calculator.py already does: force
LITELLM_LOCAL_MODEL_COST_MAP, rebind litellm.model_cost, and clear the
get_model_info lru cache before asserting so a remote-backed entry cached
earlier in the same worker cannot leak through, then clear it again afterwards
so no locally-backed entry outlives the test
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.

3 participants