Skip to content

fix(runtime): update model pricing table to current rates - #3357

Merged
Yeachan-Heo merged 2 commits into
ultraworkers:mainfrom
twtrubiks:fix/model-pricing-table
Oct 19, 2026
Merged

Yeachan-Heo merged 2 commits into
ultraworkers:mainfrom
twtrubiks:fix/model-pricing-table

Conversation

@twtrubiks

@twtrubiks twtrubiks commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

pricing_for_model (used by /cost, usage summaries, and the estimated_cost_usd telemetry/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.
  • All Opus models were priced at $15 / $75. Opus 4.5 and later are $5 / $25, and Opus 5.5 is $4 / $20.
  • Haiku 5.5, Sonnet 5 / 5.5, and Fable / Mythos had no entries.
  • DeepSeek models fell back to the default tier, so deepseek-v4-flash was 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):

Model Before After
default (default_sonnet_tier, unknown models) $15 / $75 / $18.75 / $1.50 $3 / $15 / $3.75 / $0.30
Sonnet 3.x / 4.x (sonnet alias → claude-sonnet-4-6) $15 / $75 / $18.75 / $1.50 $3 / $15 / $3.75 / $0.30
Sonnet 5 $15 / $75 / $18.75 / $1.50 $2 / $10 / $2.50 / $0.20
Sonnet 5.5 $15 / $75 / $18.75 / $1.50 $2 / $10 / $2.50 / $0.10
Opus 4 / 4.1 (still on Bedrock / Google Cloud) $15 / $75 / $18.75 / $1.50 unchanged
Opus 4.5 – 4.8, Opus 5 $15 / $75 / $18.75 / $1.50 $5 / $25 / $6.25 / $0.50
Opus 5.5 $15 / $75 / $18.75 / $1.50 $4 / $20 / $5 / $0.20
Haiku 4.5 $1 / $5 / $1.25 / $0.10 unchanged
Haiku 5.5 $1 / $5 / $1.25 / $0.10 $0.10 / $0.50 / $0.125 / $0.01
Haiku 3.5 $1 / $5 / $1.25 / $0.10 $0.80 / $4 / $1 / $0.08
Fable 5 / Mythos 5 default $10 / $50 / $12.50 / $1
Fable 5.1 / Mythos 5.1 default $10 / $50 / $12.50 / $0.25
DeepSeek deepseek-v4-pro default $1.32 / $3.96 / $1.32 / $0.044
DeepSeek deepseek-flash, deepseek-v4-flash, deepseek-chat, deepseek-reasoner default $0.30 / $1.20 / $0.30 / $0.006

To 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, Bedrock anthropic.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_tokens to cache reads, so cache hits get the cache-hit rate. deepseek-chat / deepseek-reasoner were 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

  • Classification: actionable-fix
  • Evidence: official pricing pages linked above; supports_model_specific_pricing now covers 10 model ids, plus new distinguishes_cache_read_rates_across_versions and prices_deepseek_api_models_at_peak_rates tests.
  • Non-destructive review result: merge candidate

Verification

  • cargo fmt --all --check
  • cargo test --workspace: all pass except tools::tests::powershell_runs_via_stub_shell, which fails locally only because pwsh is not installed (same on main).
  • cargo clippy --workspace: no new warnings in the touched files.
  • Targeted tests/docs checks ran, or the gap is explicitly recorded.
  • git diff --check passes.
  • No live secrets, tokens, private logs, or unrelated generated churn are included.

Compatibility and known gaps

  • Output change: estimated costs in /cost, usage summaries, and the estimated_cost_usd JSON / telemetry fields change for affected models. Field names and formats are unchanged.
  • Unknown models (e.g. OpenAI, xAI, or DashScope models) still fall back to default_sonnet_tier() and are still marked pricing=estimated-default, but the estimate drops from $15 / $75 to $3 / $15 per MTok.
  • DeepSeek ids are no longer marked 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.
  • Test expectations updated accordingly: api/src/types.rs ($54.6750 → $10.9350) and api/tests/client_integration.rs. In the latter, the fixture's token counts are scaled by 100 because the original counts round to $0.0000 at Sonnet rates.
  • Haiku 5.5 bills prompts over 100K tokens at 5x. Usage is aggregated across requests, so the estimate uses the base tier; this is noted in a code comment.
  • Cache writes use the 5-minute rate, since claw does not request the 1-hour TTL.
  • Not in scope: several CLI call sites (e.g. the status and JSON usage outputs in main.rs) call estimate_cost_usd() without a model and therefore always use the default tier. That can be a follow-up.

Resolution gate

  • If this PR resolves an issue, the issue number and fix evidence are linked. (No existing issue; evidence is in this PR.)
  • If this PR should not merge, the rejection/defer rationale is evidence-backed and does not rely on vibes.
  • I did not merge/close remote PRs or issues from an automation lane without owner approval.

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.
@XinwangTao

Copy link
Copy Markdown

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.

@XinwangTao

Copy link
Copy Markdown

这个更新很关键:之前默认费率还停留在旧 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 的基础,建议尽快合并。

@Yeachan-Heo
Yeachan-Heo merged commit 4b8c79e into ultraworkers:main Oct 19, 2026
@Yeachan-Heo Yeachan-Heo mentioned this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants