Skip to content

feat(usage): price Claude 5 family and GPT-5.6 token usage - #10822

Merged
brennanb2025 merged 3 commits into
mainfrom
brennan/sta-2684-update-token-usage-tracking-to-include-new-models
Jul 27, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennan/sta-2684-update-token-usage-tracking-to-include-new-models

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

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, so estimateCostUsd returned null and 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 — added claude-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 — added gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna with their long-context tiers, plus normalization (reasoning suffixes like -xhigh / (medium) already strip before lookup).

Rates from Anthropic pricing and OpenAI pricing.

Model Input Output Cache read Cache write
claude-fable-5 $10 $50 $1 $12.50
claude-opus-5 $5 $25 $0.50 $6.25
claude-sonnet-5 $3 $15 $0.30 $3.75
Model Input Cached input Output (long ctx >272k)
gpt-5.6-sol $5 $0.50 $30 $10 / $1 / $45
gpt-5.6-terra $2.50 $0.25 $15 $5 / $0.50 / $22.50
gpt-5.6-luna $1 $0.10 $6 $2 / $0.20 / $9

Two judgement calls worth reviewing

  1. Sonnet 5 gets no long-context tier. Sonnet 4/4.5/4.6 carry a >200k premium in our table, but Anthropic's pricing page now states Claude 4.6 and later bill the full 1M window at standard rates. So Sonnet 5 is flat.
  2. Sonnet 5 uses the standard $3/$15, not the $2/$10 introductory rate in effect through 2026-08-31. The pricing table has no date dimension, and standard is the durable value — this slightly overstates Sonnet 5 cost until Sept 1.

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)/1e6 exactly
  • claude-sonnet-5 → $29.4146736, exact
  • gpt-5.6-luna → $1.2864912, exact (gpt-5.6-sol differs from a whole-total calc by $0.01 because cost is summed per daily row, so each row tiers independently — pre-existing behavior)

orca-2684-models.png

orca-2684-codex-models.png

Not in scope

  • claude-sonnet-4-6 may 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.
  • The "Unknown model — inferred pricing" row in the Codex screenshot is pre-existing (sessions with no model recorded), unrelated to this change.

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

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ebda447b-16ff-4575-97dd-b5a9761933a1

📥 Commits

Reviewing files that changed from the base of the PR and between 3e7eac7 and a3aebe9.

📒 Files selected for processing (1)
  • src/main/claude-usage/store.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/claude-usage/store.ts

📝 Walkthrough

Walkthrough

Updated 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is informative, but it misses several required template sections, especially Testing, AI Review Report, Security Audit, and Notes. Reformat the PR description to match the template and add the missing Testing checklist, AI Review Report, Security Audit, and Notes sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main pricing change for Claude 5 and GPT-5.6 usage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 29c40e3 and b4f0cde.

📒 Files selected for processing (4)
  • src/main/claude-usage/store.test.ts
  • src/main/claude-usage/store.ts
  • src/main/codex-usage/store.test.ts
  • src/main/codex-usage/store.ts

Comment thread src/main/claude-usage/store.test.ts Resolved
Comment thread src/main/codex-usage/store.ts Resolved
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.
@brennanb2025
brennanb2025 merged commit cf513ad into main Jul 27, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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
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.

1 participant