Skip to content

🐛 fix(model-bank): align Gemini -latest alias pricing and Gemini 2.5 cache-read rates - #18647

Open
xyzs996 wants to merge 3 commits into
lobehub:canaryfrom
xyzs996:fix/gemini-alias-and-2-5-cache-pricing
Open

xyzs996 wants to merge 3 commits into
lobehub:canaryfrom
xyzs996:fix/gemini-alias-and-2-5-cache-pricing

Conversation

@xyzs996

@xyzs996 xyzs996 commented Aug 24, 2026

Copy link
Copy Markdown

What

Three Gemini price rows in packages/model-bank/src/aiModels/google.ts disagree either with
Google's published rate card or with the row they say they mirror. All three make LobeHub's
displayed cost roughly 2x too high for cache-heavy traffic.

Every number below is from https://ai.google.dev/gemini-api/docs/pricing, checked today.

1. gemini-flash-latest is priced at the 2027 rate

#18289 repointed this alias from gemini-3.6-flash to gemini-3.7-flash and updated its
extendParams, but left the pricing block untouched. In the same PR, gemini-3.6-flash was
repriced down to the introductory rate — with a comment that spells out exactly what the alias
is now carrying:

// Introductory pricing, in effect through 2026-12-31. From 2027-01-01 standard rates apply:
// input 1.5 / output 7.5 / cacheRead 0.15 / cacheWrite lookup { '1h': 1 } (per million tokens).
input output cacheRead cacheWrite 1h
gemini-3.7-flash (target) 0.75 3.75 0.075 0.5
gemini-flash-latest (alias, today) 1.5 7.5 0.15 1

Exactly 2x, on every unit, until 2027-01-01.

2. gemini-pro-latest still carries Gemini 2.5 Pro's rate card

Its description says Points to gemini-3.1-pro-preview, but its numbers are 2.5 Pro's:

input ≤200k / >200k output cacheRead
gemini-3.1-pro-preview (target) 2 / 4 12 / 18 0.2 / 0.4
gemini-pro-latest (alias, today) 1.25 / 2.5 10 / 15 0.31 / 0.625

Input is 1.6x low, output 1.2x low, cache read 1.55x high. It is also missing the
imageInput / videoInput / audioInput / textInput_cacheWrite units the target has, so
multi-modal input on this alias currently bills at nothing.

The third alias, gemini-flash-lite-latest, matches its target exactly — that is the intended
convention, and it is the one the existing test happens to pin.

3. Gemini 2.5 cache reads are at the retired 2.0 ratio

Google charges 10% of input for context caching on 2.5. These rows use 25%, which was the
Gemini 2.0 rate:

model cacheRead today Google publishes
gemini-2.5-pro 0.31 / 0.625 0.125 / 0.25
gemini-2.5-flash 0.075 0.03
gemini-2.5-flash-lite 0.025 0.01

This is specifically a 2.5 problem: every 3.x row in the file already uses 10%, and the 2.0 and
1.5 rows correctly use 25% because that was the rate then, which is why it doesn't read as
wrong at a glance.

Impact

Priced at a coding agent's token mix — 95.6% cache read, 4.1% cache miss, 0.3% output, measured
over 8.04B tokens — per 1M tokens:

model LobeHub shows should be
gemini-flash-latest $0.2274 $0.1137 2.00x
gemini-2.5-flash-lite $0.0292 $0.0149 1.97x
gemini-2.5-pro (>200k) $0.7450 $0.3865 1.93x
gemini-2.5-flash $0.0915 $0.0485 1.89x
gemini-pro-latest (≤200k) $0.3776 $0.3092 1.22x

gemini-pro-latest is the mixed one: over-billed on cache reads, under-billed on input and
output, so a short uncached prompt is reported cheaper than it is.

Test

Google rolling model aliases already asserts flashLiteLatest.pricing === flashLite.pricing,
but only for that one pair — which is why the other two drifted. I replaced the one-off check
with a generic one that reads each alias's own description and compares against the model it
names, so repointing an alias without repricing it fails here:

it.each([
  ['gemini-pro-latest'],
  ['gemini-flash-latest'],
  ['gemini-flash-lite-latest'],
])('prices %s the same as the model it points to', (aliasId) => {

Two computeChatCost cases read gemini-2.5-pro's real pricing and had the old 0.625 baked
into their expected credits; those are updated with the arithmetic shown in the comments.

Not changed here

The same two rows exist elsewhere and I left them alone rather than guess:

  • vertexai.ts prices gemini-3.6-flash and gemini-3.7-flash at 1.5 / 7.5 / 0.15 — the
    post-2027 numbers — while google.ts has 0.75 / 3.75 / 0.075 for the same models. Same PR
    added both. I could not load Vertex's own pricing table to confirm Vertex mirrors AI Studio
    here, and gemini-2.0-flash is already priced differently in the two files (0.15 vs 0.10), so
    I did not assume it. Happy to include it if you confirm the direction.
  • vertexai.ts and aihubmix.ts carry the same 25% cache-read ratio on their Gemini 2.5 rows.
    aihubmix.ts mirrors google.ts exactly on every 3.x row, so those two rows are very likely the
    same defect — say the word and I'll add them to this PR.

Test

  • Tested locally
  • Added/updated tests
  • No tests needed
pnpm --filter model-bank    exec vitest run   →  8 files, 91 passed
pnpm --filter model-runtime exec vitest run   →  186 files, 4644 passed, 1 skipped
npx tsgo --noEmit                             →  exit 0
npx prettier --check <the 3 files>            →  clean

Negative control for the new assertion: with only gemini-flash-latest's pricing reverted to
its current values, prices gemini-flash-latest the same as the model it points to fails and
the other 16 still pass — so the test is pinning the thing it claims to pin.

🔗 Related Issue

None — found while diffing the catalog against Google's rate card. Related to #18289, which is
where the gemini-flash-latest alias was repointed.

@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

@xyzs996 is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. provider:gemini labels Aug 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb69359ba8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

pricing: {
units: [
{ name: 'textInput_cacheRead', rate: 0.075, strategy: 'fixed', unit: 'millionTokens' },
{ name: 'textInput_cacheRead', rate: 0.03, strategy: 'fixed', unit: 'millionTokens' },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the higher cached-audio rates

When Gemini 2.5 Flash usage contains cached audio, computeChatCost assigns those tokens to textInput_cacheRead unless the card provides a dedicated audioInput_cacheRead unit (computeChatCost.ts:186-204). Consequently this change charges cached audio at $0.03/M instead of Google's $0.10/M rate; the analogous Flash-Lite change charges $0.01/M instead of $0.03/M. Add the modality-specific units, as the Gemini 3.1 Flash-Lite card already does, and cover both corrected paths with regression assertions.

AGENTS.md reference: AGENTS.md:L124-L124

Useful? React with 👍 / 👎.

This branch has not been deployed

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

Labels

provider:gemini size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant