← All 96 breakdowns
CACHE

The same AI prompt can cost you 90 % less: prompt caching, the breakdown

What's happening

Every call to a model API sends the whole prompt again: the tools, the system prompt, the documents, the history. To read a prompt, the model computes "keys and values" for every token (its working memory of the prompt). That prefill is the slow, expensive part.

Prompt caching keeps those keys and values for the start of your prompt. If the next call starts with exactly the same tokens, the provider reuses them and only computes the new part. You pay a fraction for the cached tokens and the answer starts sooner.

What the providers publish (Nov 2026):

Cached-token price Default lifetime Turn it on
Anthropic 0.1x input (0.05x on Opus 5.5 / Sonnet 5.5); writes 1.25x (5 min) or 2x (1 h) 5 minutes, refreshed on every hit cache_control (automatic, or per block)
OpenAI (GPT-5.6+) 0.1x input (0.05x on some models); writes 1.25x (30 min) or 2.5x (12 h) 30 minutes minimum, refreshed on reads on by default
Google Gemini 4 0.05x input implicit: keep similar requests close together on by default (implicit)

Minimum cacheable lengths apply (Anthropic 512-4,096 tokens by model, OpenAI 1,024, Gemini 2,048-4,096).

A free demo of the mechanism (open model Qwen2.5-7B on one consumer GPU, a 10,180-token prompt): time to first token 1.86 s cold, 0.055 s with the prefix cached (34x faster), and 1.86 s again after changing one character in the first line.

Why it matters

Agents and RAG apps send the same long prefix thousands of times. Without a cache hit, every call pays full price for it, and waits for it.

What to do (save this)

  1. Stable stuff first: tools, system prompt, long documents, examples, at the very start, byte-for-byte identical.
  2. Changing stuff last: the time, the user's name, retrieved snippets, the question, after the stable part. One changed character early in the prompt misses the whole cache.
  3. Stay inside the cache's lifetime: a hit refreshes it; long gaps let it expire (use the longer lifetime option if your calls are spread out).

Set it up yourself

  1. Find your prompt's stable part. Print two consecutive requests and diff them: the first difference is where your cache ends.
  2. Move anything dynamic (timestamps, IDs, per-user text) below that point.
  3. Anthropic: add cache_control (automatic caching, or a breakpoint after the stable blocks). OpenAI and Gemini cache automatically above their minimum length.
  4. Check the usage fields on the second call: Anthropic cache_read_input_tokens, OpenAI cached_tokens, Gemini total_cached_tokens. If it's 0, something above the breakpoint changed.
  5. Free local test: run the same long prompt twice through an open model with its KV cache kept (llama.cpp's prompt cache, or transformers with past_key_values) and time the first token.

Sources

FREE ONE-TIME UNLOCK

Unlock the full CACHE breakdown

Drop your email once to read the complete step-by-step guide, grab the files, and unlock all 96 Reel breakdowns on this device forever.

✓ Instant reveal right here✓ No spam, unsubscribe any time