Llm usage normalizer
@agentcosts/llm-usage-normalizer
Convert Anthropic and OpenAI usage exports, or your own app's token logs, into one usage schema with customers, tasks, cached and uncached tokens, and cost from a price table you edit. Fixes the classic mistake of counting cached tokens twice, and lists unmapped keys and unpriced models.
- Activity
- New: be the first to try it
- Installs
- 0 installs
- Likes
- 0 likes
- Clones
- 0 clones
- 1# LLM usage normalizer
- 3Converts Anthropic and OpenAI usage exports, or your own app's token logs, into one usage CSV with customer, task, cached and uncached tokens, and cost. It handles the cached-token difference between providers, maps API keys or projects to customers, and tells you what it could not map or price.
- 5**Who it is for:** engineers and finance folks at AI products who need one clean usage file before they can talk about cost per customer or margins.
- 7## Example
- 9Input: `examples/anthropic-usage.csv` (daily rows per model and key), `examples/openai-usage.csv` (daily rows per model and project), `examples/customer-map.csv`, `examples/prices.csv`.
- 11Output (`out/usage-normalized-report.md`):
- 13```
- 14| examples/anthropic-usage.csv | anthropic | 8 | $7.65 | api_key_id | uncached_input_tokens |
- 15| examples/openai-usage.csv | openai | 4 | $3.93 | api_key_id | input_tokens |
- 16Total $11.59 across 12 rows.
- 17Keys with no customer: key-staging (1 row)
- 18```
- 20And `out/usage-normalized.csv` in the shared schema used by every Agent Costs kit.
- 22## What it can access
- 24- Runs `node scripts/normalize.mjs` (Node built-ins only).
- 25- Reads exports in `data/`. Writes `data/llm-prices.csv`, `data/customer-map.csv`, and `out/usage-normalized*`.
- 26- No network, no API keys. It never calls a provider.
- 28## Setup
- 30Copy `examples/prices.csv` to `data/llm-prices.csv` and **check every price against the provider's current pricing page** (the example prices are a starting point, not a quote). Then export usage from each provider's console into `data/`.
