Sign in
Back to blog

Prompt caching explained: why a coffee break costs you money

Prompt caching can cut what you pay for AI input by 95%, or quietly raise it. Here's how Claude and OpenAI caches work in plain words, what they cost, and the habits that keep them warm.

You asked Claude to fix one thing. You went to make coffee. You came back eight minutes later, typed "ok, now the tests", and the bill for that one message was bigger than the last ten.

You didn't do anything wrong. You walked past a timer nobody told you about. This week a post on Hacker News claimed that timer is 23% of a coding bill, and the thread argued about whether that's true. The honest answer is "it depends on how you work", so here's how it works.

What prompt caching actually is

Every time you send a message, the model reads the whole conversation again from the top: the instructions, the files, every earlier turn. That reading is what you pay for as input tokens.

A prompt cache saves the reading. If the start of your next message is exactly the same as last time, the provider reads the saved copy instead and charges you a small part of the normal price.

Two words matter there. Exactly, and start.

The cache only works on the beginning of the prompt, and it has to match token for token. Waldek Mastykarz put it well: a request id near the top of your instructions, or tools listed in a different order on each call, and every request pays full price while your code looks fine.

How a cache hit happens: the first call writes the cache, a call with the same start reads it cheaply, and a change near the top or a long wait sends you back to full price.
How a cache hit happens: the first call writes the cache, a call with the same start reads it cheaply, and a change near the top or a long wait sends you back to full price.

What it costs on Claude, in numbers

Anthropic lists every cache price on its pricing page. Here's Claude Sonnet 5.5, per million input tokens:

One million input tokens on Claude Sonnet 5.5: $2.00 normal, $2.50 for a 5-minute cache write, $4.00 for a 1-hour cache write, and $0.10 for a cache read.
One million input tokens on Claude Sonnet 5.5: $2.00 normal, $2.50 for a 5-minute cache write, $4.00 for a 1-hour cache write, and $0.10 for a cache read.
Opus 5.5 Sonnet 5.5 Haiku 5.5
Normal input $4 $2 $0.10
Write, kept 5 minutes $5 $2.50 $0.125
Write, kept 1 hour $8 $4 $0.20
Read (a hit) $0.20 $0.10 $0.01

So a write costs a bit more than normal input, and a read costs almost nothing. Anthropic's own page says the 5-minute cache pays for itself after one read, and the 1-hour cache after two.

The catch is the clock. Anthropic's caching docs say the default cache lives for 5 minutes, and each hit resets it for free. Miss the window and the next message writes the whole thing again at the write price.

OpenAI works the same way, with a longer clock

OpenAI turned caching on automatically for everyone back in 2024. Their current prompt caching guide says that for GPT-5.6 and later:

  • A cache write costs 1.25 times normal input and lasts 30 minutes by default.
  • You can ask for 12 hours instead, at 2.5 times normal input.
  • A read costs 0.1 times normal input on most models, and 0.05 times on a few.
  • Prompts shorter than 1,024 tokens aren't cached at all.

One commenter in the HN thread summed up the difference: 5 minutes on Claude, 30 on OpenAI, with a longer option on both if you pay more for the write.

When the cache makes your bill bigger

This is the part that surprises people. A cache you never read again is a tax.

Aditya ran the numbers on a 6,000-token prompt sent once an hour with a 5-minute cache. The cache made the bill 14.1% bigger, while the same setup at steady traffic cut input cost by 87.7%. The discount comes from how often you call, not from the feature.

Here's a plain example. A job sends a 20,000-token prompt to Sonnet 5.5 three times an hour, every 20 minutes:

  • No cache: 3 × $0.04 = $0.12 an hour.
  • 5-minute cache: it expires before every run, so you pay the write price 3 times. $0.15 an hour, more than no cache.
  • 1-hour cache: one write at $0.08, then two reads at $0.002. About $0.084 an hour.

Rolan Bendecio made the same point about jobs that run every 20 minutes: they miss the default cache every time.

One more trap. Emil Zaman noticed the 5-minute clock starts when your request starts, not when the answer ends. A reply that streams for four minutes leaves you about one minute to send the next message.

Five habits that keep the cache warm

  1. Put what never changes at the top. Instructions, tool lists and reference files first. Dates, ids and the user's question last.
  2. Keep tool lists in a fixed order. Same names, same order, every call.
  3. Match the clock to your pace. If you think for ten minutes between turns, pay for the 1-hour cache. If you fire messages back to back, the 5-minute one is cheaper.
  4. Watch the hit rate, then the misses. One person had a 95.4% hit rate and still spent a fifth of their input money rebuilding the cache. Hit rate counts tokens. Your bill counts misses times the size of what you resend.
  5. Know your tool's default. Claude Code's docs say it asks for the 1-hour cache when you're on a Claude subscription inside your plan's usage, and the 5-minute cache on an API key. Another commenter keeps the cache timer in their status line so they can see it.

Big teams feel this too. Cloudflare said caching and smarter model choice cut their AI code reviewer's inference bill by 68%.

How we handle it in Team Brain

Most of the AI work in a team isn't a chat. It's the same small job on a schedule: a morning digest, a nudge about late tasks, a check on new rows. That's exactly the shape that misses a 5-minute cache.

So in Team Brain, an agent can run as a short script that only calls a model for the step that needs one. Reading rows, filtering by date and writing a summary row back is plain code, with no tokens at all. The cheapest cached token is the one you never send.

When a step does need a model, you pick it per agent and see when it runs:

An agent's page in Team Brain: it runs every day at 8:00, uses Claude Sonnet 5.5 and stops after one hour.
An agent's page in Team Brain: it runs every day at 8:00, uses Claude Sonnet 5.5 and stops after one hour.

Every AI answer then shows up in one list, with the model, the tokens and the credits it used. An agent's run receipt also counts how many of its input tokens came from the cache.

The Usage tab in Team Brain: credits used, AI answers from chats, agents and apps, and the latest answers with their model and tokens.
The Usage tab in Team Brain: credits used, AI answers from chats, agents and apps, and the latest answers with their model and tokens.

You can pay per use, or bring your own AI subscription or key and pay your provider directly. The workspace itself is free for any number of people.

Common questions

Do I have to turn prompt caching on? On OpenAI it's automatic. On Claude's API you add one cache_control setting to the request, or your tool does it for you.

Does caching change the answer? No. It only skips re-reading text the model already read. The output is priced the same as always.

Is the 1-hour cache always better? No. It costs more to write. It wins when you come back after more than 5 minutes but within the hour.

Does this matter on a flat subscription? Less for money, more for limits. A missed cache still burns your plan's usage faster, as people in the HN thread pointed out.

Prompt caching explained: why a coffee break costs you money · Team Brain