Home › Blog › How to Cut Your Anthropic API Costs
How to Cut Your Anthropic API Costs
Claude gives you strong cost levers, but most teams leave them half-used. Caching that silently misses and background jobs on full price are the usual culprits.
Cache your stable prompt prefix (cache reads cost about a tenth of normal input on most models), send anything nobody is waiting on through the Message Batches API (50% off), pick the smallest model that passes your evals, and control thinking spend with the effort setting.
1. Read the usage object on every response
Every Claude API response reports input_tokens, output_tokens, cache_creation_input_tokens and cache_read_input_tokens. Log them with a feature name and rank features by cost. To check a prompt's size before you send it, use Anthropic's token counting endpoint. Third-party tokenizers built for other models won't match Claude's counts.
2. Cache your stable prompt prefix
Prompt caching is the biggest lever on most Claude bills. Mark the end of the stable part of your prompt with cache_control, or turn on automatic caching for the whole request.
- Price: cache reads cost about a tenth of the normal input price on most models, and less on some newer ones. Cache writes cost 1.25× normal input with the default 5-minute lifetime, or 2× with the 1-hour option.
- Break-even: with the 5-minute lifetime, caching pays off from the second request that reuses the prefix. Every cache read resets the timer at no extra cost.
- Order matters: the cache matches a prefix in the order tools, system prompt, then messages. Any change near the top, like a timestamp in the system prompt, invalidates everything after it.
- Minimum size: prefixes shorter than the model's minimum (between 512 and 4,096 tokens, depending on the model) don't cache, and there's no error. Check that
cache_read_input_tokensrises above zero.
3. Batch anything nobody is waiting on
The Message Batches API takes 50% off every token in the request, including cache reads and writes, so the two discounts stack. Results arrive asynchronously within 24 hours. It suits evals, backfills, scheduled reports and enrichment jobs.
4. Pick the model per route
Haiku-class models handle classification, extraction and routing at a fraction of the price of larger models. Test each route on your evals before you switch. Compare cost per completed task, not cost per request: a cheaper model that needs extra retries or turns can end up costing more. A larger model at a lower effort setting is sometimes cheaper per finished task than a smaller one.
5. Control thinking spend with effort
Thinking tokens are billed as output tokens, whether or not you show them to users. On current models, the effort setting is the main control over how much the model thinks. Routine routes such as chat and classification often hold quality at low or medium effort. Keep higher effort for hard coding and agent work, and measure before you change a default.
6. Trim output and agent loops
- Spell out the output shape you need, ideally with an example, so replies stay short.
- Return only the parts of tool results the model actually needs.
- End agent loops as soon as the task is done, and cap the number of steps.
- Don't set
max_tokensso low that replies get cut off. A truncated reply you have to retry costs more than a complete one.
Measure the result
Track cost per request per route, and watch your cache read share after every deploy. A prompt change that breaks caching can wipe out your savings overnight; that's what cost regression protection catches.
Want us to find your 20%?
Book a free 15-minute API cost teardown. Bring last month's provider usage and we'll show you your biggest waste and the first fix we'd ship.
Get My Free 15-Minute API Cost TeardownFrequently asked questions
Does prompt caching work on every Claude model?
Current models support it, but the minimum cacheable length differs by model. If cache_read_input_tokens stays at zero, your prefix is too short or something in it changes between requests.
Do cached tokens count toward rate limits?
On the Claude API, cache reads don't count toward input-token rate limits on most models, so good caching can raise your throughput as well as cut cost.
Can I combine batching and caching?
Yes. The batch discount applies to cache reads and writes too. Cache hits inside a batch are best-effort, because requests in a batch can run at the same time.