What this thread does
Do first: Put reusable content first and mark its last stable block with cache_control: {"type":"ephemeral"}.
Short answer
Cache the complete shared prefix in order tools → system → messages. Reuse identical content on later requests. Explicit breakpoints suit a stable prefix followed by changing input; top-level automatic caching suits growing conversations.
What to do
| Setting / rule | Value / action |
|---|---|
| Explicit caching | Put cache_control: {"type":"ephemeral"} on the last reusable content block |
| Automatic caching | Put the same cache_control at request top level; it targets the last cacheable block and moves with the conversation |
| Cache type | ephemeral is the only supported type |
| Lifetime | Default 5 minutes; add ttl: "1h" for 1 hour |
| Refresh | Reads refresh the lifetime without an extra refresh charge; lifetime starts at request start, including response generation time |
| Mixed lifetimes | Place 1-hour entries before 5-minute entries |
| Breakpoints | At most 4; automatic caching consumes one slot |
| Prefix lookup | At most 20 positions per breakpoint, counting the breakpoint itself |
| Consecutive tool blocks | On Claude API, a run of tool_use blocks or a run of tool_result blocks counts as one lookup position |
| Match | 100% identical prefix, including text and images through the breakpoint |
| Cache availability | After the first response starts; wait for that before concurrent requests expecting hits |
| Invalidation | Changing tools, system or messages invalidates that level and later levels |
| Valid targets | Tool definitions, system/message content, images/documents and tool results; do not mark empty text, thinking blocks or citation sub-blocks directly |
Minimum prefix tokens on Claude API (also listed for Claude Platform on AWS, Google-managed Claude and Foundry, where the model is available):
| Tokens | Claude models |
|---|---|
| 512 | Fable 5.2, Mythos 5.2, Fable 5.1, Mythos 5.1, Opus 5.5, Opus 5, Sonnet 5.5, Fable 5, Mythos 5, Haiku 5.5 |
| 2,048 | Mythos Preview, Opus 4.7 |
| 4,096 | Opus 4.6, Opus 4.5, Haiku 4.5 |
| 1,024 | Opus 4.8, Sonnet 5, Sonnet 4.6, Sonnet 4.5 |
| 1,024, retired exceptions | Opus 4.1 and Sonnet 4 on Google-managed Claude / Bedrock; Opus 4 on Google-managed Claude |
The page marks Sonnet 4.5 deprecated. Below the minimum, the prompt is processed without caching and without an error.
| Cost relative to base input price | Multiplier |
|---|---|
| 5-minute write | 1.25× |
| 1-hour write | 2× |
| Read / refresh | 0.1× normally |
| Read / refresh exceptions | Fable 5.2, Mythos 5.2, Fable 5.1, Mythos 5.1: 0.025×; Opus 5.5, Sonnet 5.5: 0.05× |
Inspect response usage (or streaming message_start): cache_creation_input_tokens counts writes, cache_read_input_tokens counts reads, and input_tokens counts uncached tokens. Total input is their sum. Both cache counters at 0 means the request did not use caching. The cache_creation object splits writes into ephemeral_5m_input_tokens and ephemeral_1h_input_tokens.
For optional pre-warming, use max_tokens: 0 with an explicit breakpoint on the shared prefix. Keep the same thinking configuration and output_config.effort as follow-up requests. The response has empty content and stop_reason: "max_tokens".
Limits and open questions
- Automatic caching is a no-op when the final block has an explicit marker with the same TTL. A different TTL there, or 4 existing explicit breakpoints plus automatic caching, produces HTTP
400. - On Amazon Bedrock
bedrock-runtime, top-level automatic caching produces400; use block-level breakpoints. Bedrock has platform-specific minimums and usage fields. - A changing suffix inside the breakpoint prevents reuse unless an earlier matching prefix was already written. Add an earlier breakpoint before the changing input.
- Prompt caching reuses input computation; it does not cache generated answers. Exact per-model prices and other price modifiers are separate from the multipliers above.
Not for: OpenAI API prompt caching.
Sources
- Anthropic prompt caching documentation, Anthropic.
Checked
2026-11-16; read Anthropic prompt caching documentation, including automatic/explicit caching, minimums, pricing, usage, TTLs and pre-warming; no command was run.
Started from a post by @Anthropic, packaged by the editor. Original post