Imtiaz RayhanFounder & EditorBoth Anthropic and OpenAI treat prompt caching as a first-class economic primitive as of December 2026, with cache-read discounts reaching 95% off on flagship models from both labs. Look closer and the designs still diverge in meaningful ways. Anthropic centers caching on explicit cache_control prefix breakpoints with a strict Tools -> System -> Messages hierarchy and a 512-token floor on Claude 5.5 tiers. OpenAI pairs default automatic prefix caching with explicit retention controls on the Responses and Chat Completions APIs, a 1,024 visible-token floor, and extended 12-hour persistence.
That architectural gap changes how you structure prompts, pick TTL tiers, and debug hit rates. This post sits under the context engineering pillar and is the side-by-side companion to the prompt caching guide.
The Two Approaches at a Glance
The headline difference is where the control lives.
On Anthropic, caching is opt-in per request with explicit breakpoints, as detailed in Anthropic's prompt caching documentation. You attach a cache_control marker to a content block, and the API caches everything up to and including that block in a strict Tools -> System -> Messages evaluation order. You choose where each cache tier ends and whether that entry uses the 5-minute default TTL or the 1-hour extended TTL.
On OpenAI, caching is automatic by default with explicit retention options on the Responses and Chat Completions APIs, documented in OpenAI's prompt caching guide. Any request sharing at least 1,024 visible leading tokens with a recent call automatically hits the cache, and on the Responses API you can extend persistence from the 30-minute standard window to a 12-hour extended tier.
Both converge on the same layout discipline — stable-first, variable-last — and both require byte-for-byte prefix matching. Anthropic rewards deliberate multi-tier layering; OpenAI rewards uniform prefix construction and offers longer retention for sparse traffic. The prompt caching glossary entry has the short definition; this post compares the two designs in production.
Anthropic's Explicit Cache Breakpoints
Anthropic's cache_control marker is a content-block annotation ({ "type": "ephemeral" }, with an optional "ttl": "1h" for extended persistence). The API resolves cached prefixes in a strict hierarchy: Tools -> System -> Messages. Changing a tool definition invalidates the system and message caches downstream; changing a user message leaves the cached tools and system prompt intact.
That design lets you layer cache regions cleanly. A production agent typically has distinct stability tiers:
- Tool definitions (stable per deploy)
- System prompt and rules (stable per deploy)
- Reference docs or few-shot libraries (stable per week or session)
- Retrieved context and current user turn (varies per call)
Place a breakpoint at the end of your tool definitions, another at the end of your system instructions, and a third after shared reference material. When the reference material changes, the tools and system tiers still hit. On Claude 5.5 tiers (Claude Opus 5.5, Claude Sonnet 5.5, and Claude Haiku 5.5), the minimum cacheable prefix dropped to 512 tokens, which means even concise system prompts and lean tool registries now qualify for caching.
The trade-off is bookkeeping. Every code path calling Claude must attach the cache_control markers consistently and respect the Tools -> System -> Messages order. Following Anthropic's Claude prompting best practices, treat every block above a breakpoint as immutable between deploys — a single whitespace edit hashes differently and misses that block and everything after it.
OpenAI's Automatic and Explicit Prefix Caching
OpenAI defaults to zero-config prefix caching across the GPT-6.2 family (GPT-6.2 Astra, GPT-6.2 Sol, plus GPT-6.1 Terra and GPT-6 Luna) on both the Responses API and Chat Completions API. Once a prefix crosses 1,024 visible tokens, OpenAI matches from token zero up to the first point of divergence against active cache entries.
Alongside automatic detection, the Responses API exposes explicit caching controls, including a 12-hour extended TTL (at a 2.5x write rate) alongside the 30-minute standard TTL (at a 1.25x write rate). For enterprise assistants or internal coding agents that see bursts separated by hours rather than minutes, 12-hour retention eliminates repeated cold starts across the workday.
The virtue is low friction: ship a prompt with static developer instructions and sorted tool schemas at the front, and caching engages without annotating individual blocks. The tax is invisible drift. Because matching is strictly byte-for-byte from the start of the request, two microservices serializing the same JSON tool schema with different key orders — or middleware prepending a request ID or timestamp into the developer prompt — silently break caching for everything downstream without throwing an error.
Side-by-Side Comparison (December 2026)
| Dimension | Anthropic (Claude 5.5 / Fable 5.2) | OpenAI (GPT-6.2) |
|---|---|---|
| Activation | Explicit cache_control breakpoints on content blocks | Automatic by default + explicit retention on Responses / Chat Completions APIs |
| Prefix hierarchy | Strict order: Tools -> System -> Messages | Byte-for-byte prefix match from token 0 (static developer/system instructions + tools first) |
| Minimum cacheable length | 512 tokens (Claude 5.5 tiers) | 1,024 visible tokens |
| Standard TTL & write cost | 5-minute default TTL (1.25x input write) | 30-minute standard TTL (1.25x input write) |
| Extended TTL & write cost | 1-hour extended TTL via ttl: "1h" (2x input write) | 12-hour extended TTL on Responses API (2.5x input write) |
| Cache read discount | 0.1x (90% off) standard; 0.05x (95% off) on Opus 5.5 & Sonnet 5.5 | 0.1x (90% off) standard; 0.05x (95% off) on GPT-6.2 Sol & Astra |
| Layering | Explicit multi-breakpoint layering per stability tier | Implicit longest shared prefix up to first divergence |
| Hit telemetry | cache_creation_input_tokens and cache_read_input_tokens in usage | cached_tokens inside input token details in usage |
| Long-context billing note | 1M context on Claude 5.5 & Fable 5.2 (Haiku 5.5 steps up >100K) | 1.05M context on GPT-6.2 (>272K input bills 2x input / 1.5x output) |
December 2026 Cached Pricing Snapshot
Exact economics depend on your model tier, cache hit ratio, and TTL choice. Based on Anthropic's published pricing and OpenAI's API pricing as of December 2026:
| Model | Context Window | Standard Input / Output (per 1M) | Cached Read Rate (per 1M) | Effective Read Discount |
|---|---|---|---|---|
| Claude Fable 5.2 | 1M | $8.00 / $40.00 | $0.20 | 97.5% off input |
| Claude Opus 5.5 (default flagship) | 1M | $4.00 / $20.00 | $0.20 | 95% off (0.05x) |
| Claude Sonnet 5.5 | 1M | $2.00 / $10.00 | $0.10 | 95% off (0.05x) |
| Claude Haiku 5.5 (<=100K) | 1M | $0.10 / $0.50 (>100K: $0.50 / $2.50) | $0.01 | 90% off (0.1x) |
| GPT-6.2 Astra | 1.05M | $8.00 / $40.00 | $0.40 | 95% off (0.05x) |
| GPT-6.2 Sol (everyday flagship) | 1.05M | $2.00 / $10.00 | $0.10 | 95% off (0.05x) |
Notice how quickly cache writes pay back. At a 1.25x standard write rate and a 0.05x read rate (on Opus 5.5, Sonnet 5.5, GPT-6.2 Sol, or GPT-6.2 Astra), the write premium is only 0.25x of one uncached call, while a single hit saves 0.95x — you break even on the very first repeat call. Even on extended TTLs (2x write on Anthropic's 1-hour tier, 2.5x write on OpenAI's 12-hour Responses API tier), two repeat calls within the window put you decisively ahead. For how caching interacts with output budgets and model routing across a full stack, see the token economics guide 2026.
Prompt Structure Implications
Both designs reward identical structural habits, but the flex points sit in different places.
On Anthropic, flex points are wherever you place (or omit) a breakpoint along the Tools -> System -> Messages chain. You can cache tool definitions and system rules on a 1-hour TTL (ttl: "1h") while putting a 5-minute TTL on a per-session document block in messages. If you reorder tools or swap a tool schema mid-session, every downstream breakpoint misses — because tools sit at the very top of Anthropic's cache hierarchy.
On OpenAI, the flex point is wherever two requests diverge byte-for-byte. If your developer instructions and tool list are identical across callers, the cache covers both; if one caller adds a per-user sentence inside the developer block before the tool descriptions, caching truncates right before that sentence. Also watch GPT-6.2's 272K-token input threshold (above which input bills at 2x and output at 1.5x): keeping cached prefixes tight and pruning old conversation turns prevents requests from quietly crossing that cliff.
In both cases, content inside the cached region must be exact token-for-token, not merely semantically equivalent. No timestamps, no trace IDs, no per-user metadata unless your cache is explicitly scoped to a high-frequency single user. The prompt caching guide covers the broader hygiene checklist.
Cache Hit Matching Rules
Both providers scan from token zero until the first mismatch. Four things break matches across both APIs:
- Any character change in the cached region — whitespace, punctuation, JSON key ordering in tool schemas, or dynamically formatted dates.
- Minimum size not met — prefixes under 512 tokens on Claude 5.5 tiers or under 1,024 visible tokens on GPT-6.2 never populate a cache entry.
- Hierarchy or prefix contamination — on Anthropic, mutating a tool schema invalidates System and Messages below it; on OpenAI, an SDK middleware prepending a trace header or rotating prompt fragment silently kills downstream matches.
- TTL expiry or model swap — letting the window elapse without a hit, or changing the pinned model snapshot, resets the cache cold.
TTL Selection and Invalidation
Choosing the right TTL is now an explicit engineering decision on both platforms rather than a fixed minutes-only constraint:
- High-frequency traffic (requests every few seconds to minutes): Use Anthropic's 5-minute default TTL (1.25x write) or OpenAI's 30-minute standard TTL (1.25x write). Frequent hits keep the cache warm without paying the extended write premium.
- Moderate or bursty traffic (10–60 minute gaps): Anthropic's 1-hour extended TTL (
ttl: "1h", 2x write) avoids re-warming every five minutes on active user sessions. - Sparse enterprise or agentic workflows (multi-hour gaps across a workday): OpenAI's 12-hour extended TTL on the Responses API (2.5x write) keeps large static system + tool + handbook prefixes warm all day, paying back its 1.5x extra write premium after just two cache hits.
Invalidation still happens for four reasons on both providers:
- TTL expiry — time window elapsed without refresh.
- Prefix mutation — any edit in or above the cached region.
- Model version swap — switching from one snapshot or tier to another starts cold.
- Capacity eviction — under heavy provider load, cold entries can evict ahead of TTL.
Inspect usage metadata on every response (cache_read_input_tokens / cache_creation_input_tokens on Anthropic; cached_tokens on OpenAI) so you know immediately which of the four bit you.
A Cross-Provider Migration Example
The cleanest way to write prompts that cache reliably on both Anthropic and OpenAI is to standardize on one shared prefix order — Tools, then System/Developer Instructions, then Static Reference Material, then Volatile Per-Call Context — and emit provider-specific cache markers in the adapter layer.
{
"shared_prefix_order": [
"1. Tool definitions (sorted alphabetically by tool name, stable per deploy)",
"2. System / developer identity, guardrails, and JSON output schema (stable per deploy)",
"3. Reference policy summary and ticket taxonomy (stable per week)"
],
"anthropic_adapter_annotation": {
"system_last_block": {
"type": "text",
"text": "<reference_material>...</reference_material>",
"cache_control": { "type": "ephemeral", "ttl": "1h" }
}
},
"openai_adapter_notes": {
"api": "Responses API",
"prefix_rule": "Identical static developer instructions + sorted tools >= 1,024 visible tokens",
"retention": "Standard 30m (1.25x write) or extended 12h (2.5x write) for sparse traffic"
},
"volatile_tail_below_boundary": [
"4. Retrieved user tickets and session metadata (varies per call)",
"5. Current user message (varies per call)"
]
}
On Anthropic, attaching cache_control to the last static block caches everything above it in Tools -> System -> Messages order (down to 512 tokens on Claude 5.5). On OpenAI, keeping those exact static sections byte-identical at the start of the request triggers automatic caching above 1,024 visible tokens, with optional 12-hour retention on the Responses API.
Migration Tips
- Pin byte-for-byte stability in the shared prefix. Strip timestamps, trace IDs, and per-user fields out of system/developer prompts and move them into the user message below the boundary.
- Sort tool definitions deterministically at build time. Alphabetizing tool names and JSON schema keys stops different workers or SDK versions from generating duplicate prefixes.
- Match TTL tier to real inter-arrival times. Measure median gap between calls before paying 2x (Anthropic
1h) or 2.5x (OpenAI12h) write multipliers; default 5-minute / 30-minute windows win whenever calls arrive steadily. - Version prompt edits like schema migrations. Even a one-character change in a cached block invalidates every active prefix; batch copy tweaks and deploy outside peak hours when hit rate drives unit economics.
- Log cache-hit ratios per provider and model. Track
cached_read / total_inputseparately for Claude 5.5 and GPT-6.2 so silent prefix contamination shows up on a dashboard within minutes. - Partition sensitive per-tenant prefixes. Never share tenant-specific reference docs inside a global cached prefix; keep cross-tenant prefixes strictly limited to generic instructions and schemas.
Common Anti-Patterns
- Assuming OpenAI's automatic caching "just handles it" — it matches byte-for-byte prefixes, not equivalent intent. Two services formatting the same prompt with different whitespace or key order miss each other's caches.
- Forgetting Anthropic's
Tools -> System -> Messageshierarchy — placing a dynamic tool list at the top invalidates your carefully markedsystemandmessagesbreakpoints on every single call. - Paying for extended TTLs on high-QPS endpoints — if your endpoint receives traffic every 20 seconds, 1.25x standard writes keep caches warm far more cheaply than 2x or 2.5x extended writes.
- Putting an Anthropic
cache_controlmarker on a per-call block — you pay the 1.25x–2x write multiplier for a prefix nobody will ever read again. - Ignoring long-context step-up cliffs — letting cached multi-turn transcripts cross 100K on Claude Haiku 5.5 ($0.10 to $0.50 input) or 272K on GPT-6.2 (2x input / 1.5x output) quietly erodes caching gains if you do not compact history.
- Conflating prompt caching with response caching — prompt caching skips prefix prefill while still running full generation; semantic/response caching returns a stored answer. See semantic caching vs. prompt caching.
FAQ
Do I need different prompts for Claude and OpenAI to get caching?
Not structurally. The same stable-first, variable-last layout (sorted tools, static system/developer prompt, static reference docs, then volatile context) works on both. Only the adapter layer differs: add Anthropic's cache_control marker on the Claude path, and set Responses API retention parameters on the OpenAI path if you need the 12-hour tier.
Is OpenAI's automatic caching always cheaper than no caching?
Almost always when prefixes repeat — though check the write multiplier on extended tiers. On standard 30-minute caching (1.25x write, 0.05x read on GPT-6.2 Sol and Astra), a single repeat hit clears the write cost and drops prefix spend by up to 95%. If prefixes never repeat within the TTL or stay below 1,024 visible tokens, you should avoid opting into the 2.5x 12-hour write tier.
Does Anthropic charge extra for using cache_control?
Yes on writes, with massive savings on reads. Writing a cache costs 1.25x input on the 5-minute TTL and 2x input on the 1-hour extended TTL (ttl: "1h"). Cache reads then drop to 0.1x (90% off) standard and 0.05x (95% off) on Claude Opus 5.5 ($0.20/M) and Claude Sonnet 5.5 ($0.10/M) — plus $0.20/M on Fable 5.2 and $0.01/M on Haiku 5.5. Never place cache_control on blocks that change every turn.
Can I use both providers in the same pipeline and share a prompt?
Yes, and many production teams route across Claude 5.5 and GPT-6.2 for resilience or task specialization. Keep one canonical template with deterministic tool ordering, render it identically, add Anthropic's cache_control marker in the Claude adapter, and monitor cache-hit ratios per provider independently.
Which provider's caching is better?
Neither in the abstract. Anthropic gives finer multi-tier control and a lower 512-token floor on Claude 5.5 tiers. OpenAI gives zero-config automatic prefix matching above 1,024 tokens plus a 12-hour extended TTL on the Responses API for low-frequency workloads. If you are weighing the two ecosystems more broadly than caching, our breakdown of the best AI model in 2026 compares ChatGPT, Claude, and Gemini head-to-head.
Wrap-Up
By December 2026, both Anthropic and OpenAI deliver up to 95% cache-read savings ($0.10/M on Claude Sonnet 5.5 and GPT-6.2 Sol; $0.20/M on Claude Opus 5.5 and Fable 5.2; $0.40/M on GPT-6.2 Astra), with complementary ergonomics. Anthropic's explicit cache_control breakpoints, strict Tools -> System -> Messages order, and 512-token floor reward teams that layer stability tiers deliberately. OpenAI's automatic prefix caching above 1,024 visible tokens and 12-hour Responses API retention reward teams that want low setup overhead and long-lived enterprise caches. Keep your prefix deterministic, pick the TTL tier that matches your request cadence, and verify hit ratios in telemetry on both paths.
For the general mechanics, see the prompt caching guide 2026. For where caching sits in the cost picture, see the token economics guide 2026. For the adjacent concept people confuse with prompt caching, see semantic caching vs. prompt caching. And for where caching sits in a team's overall context architecture, the Context Engineering Maturity Model treats it as the step from Level 3 to Level 4.