Prompt caching

When you often resend the same beginning of a prompt (instructions, documents, history), the cache avoids paying full price for it every time. It is the most powerful savings lever for coding assistants and agents.

How it works

The beginning of your request (the “prefix”) is remembered by the model provider. On later requests, if the beginning is strictly identical, the matching tokens are read from the cache instead of being processed again, at a much lower price.

Three kinds of tokens appear in your invoices and in the usage field of each response:

Table
TypeWhenPrice
Normal inputTokens that are not cached100% of the input price
Cache writeThe first time a prefix is stored125% of the input price (5-minute duration), 200% (1-hour duration)
Cache readLater times, as long as the cache is validA fraction of the input price, shown in the catalog (often 10%, sometimes less)

How much it saves

Cost of the same prefix sent several times, as multiples of the input price (5-minute write at 125%, read at 10%):

Table
Number of requestsWithout cacheWith cache
11.001.25
22.001.35
55.001.65
1010.002.15
5050.006.15

The cache pays for itself from the second request. Over a conversation or an agent loop of 50 requests, the repeated part costs about 8 times less.

Enabling it with the native API (Claude)

Add cache_control to the last block of the prefix you want to store. You can set up to four cache points per request.

json
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "system": [
    {
      "type": "text",
      "text": "You are the company's legal assistant… (long, stable instructions)",
      "cache_control": { "type": "ephemeral" }
    }
  ],
  "messages": [{ "role": "user", "content": "What does article 7 say?" }]
}

Check that the cache works in the usage field of the response:

json
"usage": {
  "input_tokens": 12,
  "cache_creation_input_tokens": 4200,
  "cache_read_input_tokens": 0,
  "output_tokens": 180
}

On the next request, cache_read_input_tokens should appear in place of cache_creation_input_tokens.

The rules to follow

  • Put stable content first (instructions, documents, tools) and changing content last (the user’s question). A single difference in the prefix invalidates the cache.
  • Respect the minimum size: a prefix that is too short is not cached (on the order of 1,000 tokens or more depending on the model).
  • Reuse quickly: the 5-minute cache is renewed on every read; after a pause longer than 5 minutes, it expires.
  • Do not change the model: the cache is specific to each model.
  • Depending on the model family, caching may be automatic and need no setting: in every case, watch the “cache” tokens in the usage field of your responses.
Coding assistants already do it
Claude Code and most coding assistants use prompt caching transparently. You will normally see cache-read tokens appear in the dashboard from the second turn of a conversation.

Going further

Last updated: October 4, 2026Found a bug? admin@minedom-france.fr