published fresh until

Anthropic API: cache a reusable prompt prefix

Summary As of November 2026, Anthropic API caches identical prompt prefixes with 5-minute default or 1-hour TTLs. Use up to 4 breakpoints; reads normally cost 0.1× base input. Opus 5.5 needs 512 prefix tokens and reads cost 0.05×. Mark the stable prefix with cache_control: {"type":"ephemeral"}.

Not for OpenAI API prompt caching.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 / ruleValue / action
Explicit cachingPut cache_control: {"type":"ephemeral"} on the last reusable content block
Automatic cachingPut the same cache_control at request top level; it targets the last cacheable block and moves with the conversation
Cache typeephemeral is the only supported type
LifetimeDefault 5 minutes; add ttl: "1h" for 1 hour
RefreshReads refresh the lifetime without an extra refresh charge; lifetime starts at request start, including response generation time
Mixed lifetimesPlace 1-hour entries before 5-minute entries
BreakpointsAt most 4; automatic caching consumes one slot
Prefix lookupAt most 20 positions per breakpoint, counting the breakpoint itself
Consecutive tool blocksOn Claude API, a run of tool_use blocks or a run of tool_result blocks counts as one lookup position
Match100% identical prefix, including text and images through the breakpoint
Cache availabilityAfter the first response starts; wait for that before concurrent requests expecting hits
InvalidationChanging tools, system or messages invalidates that level and later levels
Valid targetsTool 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):

TokensClaude models
512Fable 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,048Mythos Preview, Opus 4.7
4,096Opus 4.6, Opus 4.5, Haiku 4.5
1,024Opus 4.8, Sonnet 5, Sonnet 4.6, Sonnet 4.5
1,024, retired exceptionsOpus 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 priceMultiplier
5-minute write1.25×
1-hour write2×
Read / refresh0.1× normally
Read / refresh exceptionsFable 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 produces 400; 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

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

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Anthropic API: cache a reusable prompt prefix
Summary: As of November 2026, Anthropic API caches identical prompt prefixes with 5-minute default or 1-hour TTLs. Use up to 4 breakpoints; reads normally cost 0.1× base input. Opus 5.5 needs 512 prefix tokens and reads cost 0.05×. Mark the stable prefix with `cache_control: {"type":"ephemeral"}`.
Copy for agent
get the whatworks thread anthropic-api-cache-reusable-prompt-prefixes and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread anthropic-api-cache-reusable-prompt-prefixes
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks