r/ClaudeCode • • Mar 28 '26

Showcase I'm a frontend dev who barely writes code anymore. Built a tool to figure out where all my AI tokens go.

Post image
8 Upvotes

14 comments sorted by

1

u/2024-YR4-Asteroid Mar 29 '26

This is off the API pricing correct?

1

u/siropkin Mar 29 '26

Claude Code: Real-time via OpenTelemetry (exact tokens + cost per API call, including thinking tokens) + hooks for session metadata. Also parses JSONL transcripts for historical backfill.

Cursor: Pulls from their usage API which returns exact tokens and cost per request. Hooks for session context (repo, branch).

Cost is calculated from per-model API pricing, not from your invoice — but when I compared against my Anthropic billing the numbers matched.

1

u/2024-YR4-Asteroid Mar 29 '26

Be careful with that, API pricing is heavily marked up. L I did a cost for per million token calculation for what Anthropic pays and found my usage for last month to have costs around $35 in compute costs on AWS inferentia 2 infrastructure.

The INF2 compute clusters that Anthropic uses run $5.19 per compute hour for public 3 year reserved pricing.

INF2 clusters can process between 7million and 18m tokens per hour depending on model. (This is a huge guess because I only have data from opensource models. But Anthropics are better optimized than opensource so it should be close)

Let’s lay out the variables:

if I used 1.5 billion tokens, or 1500 units (units of 1 million tokens) 4 million were full input and output, and the other 1446 were cached (close to my actual usage). Cached prompt recall is 90% cost reduction in compute costs

U = units of 1 million Cost per million $5.19 / 7u = $.74 $5.29 / 18u = $.28

Cached costs .74 x 10% = 0.074 .28 x 10% = 0.028

My costs 4u x .74 = $2.96 4u x .28 = $1.12

1446c x .074 = $107.00 1446c x .027 = $40.48

So between $41.60 and $109.96 to run my plan.

1

u/siropkin Mar 29 '26

Wow, that's deep! I hadn't thought about the actual compute cost side.

Just to clarify — budi tracks what you're being charged, not what it costs to run. OTEL or JSONL gives token counts, I just multiply by Anthropic's published pricing. For Cursor their usage API returns the cost directly.

I never thought to calculate the actual compute cost but that's a cool idea.

1

u/siropkin Mar 29 '26

I ran your formula against my actual usage from budi. Last month:

  • 6.49B tokens total (99.94% cache hit rate)

  • 367.5M full tokens (input + output + cache creation)

  • 6.12B cached tokens

API cost (what Anthropic charged me): ~$5,159

Your INF2 compute estimate: $274–$725

That's a 7–19x markup. Even at the high end of your compute estimate, I cost Anthropic about $725 to serve — and they charged me $5,159. The cache hit rate being 99.94% is key — almost all my tokens are cache reads, which are cheap both at API level ($0.30/1M) and compute level.

The formula I use in budi for API cost:

cost = (input × $price) + (output × $price) + (cache_read × $price) + (cache_create × $price)

with per-model pricing tables.

Do you think I need to add this info to the app lol

→ More replies (1)
→ More replies (4)

1

u/Ok_Mathematician6075 Mar 29 '26

OpenTelemetry sent to M365 logs?

1

u/siropkin Mar 29 '26

No, everything stays local. Claude Code sends OTEL events to budi's daemon on localhost:7878 - nothing leaves your machine. No cloud, no M365, no external services.

1

u/Ok_Mathematician6075 Mar 29 '26

Ha! Nothing leaves your machine. Like that's comforting. As a security bitch, I'm turning off Claude Cowork at the Enterprise level until we get the OpenTelemetry events logged - prob more than that.

1

u/siropkin Mar 29 '26

Totally fair. If OTEL is locked down at your org level, budi still works — it falls back to parsing Claude Code's JSONL transcripts for token data. You lose thinking token counts (so cost is ~5-8% underestimated) but everything else works the same. And it's all local, just reads files from disk.