Repository navigation
feat(runtime): add OpenAI, xAI, and DashScope pricing - #3358
Conversation
|
This fills a real gap — without entries in pricing_for_model, OpenAI/xAI/DashScope models fell back to the default tier and produced badly skewed estimates (gpt-5.4-nano at 15x, qwen-plus at ~26x input price). The strict matching (no o1→o1-mini, no qwen-plus→qwen-plus-character) and the dated-snapshot/-latest alias handling are the right details. Consistent with #3357's approach on long-context tiers. |
Models from the OpenAI-compatible providers fell back to default_sonnet_tier ($3/$15 per MTok), so e.g. gpt-5.4-nano was estimated at 15x its input price and qwen-plus at about 26x. Add a table of published rates keyed by model id, matching dated snapshots and -latest aliases: - OpenAI standard tier for current gpt-6 / gpt-5.x / gpt-4.1 / gpt-4o and o-series models (Responses-only pro models are omitted). - xAI grok-4.x and grok-build. Slugs retired on 2026-05-15 (grok-3, grok-4-0709, grok-4-fast-*, grok-4-1-fast-*) are billed at grok-4.3 rates, and grok-code-fast-* is served as grok-build. - DashScope qwen-max, qwen-plus, qwen-flash and kimi-k2.5 at China (Beijing) rates, which is claw's default DashScope endpoint, with non-thinking output and the 20% implicit-cache hit rate. Long-context and higher input tiers use the base rate because usage is aggregated across requests.
7a287d2 to
14d6c84
Compare
|
补充这些模型定价很及时:之前 default tier 沿用旧 Opus 4 的 $15/$75,Sonnet 会被高估 5 倍,DeepSeek 系列因为没有独立条目更是直接落到默认档、估算偏差 10 倍以上,直接影响 /cost 和 estimated_cost_usd。补齐 OpenAI、xAI、DashScope 和 DeepSeek 后成本统计才可靠,family_version() 用版本号区分 tier 的思路也清楚。 |
1 similar comment
|
补充这些模型定价很及时:之前 default tier 沿用旧 Opus 4 的 $15/$75,Sonnet 会被高估 5 倍,DeepSeek 系列因为没有独立条目更是直接落到默认档、估算偏差 10 倍以上,直接影响 /cost 和 estimated_cost_usd。补齐 OpenAI、xAI、DashScope 和 DeepSeek 后成本统计才可靠,family_version() 用版本号区分 tier 的思路也清楚。 |
Summary
Models from the OpenAI-compatible providers (OpenAI, xAI, DashScope) have no entry in
pricing_for_model, so they fall back todefault_sonnet_tier()($3 / $15 per MTok after #3357) and are markedpricing=estimated-default. For many of them that is far off. For example,gpt-5.4-nanois estimated at 15x its input price, andqwen-plusat about 26x.This adds a table of published rates (input / output / cache write / cache read per MTok), keyed by model id. An id also matches its dated snapshots and
-latestalias (gpt-4.1-2025-04-14,qwen-plus-latest), and provider prefixes such asopenai/andqwen/are stripped. Matching is strict, soo1does not matcho1-miniandqwen-plusdoes not matchqwen-plus-character.gpt-6-*,gpt-6.1-sol,gpt-5.6-*,gpt-5.5,gpt-5.4(+ mini/nano),gpt-5.2,gpt-5.1,gpt-5(+ mini/nano),gpt-4.1(+ mini/nano),gpt-4o(+ mini, + the2024-05-13snapshot),o1,o3,o3-mini,o4-minigrok-4.7,grok-4.6,grok-4.5,grok-4.3,grok-4.20*,grok-build,grok-code-fast*; retiredgrok-3,grok-4/grok-4-0709,grok-4-fast-*,grok-4-1-fast-*qwen-max,qwen-plus,qwen-flash,kimi-k2.5Pricing choices:
gpt-4o-2024-05-13) use the input rate for cache reads. The OpenAI-compatible client already mapsprompt_tokens_details.cached_tokensto cache reads.grok-code-fast-*is an alias ofgrok-build-0.1.DASHSCOPE_BASE_URLis the Beijing endpoint. Users of the international (Singapore) endpoint pay roughly 3–4x more. Output uses the non-thinking rate because claw does not enable Qwen thinking mode. Cache hits use the 20% implicit-cache rate.Anti-slop triage
prices_openai_compatible_provider_modelstest covering snapshots, prefixes, retired xAI slugs, and ids that must stay unpriced.Verification
cargo fmt --all --checkcargo test -p runtime --lib usage,cargo test -p api: passcargo clippy -p runtime --all-targets: no new warnings in the touched file.git diff --checkpasses.Compatibility and known gaps
/cost, usage summaries, and theestimated_cost_usdJSON / telemetry fields now show provider rates instead of the default, and drop thepricing=estimated-defaultmarker. Field names and formats are unchanged.*-promodels, which claw's Chat Completions client cannot call.o1-mini,grok-3-mini,grok-2,qwen-turbo,qwq-plus,qwen3-max,qwen3-coder-plus.qwen3.x-*, datedkimi-*), Groq, and local models.Resolution gate