Prompt Caching
Definition
Prompt caching lets API requests resume from a cached prompt prefix, cutting processing time and cost for repetitive prompts. Enabled via cache_control, either as automatic caching (one top-level field; the system puts the breakpoint on the last cacheable block and moves it forward as the conversation grows) or explicit cache breakpoints (placed on individual content blocks).
Key Points
- Pricing multipliers (vs base input): 5m cache write = 1.25×, 1h cache write = 2×, cache read = 0.1×. On Opus 5 (6.25, 1h write 0.50.
- TTL: default 5 minutes (refreshed free on each hit); 1-hour TTL available via
"ttl": "1h"at 2×. - Minimum cacheable prefix: 512 tok (Opus 5/Fable 5/Mythos 5), 1024 (Opus 4.8, Sonnet), 2048 (Opus 4.7, Mythos Preview), 4096 (Opus 4.6/4.5, Haiku 4.5). Shorter prompts cannot be cached even with
cache_control. - Mechanics: each request hashes the prefix at the breakpoint and walks backward (max 20-block lookback) for a prior write; writes occur only at breakpoints. Cacheable: tools, system prompts, text/images/documents, tool use/results. Thinking blocks, citations, and empty text blocks cannot be cached directly.
- Isolation & limits: exact match required; cache isolated per workspace (org-level on Bedrock/Vertex); cache hits are not deducted against rate limits; pre-warming possible via
max_tokens: 0(no output billed).
Implications
Prompt caching is the mechanism behind the “repeated content is cheap” rule in token-usage-reduction. The 0.1× read price makes conversation history, system prompts, and tool definitions the cheapest content to re-send — so cache-aware tools (like claude-code-system-prompt’s deferral of tool definitions) exist to keep cacheable prefixes stable and large. The per-model minimum-prefix thresholds and write multipliers (1.25–2×) mean caching is only a win above the prefix minimum and when reads dominate writes.
Open Questions
- Whether the model-specific thresholds shift as new models ship (version-sensitive numbers).
- How automatic breakpoint placement performs vs explicit breakpoints on long, heterogeneous prompts.
- Anthropic’s read/write multipliers (0.1× read, 1.25–2× write) and OpenAI’s (1.25× write) are provider-specific and version-sensitive; do not compare numerically across providers.
OpenAI: Prompt caching (confidence: high)
OpenAI’s prompt caching uses exact-prefix matching at cache breakpoints, auto-enabled for prompts ≥1024 tokens.
- Routing & lookup: requests hash the initial prefix (first ~256 tokens, model-dependent) for machine routing;
prompt_cache_keyadds explicit routing control to improve hit rates on shared long prefixes. Maintain traffic at ~15 requests/minute per key to prevent cache misses at high volume. - GPT-5.6 behavior change: the implicit breakpoint is placed at the latest user/tool message and — unlike earlier models — there is no fallback to the longest matching unmarked prefix before it. Shared static prefixes can therefore yield
cached_tokens: 0when the latest message changes. Fix: explicitprompt_cache_breakpointafter the stable prefix + sharedprompt_cache_key; setprompt_cache_options.mode: explicitto disable the implicit breakpoint. - Breakpoints:
mode: implicit(default; breakpoint on latest message + any explicit ones) vsexplicit(only explicit breakpoints eligible for reads/writes). A breakpoint marks the exact end of the cached prefix; content after it may change without invalidating the cache. TTL30m(only supported value; minimum lifetime, not max retention). Up to 4 new cache writes/request; reads consider up to the latest 50 breakpoints; longest matching prefix wins. - Retention: GPT-5.6+ uses
prompt_cache_options.ttl. Earlier models useprompt_cache_retention:in_memory(5–10 min inactivity, max 1h, volatile GPU memory only) or24hextended (KV tensors offloaded to GPU-local storage; prompt text itself never persisted).gpt-5.5/gpt-5.5-prosupport only24h. - Pricing: GPT-5.6+ cache writes bill 1.25× the uncached input rate (exposed via
cache_write_tokens); reads bill at the cached-input rate. Min cacheable prefix: 1024 tok strict (GPT-5.6+), 1024–2048 (GPT-5.5 and earlier). - Structuring: static content (instructions, examples, tools, images) first; variable content last — identical to the Anthropic advice on this page.
Related
token-usage-reduction — cost-lever concept this mechanism underlies token-optimizer-mcp — tool that measures prompt-cache economics from transcripts claude-code-system-prompt — tool definitions deferred to keep cacheable prefixes stable claude-code-cache-fix — tool that repairs silent cache breaks on /resume and surfaces hit rates gpt-5-6 — the OpenAI model family whose caching behavior differs from earlier snapshots
Sources
- raw/external/platform-claude-com-prompt-caching-a167718a.md
- raw/external/developers-openai-com-prompt-caching-a7f81296.md
- raw/external/developers-openai-com-prompt-caching-bc9e0f40.md