2026-04-21

How Prompt Caching Saves 90% on Your Claude API Bills

What is prompt caching? If you reuse the same system prompt over and over with Claude, you are burning money. Here is what Anthropic prompt caching does under the hood and how to set it up with cache_control.

aiclaudeprompt-cachinganthropicclaude-apiapicost-optimization

Okay here is a story. You build an AI app. It has a big system prompt, like 10,000 tokens. Maybe it has tool descriptions, documentation, examples, some rules about how the bot should behave. All useful stuff.

Every time a user sends a message, you send that whole 10,000 tokens again, plus the user’s new message. The model has to read those same 10,000 tokens every single time, even though they never change.

And you pay for every token. Every call.

This is exactly what prompt caching fixes. So what is prompt caching, and how does it save you money on the Claude API? Let me show you.

Why prompt caching exists

A call to Claude Sonnet costs around $3 per million input tokens (current pricing here). Sounds cheap. But it adds up fast.

Say your system prompt is 10,000 tokens. 1000 users each send 5 messages. That’s 50 million tokens of system prompt, re-read over and over. That is $150 just to keep telling the model the same stuff you already told it.

And the model actually has to process those tokens too. So latency goes up. Users wait longer. Bad.

Analogy: imagine you are a barista. Every customer walks up and before taking their order you explain “what is coffee, what sizes do we have, what flavors are possible”. Every single customer. That’s a waste of time. You already know it. They already know it. Just take the order.

What is prompt caching and what does it do?

Prompt caching lets you mark a chunk of your prompt with a “cache this” flag. The first time the model sees that chunk, it processes it normally and saves a snapshot of what it figured out. The next time (within 5 minutes), it loads the snapshot instead of re-reading the whole thing.

Reading from the cache costs about 10 percent of the normal input price. So that $3 per million becomes $0.30 per million for cached stuff. That is a 90 percent discount.

On the FIRST call with caching:

  • Cache WRITE (a tiny bit more expensive than regular input, about 1.25x)
  • The model processes your full prompt

On the NEXT calls (within 5 minutes):

  • Cache READ (cheap, 0.1x of input price)
  • Model skips ahead from the saved snapshot

Cache flow over time

call 1 of 4

Call 1

waiting

system prompt (20K tok)

user msg (~200 tok)

cost ·
latency ·

Call 2

waiting

system prompt (20K tok)

user msg (~200 tok)

cost ·
latency ·

Call 3

waiting

system prompt (20K tok)

user msg (~200 tok)

cost ·
latency ·

Call 4

waiting

system prompt (20K tok)

user msg (~200 tok)

cost ·
latency ·
cache write cache read cache miss new user tokens

Step through the demo. First call writes the cache. All the next calls just read from it. See how little work happens on cached calls.

How to enable prompt caching (cache_control)

In the Anthropic API you just add a cache_control marker to the message block you want cached. Usually your system prompt.

system = [
  {
    "type": "text",
    "text": "... your huge system prompt with tool descriptions, docs, examples ...",
    "cache_control": {"type": "ephemeral"}
  }
]

The ephemeral type means the cache lives for 5 minutes by default. You can extend to 1 hour if you pay a bit more on the write.

Important: the cache key is the EXACT bytes of your prompt. If you change even one character, it becomes a cache miss and you pay the full write price again. So do not inject timestamps or random IDs into your cached section.

The cost savings, with real numbers

Here is a real world example you can play with.

Say you have a 20,000 token system prompt. A user sends 10 messages in a chat session. Each user message is around 200 tokens. Each model response is around 500 tokens.

Cost calculator

20K tokens
200 tokens
500 tokens
10

without cache

$0.681

per session

with cache

$0.210

per session

you save

$0.471

69.2% cheaper · scales with traffic

input tokens sent202K → 22K
over 1000 sessions$471 saved

Prices shown are approximate per-million-token rates. Real-world savings depend on traffic patterns, TTL, and whether your system prompt stays stable across calls.

Play with the sliders. You will see most of the savings come from NOT re-sending that big system prompt over and over. The bigger your system prompt and the more calls you make, the bigger the win.

When prompt caching helps (and when it does not)

It helps a LOT when:

  • You have a big system prompt that never changes
  • You have long documentation or example outputs in the prompt
  • You have a long chat history that gets resent every turn
  • You have a RAG system where you cache the same retrieved docs across calls

It does NOT help when:

  • Every call has totally different context
  • Your prompts are small anyway (under 1024 tokens does not even qualify for caching)
  • The time between calls is more than your TTL (5 minutes by default, the cache expires and you lose it)

Prompt caching gotchas to remember

Cache breakpoints. You can have up to 4 cache_control markers in one request. The cache matches by longest prefix, so usually you put the marker on your biggest stable block first.

Order matters. Cache hits work on PREFIX. If you change something in the middle of the cached block, everything after that is a miss. Stable stuff first, dynamic stuff last.

TTL. Default 5 minutes. You can extend to 1 hour with a longer TTL flag but it costs more to write. For active chat apps, the 5 minute default is usually fine because users keep the conversation going.

Minimum size. Cache only kicks in if the cached content is at least 1024 tokens for Sonnet and Opus, and 2048 tokens for Haiku. Below that, caching does nothing even if you ask for it.

Cache invalidates on model change. If you switch from Sonnet to Opus, that is a fresh cache.

Wrap up

Prompt caching is one of those features that sounds boring but saves you serious money once your app has real traffic. If you are building anything with Claude that reuses context across calls, turn it on. Today.

The basic idea is simple. Don’t pay to re-read the same tokens over and over. The model already figured them out once. Just cache the snapshot.

Frequently asked questions

What is prompt caching?

Prompt caching lets you reuse the processed version of a chunk of your prompt instead of paying the model to re-read it every call. You mark a stable block, like your system prompt, with a cache flag. The first call saves a snapshot, and later calls load the snapshot instead of processing the whole thing again.

How much does prompt caching save?

Reading from the cache costs about 10 percent of the normal input price, so a cached block is roughly 90 percent cheaper. The first call pays a small write premium of about 1.25x, but every cached call after that is where the savings pile up.

How do you enable prompt caching with Claude?

In the Anthropic API you add a cache_control marker of type ephemeral to the message block you want cached, usually the system prompt. The cache key is the exact bytes of that block, so do not inject timestamps or random IDs into it or every call becomes a cache miss.

How long does the prompt cache last?

The default TTL is 5 minutes, and it refreshes each time the cache is used. You can extend it to 1 hour for a higher write cost. For active chat apps the 5 minute default is usually fine because users keep the conversation going.

What is the minimum size for prompt caching?

Caching only kicks in when the cached block is at least 1024 tokens for Sonnet and Opus, or 2048 tokens for Haiku. Below that, adding a cache marker does nothing.

When does prompt caching not help?

It does not help when every call has completely different context, when your prompts are small anyway, or when the gap between calls is longer than the TTL so the cache expires before you reuse it.

Sources

Related sprint

Need this as a working AI automation?

Turn one support, document, lead, reporting, or CRM workflow into a shipped AI agent with review points and handoff.

See AI automation sprint

Need this shipped?

Reading is useful. A focused sprint turns the idea into working software.