Measure
Token cost
You might say: run spend, model cost, usage cost
The money spent by one run on model input, model output, cached tokens, and related calls. It is attributed to a run, task, repository, or team.
- What it does
- Shows whether a task's value justifies its model usage and reveals runaway retries or oversized context.
- Ask
- What did this run spend, and which model call or retry caused the bill?
- Typical
- Report input and output tokens separately, then apply the provider's current rates. Aggregate by run, task, model, repository, and team.
- Trouble
- A run has tokens but no price, retries inflate spend, cost is assigned to the wrong task, or prompt content is logged to measure usage.
What to look for
- Input, output, and cached token counts beside a model call
- A currency total attached to a run or task
- A spend header, budget meter, or cost report
Connections
- Measured by: Agent trace
- See also: Run log
Sources
- Anthropic, Monitoring, Span attributes
`input_tokens` | Input token count from the API usage block.
- OpenTelemetry, Semantic Conventions for GenAI agent and framework spans, Invoke agent client span attributes
The number of tokens used in the GenAI input (prompt).
- OpenTelemetry, Semantic Conventions for GenAI agent and framework spans, Invoke agent client span attributes
The number of tokens used in the GenAI response (completion).
- LiteLLM, Spend Tracking, How to Track Spend with LiteLLM
Expect to see `x-litellm-response-cost` in the response headers with calculated cost
- LiteLLM, Spend Tracking, How to Track Spend with LiteLLM
LiteLLM automatically tracks spend for all known models.
- Matt Pocock, AI Coding Dictionary, Token
Tokens are the unit everything else is measured in. Cost is per token — providers bill input tokens and output tokens separately.
- Matt Pocock, AI Coding Dictionary, Input tokens
Tokens the harness sends on each model provider request — the system prompt, the conversation history, tool results, everything the model reads before it writes. Billed at a lower rate than output tokens, because they are less expensive to process than output tokens.
- Matt Pocock, AI Coding Dictionary, Output tokens
Tokens the model generates back. Billed at a higher rate than input tokens — commonly around five times the rate — since they cost more compute to produce.
- Matt Pocock, AI Coding Dictionary, Cache tokens
When consecutive requests share a prefix, the provider reuses the work via its prefix cache and bills the cached portion at a much lower rate.
- Matt Pocock, AI Coding Dictionary, Prefix cache
The provider-side store that lets consecutive model provider requests skip re-processing a shared prefix.
Use it on your project
teardown-apply: hold "Token cost" (token-cost) from the teardown at https://teardownatlas.com/software-factory/ against my project
Paste it into a coding agent that has the teardown skills.
An AI agent wrote this map with the teardown skill. It can contain errors: check the sources before you rely on a part. About and legal