Skip to content
dalfidan.dev

← Writing

How to cut your LLM API bill: a practical token optimization checklist

·6 min read·Updated ·ai · llm · cost · tokens
Watercolor illustration of a person at a dusk-lit desk as a long paper receipt curls off a printer, with scissors and paper strips nearby.

The same text does not cost the same number of tokens on every Claude model. In our measurement, the Claude 5.5 models counted 10 to 46 percent more tokens than the Claude 4.x models for identical input. So a model with a cheaper list price can still give you a higher bill.

This checklist covers the five levers that matter, in the order to pull them. Start by measuring, not by switching models.

Here is how much the token count grew for each kind of text:

Bar chart of the token increase on Claude 5.5 versus Claude 4.x for the same text: code +10%, JSON +20%, Turkish prose +20%, English prose +46%

Why a lower price can mean a higher bill

Opus 5.5 lists at $4 per million input tokens. Opus 4.6 lists at $5.

That looks like a 20 percent cut. But if your text turns into more tokens, the cut shrinks or flips. For the code sample, $5 of old spend becomes about $4.40. For the English sample, it becomes about $5.85.

Anthropic says the newer tokenizer produces “approximately 30% more tokens for the same text,” and that the increase depends on the content. Our numbers sat on both sides of that. They come from one run on four short samples, so recount your own prompts before you forecast.

Which lever should you pull first?

Do the safe, quick levers first. Leave the risky one for last.

Lever Typical saving (list price) Quality risk
1. Measure tokens per call None by itself; shows where the money goes None
2. Cache what you resend 90 to 95% off the cached part of the input None
3. Batch what can wait 50% off input and output None (results are slower)
4. Cap and shape output Grows with output removed; output costs 5x input Low to medium
5. Route easy steps to a smaller model Up to 40x per token (Opus 5.5 vs Haiku 5.5) High

The sources behind every number are in the full price and token tables.

1. Measure tokens per call

Every Messages API response reports input_tokens, output_tokens, cache_creation_input_tokens and cache_read_input_tokens. Log them per feature for a day. One or two call sites usually dominate.

To test a change before you ship it, use the count_tokens endpoint. Anthropic says it is “free to use but subject to requests per minute rate limits.”

The way this goes wrong: you count against the wrong model. Tokenizers differ, as the chart above shows, so always count on the model ID you will run. While you are in the logs, check that you are not paying for US-only inference (a 1.1x multiplier) or Opus 5.5 fast mode (double the standard rate) by accident.

2. Cache what you resend

If every request starts with the same tools, system prompt or document, you pay full price for identical tokens every time. Put that static part first and mark it for caching.

A cache read costs 0.05x the base input price on Opus 5.5 and Sonnet 5.5, and 0.1x on most other models. A write costs 1.25x for the 5-minute cache or 2x for the 1-hour cache.

For a hypothetical 20,000-token prefix sent 1,000 times to Sonnet 5.5, that is the difference between these two bars:

Two bars comparing the cost of a 20,000-token prefix sent 1,000 times on Sonnet 5.5: $40.00 uncached versus about $2.05 cached

That is about 95 percent less on the prefix. The part of each prompt that changes, and all output, cost the same as before.

The thing that breaks it: anything that varies near the top, like a timestamp or user ID. The cache matches an exact prefix, so you pay for a new write every time and never get a read. Prompts under the minimum (512 tokens on the 5.5 models) are also silently not cached. If both cache fields in usage are 0, nothing was cached.

If you trim old chat history or tool results to save input, do it in large, infrequent steps. Every edit to earlier content forces a fresh cache write from that point on.

3. Batch what can wait

Anthropic’s Message Batches API charges “50 percent of the standard API prices” on input and output. Most batches finish within an hour. A batch that is not done in 24 hours expires.

Good fits are evals, classification backfills, nightly summaries and moderation queues. Batch and caching discounts stack, though cache hits inside a batch are best effort.

The only thing you give up is speed, so do not use it for anything a user is waiting on.

4. Cap and shape output

Output costs 5 times as much as input on every current Claude model.

On a hypothetical Sonnet 5.5 call with 3,000 input tokens and 800 output tokens, output is a small share of the tokens but most of the cost:

Chart comparing share of tokens and share of cost for a call with 3,000 input and 800 output tokens: output is 21 percent of tokens but 57 percent of cost

Cutting that output to 400 tokens saves about 29 percent of the request. Cutting 1,000 input tokens saves only about 14 percent.

To get there, lower output_config.effort on simple steps. Ask only for the fields your code reads; structured outputs keep the response to your schema. Use max_tokens as a safety net only, because a hard cap cuts answers off mid-sentence.

The risk is that shorter answers drop reasoning the task needed. Compare real outputs before and after.

5. Route easy steps to a smaller model

This is the biggest saving per token. Opus 5.5 lists at $4 input and $20 output. Haiku 5.5 lists at $0.10 and $0.50, a 40x gap. Anthropic describes Haiku 5.5 as built “for high-volume, latency-sensitive tasks such as classification, extraction, and routing.”

It comes last because it is the riskiest. A cheaper model that is wrong more often can cost more in retries and bad decisions than it saves. Build a small eval set from real traffic before you switch.

Also watch the Haiku 5.5 price cliff. A prompt over 100,000 tokens pays $0.50 input and $2.50 output for the whole request.

Do this week

  1. Log tokens per endpoint for a day, and recount your biggest prompts with count_tokens on the model you actually run.
  2. Move static content to the top of the prompt, turn on caching, and confirm cache_read_input_tokens is above 0.
  3. Move every job that nobody waits on to the Batch API.

FAQ

Does prompt caching change the model’s answers?

No. It changes billing and latency for an identical prefix.

Can I combine batch and caching discounts?

Yes. Anthropic says the multipliers stack, but cache hits inside a batch are best effort.

Last verified: 2026-11-17 (prices, documentation and token counts).

Sources