Skip to content

fix(server): stop overpricing cached Claude tokens - #244

Merged
leoisadev1 merged 4 commits into
mainfrom
fix/claude-cached-token-pricing
Sep 11, 2026
Merged

fix(server): stop overpricing cached Claude tokens#244
leoisadev1 merged 4 commits into
mainfrom
fix/claude-cached-token-pricing

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Problem

The Usage page can overprice cached Claude tokens when LiteLLM publishes canonical and provider-qualified entries with the same bare model name. The parser stripped provider prefixes before inserting rates, so a later entry without the Anthropic cache discount could overwrite the canonical rate and price cache reads as ordinary input.

Fix

Preserve each LiteLLM rate under its full normalized key. Keep canonical bare entries authoritative. Add a bare alias only when every qualified entry has the same effective rate. Leave genuinely conflicting bare names unpriced.

This is an Akeru adaptation of upstream T3 Code work.

Upstream

Verification

  • vp test run apps/server/src/usage/usagePricing.test.ts apps/server/src/usage/usageScanCache.test.ts apps/server/src/usage/usageAggregation.test.ts — 30 passed
  • Targeted lint on the four changed files — clean

No UI change. Usage page numbers follow the corrected table.

Model

Grok 4.6 High in Grok Build via Orca.

LiteLLM publishes canonical and provider-qualified rates for the same
bare model name. Stripping prefixes before insert let a later entry
overwrite the Anthropic cache discount and price cache reads as ordinary
input.

Keep each rate under its full key. Alias a bare name only when every
qualified entry has the same effective rate.

Upstream: pingdotgg#8806

Grok 4.6 High in Grok Build via Orca.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
akeru-bot-landing Skipped Skipped Sep 10, 2026 6:20pm UTC

Request Review

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

Summary

  • Restores pricing for provider-qualified transcript model names by falling back to a canonical bare-model rate when no exact provider-specific rate exists.
  • Preserves exact provider-qualified rates when they are available.

No new actionable issues were identified.

Confidence Score: 5/5

Safe to merge.

The earlier pricing issue is no longer outstanding: the lookup now prefers an exact provider-qualified rate and falls back to the bare canonical model name. greptile-apps[bot] resolved the earlier thread without explanation.

Reviews (4): Last reviewed commit: "Merge branch 'main' into fix/claude-cach..." | Re-trigger Greptile

Comment thread apps/server/src/usage/usagePricing.ts Outdated
Exact-key lookup left transcripts such as anthropic/claude-fable-5
unpriced when LiteLLM only published the bare canonical rate.

Keep provider-qualified rates when they exist, and use the bare
canonical rate only when the exact key is missing.

Grok 4.6 High in Grok Build via Orca.
@leoisadev1
leoisadev1 merged commit 9b60ed6 into main Sep 11, 2026
11 checks passed
@leoisadev1
leoisadev1 deleted the fix/claude-cached-token-pricing branch September 11, 2026 06:50
@github-actions github-actions Bot mentioned this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant