Cost and Token Management
Official scope (Exam Guide v1.0): token usage tracking, cost modelling, caching (prompt caching, cache check-pointing).
The cost formula (verified pricing structure)
Cost = input tokens × input price + output tokens × output price, summed over calls. Output costs about 5x input per token on current models (for example Claude Opus 5.5: $4 input / $20 output per million). Thinking is billed as output.
Input is everything you resend: system prompt, full history, tool definitions (plus a tool-use system prompt of a few hundred tokens), tool results, images, documents. Per-turn cost rises through a conversation because history grows.
Tracking usage
- Every response:
usage.input_tokens,output_tokens,cache_creation_input_tokens,cache_read_input_tokens(total input = the three input fields summed), plusspeedand thinking-token detail. - Console Usage and Cost pages; Export gives CSV by API key and model.
- Usage and Cost Admin API (needs an Admin API key or another admin credential, not a workspace key): usage by model, workspace, API key, service tier, speed, in
1m/1h/1dbuckets; cost in USD, daily. Data usually appears within 5 minutes. - Claude Code per-user costs: the Claude Code Analytics API.
Levers, in a sensible order (design guidance, verified facts)
- Measure a baseline (cost and quality).
- Send less: trim history, shorten the system prompt, return only high-signal tool results, compact or clear old turns.
- Cache the stable prefix (below).
- Right-size the model: route easy work to a smaller tier; check quality on evals.
- Batch what can wait: 50% off.
- Cap output: ask for brevity, set
max_tokenssensibly (too low truncates), use a lower effort.
Never optimise without before/after numbers on cost and quality.
Prompt caching and check-pointing
- Explicit breakpoints:
cache_controlon up to 4 blocks at stable points (end of tools, end of system, end of a long document). - Automatic caching: one top-level
cache_control; the breakpoint moves forward as the conversation grows (uses one of the 4 slots). - Lookback: 20 blocks per breakpoint; place breakpoints so a hit is found.
- Writes cost 1.25x (5-minute TTL) or 2x (1-hour TTL) base input; reads 0.1x by default (0.05x on Opus 5.5 and Sonnet 5.5, 0.025x on Fable 5.1). Break-even depends on how many reads follow each write.
- Minimum prefix 512 tokens on current models; below it, silently uncached. Exact-prefix match required; tool,
tool_choice, image, thinking, effort or speed changes invalidate part or all of it. - Caching also raises throughput: on most models cache reads do not count toward ITPM.
Cost modelling (design guidance)
Monthly cost ≈ requests × (uncached input × price + cache writes × write price + cache reads × read price + output × output price), with the batch share at 50%. Inputs: request volume, average input and output tokens, cache hit rate, batch share, fast-mode share.
Exam traps
- Ignoring output price (it dominates for long answers and thinking).
- Caching enabled but nothing cached (below minimum, prefix changes each call, timestamp before the breakpoint).
- Reading only
input_tokensand missing cached tokens. - Downsizing the model with no quality check.
- Workspace key on the Usage and Cost API.
References
- Prompt caching — checked Oct 16, 2026
- Usage and Cost API — checked Oct 16, 2026
- Rate limits — checked Oct 16, 2026
- Models overview (pricing) — checked Oct 16, 2026
- Tool use overview (pricing) — checked Oct 16, 2026
- Batch processing — checked Oct 16, 2026
Check your understanding
Per-turn cost climbs through a chat. Cause and two fixes?Show answerHide answer
Answer
Growing resent history; trim or compact, and cache the stable prefix.Caching enabled, bill unchanged. Two things to check?Show answerHide answer
Answer
Prefix below minimum or not identical; cache counters inusage.Nightly report job. Lever?Show answerHide answer
Answer
Batch API, 50% off.Which key reads the Usage and Cost API?Show answerHide answer
Answer
An Admin API key (or other admin credential).