The main levers
- Model choiceHaiku, Sonnet, Opus, routing
- Effortthinking and output volume
- Prompt cachingrepeated prefix at 0.1×
- Batch API50% off, not real-time
- Output lengthconcise asks,
max_tokens - Input sizetrim context and tools
Where the money goes in one request
A request is billed on four kinds of token, reported in the response's usage block: uncached input (input_tokens), tokens written to the cache (cache_creation_input_tokens), tokens read from the cache (cache_read_input_tokens) and output (output_tokens). The prompt-caching docs point out a trap: input_tokens counts only the tokens after the last cache breakpoint, so total input is the sum of all three input fields.
| Model (Sep 2026) | Input / MTok | Output / MTok | Cache read | Batch |
|---|---|---|---|---|
| Claude Haiku 4.5 | $1 | $5 | $0.10 | 50% off input and output |
| Claude Sonnet 5 | $2 | $10 | $0.20 | 50% off input and output |
| Claude Opus 5 | $5 | $25 | $0.50 | 50% off input and output |
Two ratios drive most decisions. Output costs five times input on every model in the table, so a verbose answer is often the biggest line on the bill. And a cache read costs a tenth of a normal input token. Prices change — they're shown here to practise the arithmetic, and the pricing page is the source of truth. One more caution from that page: Claude 4.7 and later models use a newer tokenizer that produces roughly 30% more tokens for the same text, so compare models on measured cost per task, not on list price. The token-counting endpoint, which is free to call, counts a prompt under the tokenizer of the model you name.
Prompt caching: pay once for the part that repeats
Caching stores a processed prompt prefix so later requests that start with the same content read it back cheaply and faster. The prefix is built in a fixed order — tools, then system, then messages — and any change invalidates everything after it. The rules that matter for design:
- Stable content first, variable content last. Anything that changes per request — a timestamp, the user's name — must come after the breakpoint.
- Automatic or explicit. A single top-level
cache_controllets the API place and advance the breakpoint as a conversation grows; explicit breakpoints (up to 4 per request) suit sections that change at different rates. - Minimum length. Prompts shorter than the model's minimum aren't cached, and no error is returned — for example 1,024 tokens on Claude Sonnet 5 and 4,096 on Claude Haiku 4.5.
- Lifetime. The default cache lives 5 minutes; a 1-hour option costs more to write.
Why a cache never hits
0% cache hitstext
system:
"Current time: 09:41:07.
User: Priya (Gold tier).
[5,800 tokens of policy,
tone rules and examples]"
cache_control ← here
messages: [question]Hits on every repeattext
system:
"[5,800 tokens of policy,
tone rules and examples]"
cache_control ← here
messages:
"Current time: 09:41:07.
User: Priya (Gold tier).
[question]"The break-even is quick. A 5-minute cache write costs 1.25× normal input and each read 0.1×, so the pricing page notes it pays off after one read; the 1-hour cache write costs 2× and pays off after two reads.
IN, OUT, READ = 2.00, 10.00, 0.20 # USD per million tokens
def cost(prefix, fresh, out, cached=False, batch=False):
prefix_rate = READ if cached else IN # warm cache assumed
usd = (prefix * prefix_rate + fresh * IN + out * OUT) / 1e6
return usd * (0.5 if batch else 1.0) # batch halves every rate
# 6,000-token stable prefix, 300 fresh tokens, 400 output tokens
print(cost(6000, 300, 400)) # 0.0166 baseline
print(cost(6000, 300, 400, cached=True)) # 0.0058 -65%
print(cost(6000, 300, 150, cached=True)) # 0.0033 shorter answers tooLook at the second line. Once the prefix is cached, the 400 output tokens ($0.004) are about 70% of the remaining cost. The next lever isn't more caching; it is answer length.
The other levers, and what each one costs you
| Lever | Saves | Price you pay | Use when |
|---|---|---|---|
| Smaller model (e.g. Haiku 4.5) | Cost and latency | Capability on hard cases | Simple, high-volume tasks that pass your evals |
| Lower effort | Output and thinking tokens, time | Some depth on hard problems | Routine work on a model that supports effort |
| Batch API | 50% on input and output | Asynchronous; most batches under 1 hour, up to 24 hours | Nobody is waiting for the answer |
| Shorter output | Output tokens, time | Detail | Answers are longer than users need |
| Smaller input | Input tokens, time | Risk of dropping needed context | Unused tools, whole documents where excerpts would do |
| Streaming | Perceived latency (time to first token) | Nothing on cost | A person watches the answer appear |
| Fast mode (preview) | Output speed on Opus 5 / 4.8 | Premium price; not in batch | Latency matters more than cost on the top model |
Effort. Effort is set with output_config.effort and defaults to high. It affects all output — text, tool calls and thinking — and lower levels make fewer, terser tool calls. It isn't available on every model (Claude Haiku 4.5 is not on the supported list). Anthropic's guide to cost and intelligence goes further: sweep effort on your current model before trying multi-model set-ups, because it beats most of them.
Batch. The Message Batches API halves the price of every token and takes up to 100,000 requests or 256 MB per batch. Results arrive when the whole batch ends or after 24 hours, whichever is first; unfinished requests expire and aren't billed. Discounts stack with caching, but cache hits inside a batch are best-effort, and the docs suggest the 1-hour cache for shared context because batches can outlast 5 minutes.
Output length. Ask for brevity in the prompt; the latency guide notes that sentence or paragraph limits work better than word counts, because models count tokens, not words. max_tokens is a hard cap, not a length request: a response that hits it is cut off mid-sentence. On models with adaptive thinking, max_tokens also covers thinking, and thinking tokens bill as output even when the thinking text isn't returned.
Model routing. Anthropic's guide describes two multi-model patterns: a cheaper executor that escalates hard decisions to a stronger advisor, and a frontier orchestrator that fans bulk work out to cheaper workers. Its measured examples cut both ways — an orchestrator set-up cost about half as much on one benchmark and lost on cost on a harder one — so routing is a hypothesis to test on your own evals, not a guaranteed saving.
Which lever first?
- Long prefix repeatsPrompt cachingstable content first
- Nobody waits for itBatch APIplus 1-hour cache
- Simple task, big modelSmaller model or effortonly if evals hold
- User waits, feels slowStream, shorten outputcut time to first token
response = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024, # a cap, not a length request
output_config={"effort": "low"}, # routine question
system=[{
"type": "text",
"text": POLICY_AND_EXAMPLES, # long, identical every call
"cache_control": {"type": "ephemeral"},
}],
messages=[{"role": "user", "content": f"{now()} | {question}"}],
)
u = response.usage
print(u.cache_read_input_tokens, u.input_tokens, u.output_tokens)Traps the wrong answers are built from
| Tempting but wrong | Do this instead |
|---|---|
| Putting timestamps or user details at the top of a cached prompt | Put stable content first and per-request data after the cache breakpoint. |
Using max_tokens to make answers shorter | Ask for brevity in the prompt; keep max_tokens as a safety cap that shouldn't normally be hit. |
| Sending interactive traffic through the Batch API to save 50% | Batch only work nobody is waiting for; results can take up to 24 hours. |
| Switching to a cheaper model based on list price | Measure cost per successful task on your evals, with each model's own token counts. |
| Optimising before the prompt works | Reach target quality first, then apply levers and re-check quality after each. |
You should now be able to
- Compute per-request and daily cost from the
usagefields and the price list, including cache reads and batch discounts. - Structure prompts so caching works, and explain its minimum length, lifetime and break-even.
- Choose between caching, batching, model choice, effort, output length, input trimming and streaming for a given workload.
- Explain the latency effect of each lever, including time to first token and streaming.
- Recognise when a saving costs quality, and require eval evidence before accepting it.