Repository navigation
feat(usage): price Claude 5 family and GPT-5.6 token usage - #10822
brennanb2025 merged 3 commits into
Conversation
Claude Opus 5, Sonnet 5, Fable 5 and Codex gpt-5.6 sol/terra/luna were absent from the usage pricing tables, so their turns aggregated tokens but reported no estimated cost. Rates from Anthropic and OpenAI published pricing. Sonnet 5 gets no long-context tier: Claude 4.6 and later bill the full 1M window flat. Sonnet 5 uses the standard $3/$15 rate, not the $2/$10 introductory rate that runs through 2026-08-31 — the table has no date dimension.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated Claude usage pricing and normalization for Fable 5, Opus 5, and Sonnet 5, including flat-rate Sonnet 5 long-context billing. Added Codex pricing and normalization for GPT-5.6 Sol, Terra, and Luna variants, including reasoning suffixes and long-context rates. Added tests covering aggregate costs, per-model breakdowns, and separation from older model pricing. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 76b02a11-8ad3-4590-98b6-02e281f4fa3c
📒 Files selected for processing (4)
src/main/claude-usage/store.test.tssrc/main/claude-usage/store.tssrc/main/codex-usage/store.test.tssrc/main/codex-usage/store.ts
OpenAI routes the bare `gpt-5.6` alias to Sol, but only the explicit `-sol` / `-terra` / `-luna` IDs resolved, so alias-recorded sessions still reported no cost. Match it exactly rather than by prefix so it cannot swallow the tier IDs or a future cheaper variant. Also split the Claude 5 shadowing guard into per-model breakdown assertions and add the missing Opus 4.5 fixture the test name claimed.
…10822) * feat(usage): price Claude 5 family and GPT-5.6 token usage Claude Opus 5, Sonnet 5, Fable 5 and Codex gpt-5.6 sol/terra/luna were absent from the usage pricing tables, so their turns aggregated tokens but reported no estimated cost. Rates from Anthropic and OpenAI published pricing. Sonnet 5 gets no long-context tier: Claude 4.6 and later bill the full 1M window flat. Sonnet 5 uses the standard $3/$15 rate, not the $2/$10 introductory rate that runs through 2026-08-31 — the table has no date dimension. * fix(usage): price the bare gpt-5.6 alias and assert Opus 4.5 separately OpenAI routes the bare `gpt-5.6` alias to Sol, but only the explicit `-sol` / `-terra` / `-luna` IDs resolved, so alias-recorded sessions still reported no cost. Match it exactly rather than by prefix so it cannot swallow the tier IDs or a future cheaper variant. Also split the Claude 5 shadowing guard into per-model breakdown assertions and add the missing Opus 4.5 fixture the test name claimed. * docs(usage): note Sonnet 5 uses standard, not introductory, rates
Closes STA-2684.
Problem
Usage analytics scanned turns for Claude Opus 5 / Sonnet 5 / Fable 5 and Codex
gpt-5.6-*, aggregated their tokens, and then reported no cost for them — those model IDs were missing from both pricing tables, soestimateCostUsdreturnednulland the spend silently vanished from the totals.On my own machine that was ~$14.5k of Claude and ~$30.5k of Codex API-equivalent spend not showing up.
Change
src/main/claude-usage/store.ts— addedclaude-opus-5,claude-sonnet-5,claude-fable-5, plus family matchers ahead of the existing Opus 4 / Sonnet 4 branches.src/main/codex-usage/store.ts— addedgpt-5.6-sol,gpt-5.6-terra,gpt-5.6-lunawith their long-context tiers, plus normalization (reasoning suffixes like-xhigh/(medium)already strip before lookup).Rates from Anthropic pricing and OpenAI pricing.
claude-fable-5claude-opus-5claude-sonnet-5gpt-5.6-solgpt-5.6-terragpt-5.6-lunaTwo judgement calls worth reviewing
Verification
Unit tests (
pnpm vitest run src/main/claude-usage/store.test.ts src/main/codex-usage/store.test.ts) — 25 pass, including a guard that Sonnet 4.5 still gets tiered pricing while Sonnet 5 does not.Live in the app against real on-disk logs (dev build, isolated profile, both providers enabled through the settings UI). Arithmetic checked exactly against the rendered totals:
claude-opus-5→ $2809.165289, matches(99618×5 + 14699089×25 + 3181270073×0.5 + 136088790×6.25)/1e6exactlyclaude-sonnet-5→ $29.4146736, exactgpt-5.6-luna→ $1.2864912, exact (gpt-5.6-soldiffers from a whole-total calc by $0.01 because cost is summed per daily row, so each row tiers independently — pre-existing behavior)Not in scope
claude-sonnet-4-6may now be mispriced above 200k. Its long-context tier predates the flat-rate 1M policy, so we likely overcharge Sonnet 4.6 usage past 200k tokens. Left alone to keep this PR on one thing — happy to file a follow-up.claude-mythos-5(Project Glasswing, invitation-only) is not in the model picker, so it's not added.