Free auditStart free
GlossaryGlossary · AI search

Prompt caching

Prompt caching lets an LLM API reuse a processed prompt prefix. How Claude's cache_control and OpenAI's automatic caching work, TTLs, minimums and what breaks a hit.

3 min
read
3
sources
Oct 31, 2026
updated
Scaplet Editorial Team
author
In one line

Prompt caching lets a model API reuse the processed beginning of a prompt across requests instead of processing it again. Anthropic caches the prefix in the order tools, system, messages, up to a cache_control breakpoint. OpenAI caches by default when requests share an identical prompt prefix. Either way, a match needs the prefix to be identical.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode

At a glance

4 facts from the sources below
tools, then system, then messages
Claude cached order
5 minutes; 1 hour with ttl: 1h
Claude default TTL
Up to 4 per request
Claude breakpoints
On by default for supported models
OpenAI
01At a glance

Anatomy of a cached Claude request

Piece

Top-level cache_control

What it does
Automatic caching. The breakpoint moves to the last cacheable block as the conversation grows.
Piece

cache_control on a block

What it does
An explicit breakpoint. Up to 4 per request; automatic caching uses one of them.
Piece

"ttl": "1h"

What it does
One-hour lifetime instead of the 5-minute default. In one request, 1-hour entries must come before 5-minute entries.
Piece

Long second system block

What it does
The stable bulk of the prompt, the part worth caching.
Piece

response.usage

What it does
Reports what was written to and read from the cache.
From Anthropic's prompt caching docs
response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    cache_control={"type": "ephemeral"},
    system=[
        {"type": "text", "text": "You are an AI assistant tasked with analyzing legal documents."},
        {
            "type": "text",
            "text": "<full 50-page agreement text>",
            "cache_control": {"type": "ephemeral", "ttl": "1h"},
        },
    ],
    messages=[{"role": "user", "content": "What are the key terms in this agreement?"}],
)
print(response.usage.model_dump_json())
03At a glance

Claude and OpenAI compared

Question

Opt in?

Anthropic
Yes, with cache_control
OpenAI
On by default for supported models
Question

What must match

Anthropic
An identical prefix up to the breakpoint
OpenAI
The entire rendered prefix; a change before a breakpoint blocks reuse of everything after it
Question

Where to read hits

Anthropic
cache_read_input_tokens and cache_creation_input_tokens in usage
OpenAI
usage.input_tokens_details.cached_tokens
Question

Documented savings

Anthropic
Reads cost 0.1x base input, with exceptions
OpenAI
Cached input can be discounted by up to 95%; exact rates vary by model
05How it works

Check it in 2 minutes

  1. 1

    Send the same request twice

    Within the lifetime. The first response should show tokens in cache_creation_input_tokens, the second in cache_read_input_tokens.

  2. 2

    Total the input

    Anthropic gives the formula: cache_read_input_tokens plus cache_creation_input_tokens plus input_tokens.

  3. 3

    Both cache fields at 0

    The prompt was not cached, usually because it was under the model's minimum length.

  4. 4

    On OpenAI, read `cached_tokens`

    Check usage.input_tokens_details.cached_tokens on the second call.

Sources · 3

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • claude.com
  • openai.com
  1. 01Prompt caching (Claude docs)platform.claude.com · checked 2026-11-01
  2. 02Prompt caching (OpenAI developer docs)developers.openai.com · checked 2026-11-01
  3. 03Extended thinking (Claude docs)platform.claude.com · checked 2026-11-01
Questions

Asked a lot.

1 questions people ask next, answered from the sources on this page.

01Does prompt caching change what the model answers?

No. Anthropic states that caching does not change the generated output. It changes how much of the prompt is processed again and how that is billed.

Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly