Token Economics Best Practices
A field guide to keeping Claude API spend proportional to the value it delivers: pick the right model tier by default, cache what's reused, batch what can wait, and measure everything instead of guessing.
Search across all documentation pages
A field guide to keeping Claude API spend proportional to the value it delivers: pick the right model tier by default, cache what's reused, batch what can wait, and measure everything instead of guessing.
custom_ids rather than reprocessing the entire batch.messages.count_tokens is free and exact for the input side; use it to gate or estimate cost before a user-supplied document or long context hits the API.Model selection (section A): pick an explicit default tier and document it. It's the highest-leverage, lowest-effort change and everything else builds on top of it.
Yes, if a workload genuinely has no reused prefix, every request is truly unique content, caching adds cost with no offsetting savings. Caching is a lever for reuse, not a universal default.
Defaulting to the strongest model "just in case" instead of matching model tier to actual task difficulty. It's the easiest mistake to make because it feels safe, and the most expensive one at scale.
Run the break-even calculation: divide the one-time engineering cost by the per-request savings. If your expected request volume clears that number comfortably, the investment pays for itself.
For any production workload with real cost implications, yes, the four usage fields are cheap to log and are the only reliable way to reconcile actual spend against your cost model later.
Model selection is a decision you make once (per feature or per team), while measurement and governance are ongoing practices that verify the decision still holds as conditions change. Conflating the two makes it easy to set a good default and then forget to revisit it.
A config default tells you what the current setting is; an ADR tells you why, under what conditions it should change, and what alternatives were rejected. Both matter, but only the ADR prevents the decision from being reverse-engineered later.
No, but the weighting of effort should scale with volume, sections A and B apply almost universally, while C and D's engineering investment should be sized to actual request volume and budget stakes.
Compare blended actual cost per request (from logged usage) against what a flat, unoptimized single-model policy would have cost for the same traffic. A shrinking gap over time signals the practices are paying off.
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5 - and the official
anthropicPython SDK (latest 0.x release). Model names, pricing, and SDK versions move quickly - verify current specifics at platform.claude.com/docs before relying on them.
Reviewed by Chris St. John·Last updated Jul 19, 2026