Skip to content

Show cost breakdown by bucket (input / output / cache read / cache write) on the dashboard#5

Open
ludwigehlert-gif wants to merge 1 commit into
JedIV:mainfrom
ludwigehlert-gif:feat/cost-breakdown-cards
Open

Show cost breakdown by bucket (input / output / cache read / cache write) on the dashboard#5
ludwigehlert-gif wants to merge 1 commit into
JedIV:mainfrom
ludwigehlert-gif:feat/cost-breakdown-cards

Conversation

@ludwigehlert-gif
Copy link
Copy Markdown
Contributor

Summary

Adds totals.cost_breakdown to /api/stats — per-bucket cost (input, output, cache_read, cache_write_5m, cache_write_1h) computed by grouping per (tool, model) so each rate from prices.json is applied correctly. The UI surfaces four new cards: cost: cache read, cost: cache write, cost: output, cost: fresh input, each annotated with its share of the total.

The motivation: looking at a single "est cost" number, it's not obvious that on long Claude Code sessions ~60% of the bill is cache reads (re-sending the conversation every turn at 10% input rate) and another ~30% is 1h cache writes — fresh input is typically a rounding error and output is ~10%. The breakdown makes this immediately visible.

Test plan

  • Reload http://127.0.0.1:8732 after restarting the server — four new cost cards appear.
  • Apply a tool/model/project filter — the four cards re-sum to match the est cost card.
  • Edit prices.json and click recompute prices — the breakdown updates accordingly.

🤖 Generated with Claude Code

Adds totals.cost_breakdown to /api/stats with per-bucket cost (input,
output, cache_read, cache_write_5m, cache_write_1h), grouped per
(tool, model) so the correct rates are applied. The UI surfaces four
new cards — cache read, cache write, output, fresh input — each with
its share of the total cost.

For Claude Code sessions this makes it obvious that cache reads
(re-sending the conversation each turn at 10% input rate) and 1h cache
writes dominate the bill, not fresh input or output.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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