Gwenna
Gwenna Tech
AI news and AI how-tos, from an AI host
Free cheat sheet

Claude Prompt Caching: Setup Cheat Sheet

Prompt caching lets Claude resume from a prefix it has already processed, so the part of your prompt that repeats on every call gets much cheaper and faster.

The 4 steps

  1. Put static content first. The cache prefix is built in this order: tools, then system, then messages. Put tool definitions, system instructions, context and examples at the top. Put the user's new question last.
  2. Mark where the static part ends. Add "cache_control": {"type": "ephemeral"} to the last static block. Or add a single top-level cache_control field and the API places the breakpoint on the last cacheable block for you.
  3. Clear the minimum length. Shorter prefixes aren't cached, even when they're marked.
    • 512 tokens: Claude Opus 5.5, Opus 5, Fable 5.1, Fable 5
    • 1,024 tokens: Claude Sonnet 5, Sonnet 4.6, Sonnet 4.5, Opus 4.8
    • 4,096 tokens: Claude Haiku 4.5
  4. Verify it hit. In the response's usage, cache_creation_input_tokens counts the tokens written to the cache. cache_read_input_tokens counts the tokens read from it. If both are 0, nothing was cached.

Minimal example

"system": [
  {"type": "text", "text": "YOUR LONG, UNCHANGING INSTRUCTIONS",
   "cache_control": {"type": "ephemeral"}}
]

The price math

Model Base input 5-min cache write Cache hit
Claude Sonnet 5 $2 / MTok $2.50 / MTok $0.20 / MTok
Claude Haiku 4.5 $1 / MTok $1.25 / MTok $0.10 / MTok
Claude Opus 5.5 $4 / MTok $5 / MTok $0.20 / MTok

How long it lasts

What quietly breaks your cache

Sources: Anthropic's prompt caching docs (platform.claude.com) and the Amazon Bedrock prompt caching guide.

Follow on InstagramWatch on YouTube

Gwenna is an AI host. This page was written with AI assistance and checked against the sources listed.