Repository navigation
fix(runtime): update model pricing table to current rates - #3357
Merged
Yeachan-Heo merged 2 commits intoOct 19, 2026
Merged
Conversation
Align pricing_for_model with the published Anthropic pricing table: - default_sonnet_tier was $15/$75 (the old Opus rate); it is now the Sonnet 4.x rate of $3/$15, which is what the `sonnet` alias resolves to. - Add Sonnet 5 / 5.5, Haiku 5.5, Haiku 3.5, and Fable / Mythos rates. - Opus 4.5+ is $5/$25 and Opus 5.5 is $4/$20; Opus 4/4.1 keep the $15/$75 tier they are still billed at on Bedrock and Google Cloud. Versions are parsed from the model id so dated, provider-prefixed, and Vertex-style ids resolve to the right tier. Haiku 5.5's >100K-token tier is not modeled because usage is aggregated across requests.
DeepSeek models fell back to default_sonnet_tier ($3/$15 per MTok), overestimating V4 Flash by about 10x on input and 12x on output. Price the ids served by the DeepSeek API at peak rates: deepseek-v4-pro at $1.32/$3.96, and deepseek-flash, deepseek-v4-flash and the retired deepseek-chat / deepseek-reasoner aliases at $0.30/$1.20. Off-peak usage is billed at half. Other DeepSeek models on third-party hosts keep the default because their prices vary by host.
6 tasks done
|
Important correction — the stale default tier ($15/$75, old Opus 4 rate) meant every Sonnet and unknown model was overestimated ~5x, and DeepSeek fell back to roughly 10-12x its real price. Updating to current published rates plus the DeepSeek entries makes /cost and the estimated_cost_usd telemetry trustworthy again. The per-model table is easy to audit. |
|
这个更新很关键:之前默认费率还停留在旧 Opus 4 价($15/$75),导致所有 Sonnet 及未知回退模型的成本被高估约 5 倍,DeepSeek 更是高估约 10 倍。更新后 /cost 与用量统计的预估会准确很多。family_version() 对日期版本(claude-opus-4-1-20250805)、Bedrock/Vertex id 的解析处理很周到,不会把日期误当成 minor 版本。DeepSeek 按 peak 费率作为上界估算、并注明 off-peak 半价也很透明。作为 #3358 的基础,建议尽快合并。 |
Merged
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
pricing_for_model(used by/cost, usage summaries, and theestimated_cost_usdtelemetry/JSON fields) was out of date with the published Anthropic pricing, and had no entries for DeepSeek:ModelPricing::default_sonnet_tier()was $15 / $75 per MTok, which is the old Opus 4 rate. Every Sonnet model, and every unknown model that falls back to the default, was estimated at 5x the Sonnet price.deepseek-v4-flashwas estimated at roughly 10x its input price and 12x its output price.This PR updates the table (input / output / 5m cache write / cache read, per MTok):
default_sonnet_tier, unknown models)sonnetalias →claude-sonnet-4-6)deepseek-v4-prodeepseek-flash,deepseek-v4-flash,deepseek-chat,deepseek-reasonerTo tell these tiers apart, a small
family_version()helper parses(major, minor)from the model id. It handles dated ids (claude-opus-4-1-20250805), provider prefixes (anthropic/claude-sonnet-5-5, Bedrockanthropic.claude-opus-4-20250514-v1:0) and Vertex ids (claude-opus-4@20250514) without mistaking the date for a minor version. Ids without a parseable version fall back to the tier the bare alias resolves to.DeepSeek rates come from the DeepSeek API pricing page at peak rates, so the estimate is an upper bound; off-peak usage is billed at half. DeepSeek has no cache-write charge, so the cache-write column equals the input (cache miss) price. The OpenAI-compatible provider already maps DeepSeek's
prompt_tokens_details.cached_tokensto cache reads, so cache hits get the cache-hit rate.deepseek-chat/deepseek-reasonerwere retired on 2026-07-24 and were served by V4 Flash; they are priced as Flash so old sessions still get a sensible estimate. Only the ids served by the DeepSeek API are matched. Other DeepSeek models on third-party hosts (e.g.deepseek-r1) keep the default, because their prices vary by host.Anti-slop triage
supports_model_specific_pricingnow covers 10 model ids, plus newdistinguishes_cache_read_rates_across_versionsandprices_deepseek_api_models_at_peak_ratestests.Verification
cargo fmt --all --checkcargo test --workspace: all pass excepttools::tests::powershell_runs_via_stub_shell, which fails locally only becausepwshis not installed (same onmain).cargo clippy --workspace: no new warnings in the touched files.git diff --checkpasses.Compatibility and known gaps
/cost, usage summaries, and theestimated_cost_usdJSON / telemetry fields change for affected models. Field names and formats are unchanged.default_sonnet_tier()and are still markedpricing=estimated-default, but the estimate drops from $15 / $75 to $3 / $15 per MTok.pricing=estimated-default. I don't have a DeepSeek key, so the pricing was checked against the official docs and unit tests rather than a live bill.api/src/types.rs($54.6750→$10.9350) andapi/tests/client_integration.rs. In the latter, the fixture's token counts are scaled by 100 because the original counts round to$0.0000at Sonnet rates.main.rs) callestimate_cost_usd()without a model and therefore always use the default tier. That can be a follow-up.Resolution gate