Cutting Your Claude API Bill with Prompt Caching
By Kallistesoft · · 3 min read
Information checked on December 1, 2026 in Anthropic's official documentation. If your app sends Claude the same long context on every request (instructions, documents, tool definitions), prompt caching can reduce both cost and latency. It is not useful everywhere, though.
The idea
According to the documentation, the API can resume from an already processed prompt prefix instead of reprocessing it. The prefix follows the order tools, then system, then messages, up to the block carrying cache_control. There are two ways to enable it:
response = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
cache_control={"type": "ephemeral"}, # automatic caching
system=LONG_SYSTEM_PROMPT,
messages=[...],
)
You can also put cache_control on specific blocks (up to 4 breakpoints per request). The default lifetime is 5 minutes, refreshed on every read; "ttl": "1h" extends it to one hour.
What it costs
Multipliers apply to the base input price: 5-minute write ×1.25, 1-hour write ×2, read ×0.1 by default, and ×0.05 for Opus 5.5 and Sonnet 5.5. With Sonnet 5.5 ($2 per million input tokens, per the models overview), a cache read therefore costs $0.10 per million. A single re-read is enough to pay back the 5-minute write. The Batch API, with its 50% discount, is a separate lever.
When it does nothing
- Prompt too short: the minimum is 512 tokens for the 5.5 models, more for older ones (up to 4,096). Below it there is no error; caching is simply skipped.
- Spaced-out requests: if two calls are more than 5 minutes apart, the entry expires. Consider the one-hour lifetime, which costs more to write.
- A prefix that changes: changing
toolsinvalidates everything; changingsysteminvalidates the system and message caches. Put stable content first and variable items (date, user name) last.
Check that it works
Do not assume: read the response's usage object.
cache_creation_input_tokens # written on this request
cache_read_input_tokens # read from the cache
input_tokens # uncached, after the last breakpoint
If both of the first two are 0, the prompt was not cached; the most likely cause is a prompt below the minimum. Log these values to compute your real hit rate.
A worked example
Suppose a support assistant sends a 6,000-token system prompt on every request, 1,000 times a day, with Sonnet 5.5. Without caching, that is 6 million input tokens a day for the prompt alone, about $12 at the base rate. With caching, and requests close enough to keep the entry alive, you pay for the 5-minute writes (×1.25) when the entry expires, then reads at ×0.05. Even with a write every few minutes, the prompt portion drops sharply. These figures are an illustration based on the documented multipliers, not a measurement: run it on your own traffic and compare the usage fields.
Conclusion
Prompt caching suits assistants, questions over a fixed document and agents with many tools. For a one-off request or a context that changes on every call, it brings nothing. Measure before rolling it out, and also compare model choices: a smaller model is often enough for classification or extraction. Caching is an optimisation, not a feature: keep your prompts readable first, and add it where your logs show repeated, stable context.