Repository navigation
fix(usage): price a model newer than the table from its nearest known version - #309
Merged
Merged
Conversation
… version getModelPricing fell from the LiteLLM table straight to a static prefix list (opus, sonnet, haiku) and then to DEFAULT_PRICING at 3 / 15 USD per million tokens. A model released after the table was last refreshed was therefore costed at Sonnet-class rates with only a log line. Real case: claude-fable-5-2 was missing while claude-fable-5 and -5-1 were listed at 10 / 50, so its cost and any budget alert were under-counted by more than three times. - Add a nearest-sibling step between the exact lookup and the prefix list. The family is found by dropping trailing segments one at a time, never below two, and the newest listed version in that family wins. A release date never makes an older version look newer, a dated or suffixed id for a listed model resolves to that model, and only bare keys are considered so a provider's markup is never borrowed. - Price Claude Code's zero-token <synthetic> records (and an empty id) at zero without logging "Unknown model" on every run. - Export getModelPricingSource so a later change can label approximate prices. Not wired into any UI here. No price numbers are added or changed. Tests: new model-pricing.test.ts, 10 cases, loading fixture tables through loadPrices. Checked against this machine's cached table: claude-fable-5-2 now resolves to 10 / 50 via claude-fable-5-1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The sibling price lookup logs at info level; this mock only had warn, so a model resolved through a sibling threw inside the test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
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.



Summary
Review item 5.5 (
docs/REVIEW_2026-11-09.md).getModelPricingwent from the LiteLLM table to a static prefix list (opus, sonnet, haiku) and then toDEFAULT_PRICINGat 3 / 15 USD per million tokens. A model released after the table was last refreshed was costed at Sonnet-class rates with only a log line.claude-fable-5-2was the live case: the table listsclaude-fable-5andclaude-fable-5-1at 10 / 50, so its cost and any budget alert were under-counted by more than three times.claude-fable-5-2can borrow fromclaude-fable-5-1and never from another family. A release date never makes an older version look newer. A dated or suffixed id for a listed model resolves to that model. Only bare keys are considered, so a provider's markup is never borrowed.<synthetic>records, and an empty id, are priced at zero and no longer log "Unknown model" on every run.getModelPricingSourcereportstable,sibling,prefix,defaultornone, so a later change can label approximate prices. It is not wired into any UI here.usage-quota.mdsays new models can be approximate until the table refreshes.No price numbers are added or changed.
Test plan
npx tsc --noEmitnpx eslinton the module and its testnpx vitest run src/main/usage(newmodel-pricing.test.ts, 10 cases)claude-fable-5-2is priced at 10 / 50 viaclaude-fable-5-1; listed models are unchangedOut of scope
siblinganddefaultprices.gpt-5.7-terra): there is no two-segment family to match, so they still use the default.🤖 Generated with Claude Code