blog / reduce-anthropic-api-costs
How to reduce Anthropic API costs: a practical checklist
Six levers, ordered by how often they are the actual problem. All input-token percentages below are scoped to input; caching does not touch output tokens, and on reasoning-heavy workloads output is a large share of the bill.
1. Fix your prompt structure (the relocation trick)
Claude's cache is prefix-based: the first changed byte invalidates everything after it. Audit your top routes for dynamic content (timestamps, user names, working memory, retrieved snippets) sitting before stable content (system prompt, tool definitions, instructions). Move dynamic content to the tail. This is repeatedly the largest single win in published teardowns, and it costs nothing.
2. Place breakpoints deliberately
You get up to 4 cache_control breakpoints and a minimum cacheable block of about 1,024 tokens. Segment by change frequency: system prompt and tool schemas (rarely change) behind one breakpoint, long stable context behind another, conversation history where it helps. One caveat from the docs: with more than 20 content blocks before a breakpoint, edits earlier than those blocks can cost you the hit; intermediate breakpoints roughly every 18 blocks are the standard workaround.
3. Match TTL to your traffic, and skip writes that lose money
Writes cost 1.25x input (5-minute TTL) or 2x (1-hour). A route must recur within TTL for the premium to pay back: as a rule of thumb, more than ~22% of arrivals recurring within 5 minutes, or more than ~53% within the hour. Full derivation here. If a route does not clear the bar, the profitable move is to not cache it.
4. Stack the Batch API on async work
The Batch API is about 50% cheaper, and Anthropic's caching multipliers stack with the batch discount. Anything that tolerates minutes of latency (evals, backfills, digests, enrichment) belongs there.
5. Right-size the model tier
Opus to Sonnet, Sonnet to Haiku where quality holds is a large lever on its own. Route by task difficulty where you can measure quality; never silently, and never on quality-critical routes without an override.
6. Measure what you realized, net
Compute your effective input cost against list price from the usage blocks you already receive, subtract the write premiums you paid, and compare against what your workload could realize. If you skip this step, you cannot tell lever 1 from lever 3, and you will not notice if caching is quietly costing you money on low-reuse routes.