fix(cost): Gemini 2.5 cache reads are 10% of input, not 25% (2.5x overcharge) - #5791
Open
xyzs996 wants to merge 1 commit into
Open
fix(cost): Gemini 2.5 cache reads are 10% of input, not 25% (2.5x overcharge)#5791xyzs996 wants to merge 1 commit into
xyzs996 wants to merge 1 commit into
Conversation
Google publishes context caching for every Gemini 2.5 model at 10% of the input price: 2.5 Pro $1.25/M in -> $0.125/M cached (10%) 2.5 Flash $0.30/M in -> $0.03/M cached (10%) 2.5 Flash-Lite $0.10/M in -> $0.01/M cached (10%) 2.5 Flash-Lite $0.30/M audio in -> $0.03/M cached audio (10%) 25% is the deprecated Gemini 2.0 Flash ratio ($0.10 in / $0.025 cached). 2.0 Flash was shut down on 2026-06-01; the 2.5 rows kept its number. All four Gemini 3.x models in this repo already use 0.1, and the audio block inside gemini-2.5-flash already reads 0.1, so this restores the repo's own convention rather than introducing one. cachedInput: 0.25 elsewhere (openai gpt-4.1 / o3 / o4 / gpt-5.1, xai) is correct for those providers and is left untouched. Snapshot regenerated with jest -u; packages/__tests__/cost is green (13 suites, 190 tests).
|
@xyzs996 is attempting to deploy a commit to the Helicone Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
None — found while diffing this registry against Google's published rates.
Component/Service
Type of Change
Deployment Notes
Context
All three Gemini 2.5 models price a cache read at 25% of input. Google publishes 10% for
every one of them, so cached input is billed at 2.5x.
25% is not an arbitrary number — it is the ratio for Gemini 2.0 Flash ($0.10/M in,
$0.025/M cached). 2.0 Flash was shut down on 2026-06-01. The 2.5 rows are still carrying its
multiplier.
Google's current rates (ai.google.dev/gemini-api/docs/pricing):
gemini-2.5-pro0.25gemini-2.5-progemini-2.5-flash0.25gemini-2.5-flash-lite0.25gemini-2.5-flash-lite(audio)0.0833333gemini-2.0-flash(deprecated)The repo already disagrees with itself in two places. All four Gemini 3.x models use
0.1:And inside
gemini-2.5-flash/endpoints.tsthe audio line one block above already reads 10% whilethe
cacheMultipliersblock below it reads 25%:What this costs a user
Cache reads dominate agent traffic, so the error lands almost entirely on the token type that
carries the bill. Per 1M cache-read tokens:
gemini-2.5-progemini-2.5-flashgemini-2.5-flash-liteBlended at a coding agent's measured token mix (95.6% cache read / 4.1% cache miss / 0.3%
output, over 8.04B tokens), the reported cost per 1M tokens is 90% / 89% / 97% too high for
Pro / Flash / Flash-Lite respectively — the bill roughly doubles.
Changes
Six
cachedInputvalues and twocachedInputMultipliervalues,google-ai-studioandvertexblocks in each file:
Snapshot regenerated with
npx jest __tests__/cost/registrySnapshots.test.ts -u.npx jest __tests__/costpasses: 13 suites, 190 tests, 8 snapshots.Extra Notes
cachedInput: 0.25elsewhere is correct and is not touched. It appears 29 more times underopenai/gpt-4.1,openai/o3,openai/o4,openai/gpt-5.1andxai/— OpenAI and xAI really dodiscount cached input to 25%. That is exactly why a stale 25% on a Gemini row does not look wrong
on inspection.
What I verified and what I did not. I verified the four rates above against the Gemini API
pricing page. I could not get the Vertex AI pricing page to render its tables, so the three
vertexlines rest on this repo's own convention — every Gemini 3.x model here carries identicalcachedInputon thegoogle-ai-studioandvertexblocks. If Vertex actually differs, thevertexhalf of this diff should be dropped and the studio half kept.One thing I left alone.
gemini-2.5-pro'sthreshold: 200000tier hasinput: 0.0000025butno
cacheMultipliersblock at all, so there is no cached-input rate for prompts over 200k. Googlecharges $0.25/M there (10% of $2.50). Adding the block would change behaviour for that tier rather
than correct a wrong number, so I did not fold it into this PR — flagging it in case you want it.