Repository navigation
fix(pricing): drop the unpublished cached rate from the Gemini Live preview entries - #42651
Conversation
azure/gpt-realtime-2 was the only member of the gpt-realtime-2 family priced on one side of its cached-audio meter. Azure publishes that meter as "gpt-realtime-2 Audio cd inp Gl 1M Tokens" at 0.4 per 1M and charges the same rate for the write that populates the cache and the read that hits it, so cache_creation_input_audio_token_cost lands at 4e-07, matching azure/gpt-realtime-2.1, azure/gpt-realtime-2.1-mini and the openai gpt-realtime-2 entry. No cost path reads that field yet, so this corrects what get_model_info reports rather than what anything bills. The gemini Live entries go the other way. Google's Vertex context-caching page publishes separate supported-model lists for implicit and explicit caching, and no Live or native-audio model is in either one. Its pricing page prints N/A in both cached-input columns for every Gemini 2.5 Flash Live API row, where plain 2.5 Flash and 2.5 Flash-Lite both carry real cached prices, and the Vertex model card for the family marks context caching not supported outright. Vertex never reports cachedContentTokenCount on a Live session either, including for a byte-identical 7,021-token prefix replayed across sessions minutes apart, which is well past the 2,048-token minimum the same page sets for the Gemini 2 family. So the 7.5e-08 on the two preview siblings priced something the provider does not sell, and supports_prompt_caching on all three claimed a capability the model does not have. The rate comes out. The flag is set to false rather than removed, because get_model_info maps an absent key to None, and None is how this map spells "nobody checked" across the 2,788 entries that omit it, where false records the vendor's documented no. Both readers of the flag gate on `is True`, so nothing bills or behaves differently either way. Only the cached fields change on the two 09-2025 preview entries. Their source field points at the Gemini API pricing page rather than the Vertex one, so they describe a different surface with its own published limits, and their context windows are left alone rather than assumed to match the Vertex model card that drives the GA entry. Tests cover all three halves: the family invariant that a cached audio read implies an equal cached audio write, a cached count on a Live entry leaving the bill at the fresh-input total instead of adding the old 7.5e-08, and supports_prompt_caching answering false for all three entries while still answering true for 2.5 Flash, so the false cannot be a swallowed lookup error.
…bilities Google's model card for model ID gemini-live-2.5-flash-native-audio gives a 128K context window and 64K maximum output tokens, and marks structured output, context caching and URL context as not supported. Its modality list is text in and out, image in, audio in and out, and video in, with no document input of any kind. The entry advertised a 1M context window, an off-by-one 65535 output cap, and three capability flags the vendor marks unsupported. Context caching is the fourth and is handled in the cached-fields change alongside its two preview siblings. Both the bare id and vertex_ai/gemini-live-2.5-flash-native-audio resolve to this single entry, so the test drives the corrected values through both.
…sh rate Co-authored-by: Marty Sullivan <marty@martysullivan.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… docstrings Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 790500e. Configure here.
TLDR
Problem this solves:
supports_prompt_caching: truefor a model whose card says not supportedHow it solves it:
cache_read_input_token_costand setsupports_prompt_caching: falseon both preview entries/spend/calculatebills 100k cached tokens like fresh ones on both idsThis supersedes #40018, which sits on a fork no maintainer credential can push to and was based on the stale
litellm_internal_staging. The pricing and capability changes are the contributor's own commits, carried over with authorship intact and credited as co-author on the test commit. Relative to that PR, the GAgemini-live-2.5-flash-native-audiocorrection had already landed onmain, andazure/gpt-realtime-2was removed from the map onmainas past its deprecation date, so both parts dropped out and only the two preview entries change. The vendor reads backing the values (Vertex pricing table printingN/Ain both cached columns for every Live row, the context-caching page listing no Live model, the model card marking caching not supported) are reproduced in the original PR's descriptionUser Flow
Before: a developer planning around the Gemini Live preview model reads the gateway catalog and is told a cache exists that it never gets
gemini-live-2.5-flash-preview-native-audio-09-2025entry reportssupports_prompt_caching: trueandcache_read_input_token_cost: 7.5e-08{"cost":0.008}, charging the cached tokens at $0.075 per 1MAfter: the same catalog reports what Google documents, so the developer never chases a cache that does not exist
supports_prompt_caching: falseand no cached rate{"cost":0.0505}, every input token at the fresh $0.50 per 1MRelevant issues
Supersedes #40018
Affected release
Linear ticket
Resolves LIT-7110
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)tests/test_litellm/test_cost_calculator.pycarries the contributor's tests reworked onto main's layout: thegpt-realtime-2family invariant that a cached audio read implies an equal cached audio write, a cached count on the preview entries leaving the bill at the fresh-input total, andsupports_prompt_cachinganswering false for the Live entries while still answering true forgemini-2.5-flashso a swallowed lookup error cannot read as a pass.tests/integration/spend/test_spend_calculate.py::test_live_preview_entry_charges_cached_tokens_at_the_fresh_rateruns the same check through a real proxy for both the bare andgemini/ids, asserting equal cost with 100k cached and 0 cached tokens. Re-addingcache_read_input_token_cost: 7.5e-08to the bare preview entry turns that test red (0.008 vs 0.0505)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Proxy started on the local cost map with
LITELLM_LOCAL_MODEL_COST_MAP=True python litellm/proxy/proxy_cli.py --config proof_config.yaml --port 4111, whereproof_config.yamllistsgemini/gemini-live-2.5-flash-preview-native-audio-09-2025with a dummy key./spend/calculateis a pure catalog lookup, so no provider call is involvedBefore (merge base b0ac23d, origin/main)
After (tip fd57f3c, litellm_realtime_cost_map_residuals)
After: the stale 7.5e-08 cache-read rate is gone and the entry no longer advertises prompt caching, so 100k cached + 1k fresh tokens bill at the base input rate (101000 * 5e-07 = 0.0505) instead of 0.008
Caveats
The two preview entries cite the Gemini API pricing page rather than the Vertex one, so their context windows are left alone rather than assumed to match the Vertex model card. Nothing bills off
supports_prompt_caching; both readers gate onis True, so the flag change only corrects whatget_model_inforeportsLink to Devin session: https://app.devin.ai/sessions/4a9380d932644b428478a7eebbd41b57
Open in Devin Desktop: https://app.devin.ai/desktop/session/4a9380d932644b428478a7eebbd41b57?variant=devin
Note
Medium Risk
Changes spend and model-info behavior for two realtime models; corrected billing may increase reported costs where cached tokens were previously underpriced.
Overview
Corrects Gemini Live preview native-audio catalog entries (
gemini-live-2.5-flash-preview-native-audio-09-2025and thegemini/alias) so they match Google’s docs:cache_read_input_token_costis removed andsupports_prompt_cachingis set tofalsein bothmodel_prices_and_context_window.jsonand its backup.Without a cached read rate, 100k “cached” prompt tokens bill at the fresh input rate instead of the old phantom discount (e.g. spend/calculate moves from ~$0.008 to ~$0.0505 for the example usage). Unit tests lock in the Live native-audio family (no cached rate, equal cost with/without
cached_tokens, caching unsupported vsgemini-2.5-flashcontrol) plus a gpt-realtime-2 audio cache read/write parity check. An integration test on/spend/calculatecovers both model ids.Reviewed by Cursor Bugbot for commit 790500e. Bugbot is set up for automated code reviews on this repo. Configure here.