Skip to the page
Tecyfy

Prompt caching vs KV caching: what each one saves

KV caching saves work inside one answer and is always on. Prompt caching keeps that work between requests, so a repeated start is read at a tenth of the input price or less. What each saves, how Claude, OpenAI, Gemini and vLLM do it, and what breaks it.

Tecyfy · Published · 7 min read

A mosaic chef takes a ready tray of ingredients from a CACHE cupboard instead of starting again: prompt caching reuses earlier work

KV caching and prompt caching keep the same thing, the keys and values a model works out for each token it reads, for different lengths of time. The KV cache lasts for one answer: it saves the model from redoing work for every new token, it is always on, and it never shows on a bill. Prompt caching keeps that work after the answer is finished, so the next request that starts with the same text skips it. On most Claude models and on OpenAI's GPT-5.6 and later, those tokens are billed at a tenth of the input price. The rate is a twentieth on Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.1 Sol and GPT-6.1 Terra, and a fortieth on Claude Fable 5.1 and Claude Mythos 5.1.

KV caching: inside one answer

A model writes one TokenTokenThe small piece of text a language model reads and writes, often part of a word. Prices, limits and the context window are all counted in tokens. at a time, and each new token is worked out from every token before it. In every attention layer each earlier token has a key and a value. The KV cacheKV CacheWork a model saves from the text it has already read, so it is not redone for every new token. Prompt caching keeps that work between requests and charges less for it. keeps them, so for the 1,001st token the model reuses what it stored for the first 1,000 and only works out the newest one. Hugging Face describes the gain this way: without the cache the attention cost of each step grows with the square of the length, and with it only in step with the length.

The price is memory on the GPU, and it is gone when the answer is finished. If you call an API, you never set or pay for it. If you run a model yourself, it decides how many conversations fit on a GPU, which is worked out in KV cache size: the formula.

Prompt caching: between requests

A chat or an agent sends the whole conversation again on every turn. Anthropic's example is a task that grows from 20,000 to 120,000 tokens over 40 turns and reads about 2.8 million input tokens, because each turn resends the conversation so far. Without a cache, the provider reads that start again on every request and bills it at the full input price.

Prompt cachingPrompt CachingLetting the API keep the processed start of a prompt for a few minutes, so later requests that begin the same way are cheaper and quicker. keeps the processed start of the prompt for a few minutes. OpenAI's documentation says what it keeps: the cache stores key-value (KV) tensors, not the tokens themselves. When the next request begins with exactly the same tokens, those are read from the cache instead of being worked out again. That saves 2 things:

  • Money. Cached tokens are billed at 0.1 times the input price on most Claude and OpenAI models, 0.05 times on Claude Opus 5.5, Claude Sonnet 5.5 and GPT-6.1 Sol.
  • Time. The model can start answering sooner, because it skips processing the cached part of the prompt. Anthropic notes the gain for long documents.

Change the start below and the number of turns, and turn the cache off and on.

Try itWhat prompt caching saves in a chat
Model
10Ktokens

system prompt, tools and documents

20turns

each adds a 200-token message and a 400-token answer

Input sent on each turn

Turn 1Turn 20: 21.4K tokens

New, written to the cache

Read from the cache

Cache off$1.42

Cache on33 cents

Saved77%

20 turns on Claude Opus 5.5 send 314,000 input tokens, 93% of them read from the cache. The chat costs 33 cents instead of $1.42, 77% less.

Prices per million tokens for Claude Opus 5.5: input $4, cache write $5, cache read $0.20, output $20. With the cache on, each turn writes what is new and reads the rest, as automatic caching does when the turns come within the cache's 5 minutes.

A single request with no repeat costs more with a cache, because the write is billed above the input price (1.25 times on Claude's 5-minute cache and OpenAI's 30-minute cache) and nothing reads it back. On Claude's 5-minute cache, caching pays off after one read; on the 1-hour cache it takes two.

The 2 caches side by side

KV cachePrompt cache
KeepsKeys and values of each token readThe same, for the start of a prompt
LastsOne answerMinutes after the last use
SavesWork for every new tokenReading the same start again, and its cost
On your billNoYes: writes cost more, reads much less
Who turns it onAlways onYou, or the provider by default

How each provider does prompt caching

  • Claude. You turn it on with cache_control. Put it once at the top of the request and the cache point moves forward as the conversation grows (automatic caching), or put it on up to 4 blocks you choose. The cache lasts 5 minutes, counted from the start of the last request that wrote or read it; 1 hour costs 2 times the input price to write instead of 1.25 times. Reads cost 0.1 times the input price, 0.05 times on Opus 5.5 and Sonnet 5.5, and 0.025 times on Fable 5.1 and Mythos 5.1. The shortest prompt it caches is 512 tokens on the newest models.
  • OpenAI. On by default. Writes cost 1.25 times the input price on GPT-5.6 and later and reads 0.1 times, 0.05 times on GPT-6.1 Sol and GPT-6.1 Terra and GPT-6.1 Terra. On GPT-5.6 and later, the shortest prompt is 1,024 tokens, and a cached start stays eligible for cache-read pricing for at least 30 minutes after its last write or read.
  • Gemini. Implicit caching is on by default for Gemini 2.5 and newer models, with a minimum of 4,096 tokens on Gemini 4 Argon and 3.8 Flash. Explicit caches are not offered from Gemini 4 Argon onward.
  • Your own GPU. vLLMvLLMAn open-source engine for serving language models fast, built on PagedAttention, that answers requests through the same kinds of API the big model makers offer.'s automatic prefix caching keeps the KV cache of earlier requests and reuses it when a new one shares the same start. It saves time, not a bill, and is turned on by setting enable_prefix_caching=True in the vLLM engine.

To price a repeated prompt on each Claude model, with the 5-minute and the 1-hour cache, use the prompt caching calculator.

What breaks a prompt cache

A cache only matches a start that is identical, token for token. Anything that changes breaks the match from that point on. The request can still read an earlier cached start, but only one an earlier request wrote, and on Claude only within 20 blocks of the breakpoint; the rest is processed again. On Claude the prompt is read in the order tools, system prompt, messages. So:

  • Keep a timestamp, a user's name or a request id out of the system prompt. Put them at the end, after the cache breakpoint. On Claude, place an explicit breakpoint on the last block that stays the same, not on the changing one.
  • Keep the list of tools in the same order on every request.
  • Put the documents and examples that every request shares at the start, and the question at the end.
  • Send the next request within the cache's lifetime, or choose the 1-hour cache on Claude for traffic with long gaps.

Check that it works. Claude reports cache_creation_input_tokens and cache_read_input_tokens with every answer. If both are 0, nothing was cached, and the API does not return an error for a prompt too short to cache. Caches are kept apart per organization, and on the Claude API per workspace as well, so 2 workspaces never share one.

Which one to think about

If you call a model through an API, the KV cache is not yours to manage. Prompt caching is, and on an agent or a chat that runs many turns most of every request is the repeated start. Order the prompt so the fixed parts come first, turn caching on, and read the usage fields. If you run the model yourself, size the KV cache for the memory, then turn on prefix caching so requests that share a system prompt skip it.

Caching is the first step in how to reduce LLM API costs, and the production module of the free AI engineering course puts it in a cost plan with batches and model choice.

Questions

What is the difference between prompt caching and KV caching?
KV caching keeps the keys and values of the tokens a model has already read while it writes one answer, so each new token does not redo that work. It is always on and you never see it on a bill. Prompt caching keeps that work after the answer is finished, so the next request that starts with the same text skips it and pays less for those tokens.
How much does prompt caching save?
Cached tokens cost 0.1 times the input price on most Claude models and on OpenAI's GPT-5.6 and later, 0.05 times on Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.1 Sol and GPT-6.1 Terra, and 0.025 times on Claude Fable 5.1 and Claude Mythos 5.1. Writing to Claude's 5-minute cache, or to OpenAI's default 30-minute cache on GPT-5.6 and later, costs 1.25 times; longer caches cost more to write. In one illustration on Claude Opus 5.5, a task that processes about 2.8 million input tokens costs $11.20 in input with no cache and about $1.62 with 90% read from cache.
Is prompt caching automatic?
On OpenAI and on Gemini 2.5 and newer it is on by default. In Claude's Messages API you turn it on with cache_control (in Managed Agents it is always on), either once at the top of the request (automatic caching, which moves forward as the conversation grows) or on the blocks you choose. In vLLM you turn on automatic prefix caching.
Why is my prompt not being cached?
Check 3 things: the start changes between requests (a timestamp, a user name or a reordered tool list early in the prompt), the prompt is shorter than the model's minimum (512 tokens on the newest Claude models, 1,024 on GPT-5.6 and later, 4,096 on Gemini 4 Argon), or the next request came after the cache expired. On Claude, if both cache usage fields in the response are 0, nothing was cached.
Does prompt caching change the answer?
No. It skips work the model would do the same way again. Anthropic states that the response is identical to what you would get without caching. It also starts answering long prompts sooner.