ai-bill-to-focus

ai-bill-to-focus

●4
calendar_today ago â€Ē schedule2 min read

If your cloud costs already land in a FOCUS dataset, AI provider bills are the gap. AWS, Azure and Google Cloud export the FinOps Foundation's FOCUS format. Anthropic and OpenAI give you their own CSVs, and those don't map cleanly. ai-bill-to-focus is a free MIT CLI that converts them to FOCUS 1.4 and checks any CSV against the FOCUS rules. It runs on your machine, so your bill is never uploaded.

npx ai-bill-to-focus convert cost.csv usage.csv -o focus.csv
npx ai-bill-to-focus check focus.csv

(cost.csv and usage.csv stand for your own Cost and Usage exports from the Claude Console.)

Why I built it: the cached-token trap

Anthropic bills input tokens in four buckets, each at a different price:

Token type Price relative to base input
Uncached input 1x
Cache read 0.1x
Cache write, 5 minutes 1.25x
Cache write, 1 hour 2x

OpenAI counts cached tokens inside prompt tokens instead. Map both exports to a single "input tokens" column and you either lose Anthropic's cache writes or count OpenAI's cached input twice.

How it works

The converter writes one row per day, model and meter, each with its own SkuId, ListUnitPrice and ConsumedQuantity, the way a cloud bill itemises meters. One real day from my own October Anthropic export (prices per million tokens):

SkuMeter ConsumedQuantity ListUnitPrice BilledCost
Input Tokens (Sonnet 4.5) 52 3.00 0.000156
Cache Read Input Tokens 5,775 0.30 0.0017325
Cache Write Input Tokens (5 min) 1,925 3.75 0.00721875
Output Tokens 16 15.00 0.00024

52 uncached input tokens, but 7,700 went through the cache. An input-only mapping would have missed most of that day's input cost.

The rows have to add up to the provider's own figure. If a computed price doesn't round to the cost in the export, the converter uses the provider's number and records that it did. For the whole month: 41 rows, $1.06 FOCUS BilledCost against $1.06 on Anthropic's cost export.

Key features

  • Converts Anthropic, OpenAI and Together AI exports to FOCUS 1.4 CSV
  • check validates any FOCUS 1.2, 1.3 or 1.4 CSV locally, not only files it made
  • Detects the provider and file role from the headers, so file order doesn't matter
  • Flags changed export columns instead of converting silently
  • report prints a summary with no dollar amounts or account names, safe to paste into a public issue
  • Same converter and checker in the browser, file stays on your machine: https://www.cognocient.com/tools/focus-checker
  • Node 18+, tested in CI on Ubuntu and Windows

What's tested and what isn't

  • Anthropic: tested on real Console exports, totals match to the cent.
  • OpenAI and Together AI: built from their documented formats, not yet run on a real file.

How to get involved

The most useful contribution right now is a real OpenAI or Together AI export. You don't have to share the bill itself:

npx ai-bill-to-focus report <your-cost-export.csv> <your-usage-export.csv>

Paste the output into a GitHub issue. Issues and PRs for other providers' exports are welcome too.

Repo: https://github.com/mandarvshinde/ai-bill-to-focus

I build Cognocient AI, which tracks AI spend per feature, team and customer. This CLI is standalone and needs no account.

ðŸ”Ĩ Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Meet kalbee: State Estimation Without the Boilerplate

Vincente - Jul 18

The Sovereign Vault — A Comprehensive Guide to Protocol-Driven AI

Ken W. Algerverified - Jun 4

How to Reduce Your AWS Bill by 50%

rogo032 - Jan 27

10 Proven Ways to Cut Your AWS Bill

rogo032 - Jan 16

CRAFTER Focus: How to protect your hours of Deep Work every day (Part 3)

HawkN113 - Oct 17
chevron_left
126 Points â€Ē 4 Badges
1Posts
0Comments
Building in public, developer, product manager,technical writer, mostly API docs and developer-facing content.

Related Jobs

View all jobs →

Commenters (This Week)

3 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!