Skip to content

Estimated cost + richer token metrics in the UI#8

Merged
lroolle merged 1 commit into
mainfrom
feat/pricing-cost
Jul 12, 2026
Merged

Estimated cost + richer token metrics in the UI#8
lroolle merged 1 commit into
mainfrom
feat/pricing-cost

Conversation

@lroolle

@lroolle lroolle commented Jul 12, 2026

Copy link
Copy Markdown
Member

What

  • src/pricing.ts (new, inlined into the page like summarize.ts): embedded Claude sticker-price table + pairCost() estimation. Handles date suffixes, bedrock anthropic. prefixes, vertex @-versions, [1m] markers, and the reversed 3.x id order (claude-3-opus-...). Unknown models show no cost instead of a wrong one.
  • Cache pricing uses Anthropic's universal multipliers: read 0.1x input, write 1.25x (5m TTL) / 2x (1h TTL). The 5m/1h split comes from the wire's cache_creation breakdown; without one, writes bill at the cheaper 5m rate (same policy as ccusage — cloned into reference/ccusage for future reference, gitignored).
  • UI: cost chip per request row; detail panel gains cost (component-breakdown tooltip), effective prompt size, and output tok/s; Session view shows per-turn cost, per-thread cost in the sidebar meta and conversation chips.

Verification

  • 161/161 tests (13 new in tests/pricing.test.ts)
  • Smoke against a real captured trace: page script parses; Fable 5 pairs price correctly including the 1h cache-write TTL ($1.01 for a 43.3k-token 1h write + 14.1k input)

🤖 Generated with Claude Code

Every /v1/messages pair now shows an estimated USD cost: a chip in the
Requests list, a breakdown tooltip in the detail panel, and per-turn /
per-thread totals in the Session view. src/pricing.ts embeds the sticker
prices (snapshots stay offline-capable) and derives cache rates from the
universal multipliers (0.1x read, 1.25x 5m write, 2x 1h write); writes
without a TTL breakdown bill at the cheaper 5m rate, matching ccusage.
The detail panel also gains effective prompt size and output tok/s.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lroolle lroolle merged commit 7882488 into main Jul 12, 2026
1 check passed
@lroolle lroolle deleted the feat/pricing-cost branch July 12, 2026 05:04
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