We earn a reward if you sign up to SayGM through our links. Your price is the same.
LessPerToken

Claude prompt caching not working? How to fix it on OpenRouter, Bedrock and the Anthropic API

OpenAI, DeepSeek and Gemini cache a repeated prompt on their own. Claude doesn't: it only caches when the request asks for it. So the most common reason Claude caching "isn't working" is that nothing ever turned it on. Here's how to check, the five usual causes, and the fix for each route.

We found this exact problem in two popular open-source projects: browser-use caches Claude only on the direct Anthropic API, and mem0 never caches it.

1. Check whether anything is cached

Every route reports cache reads in the response. If this number stays at 0 across repeated calls with the same long prompt, nothing is being cached.

RouteCache readsCache writes
Anthropic APIusage.cache_read_input_tokensusage.cache_creation_input_tokens
OpenRouterusage.prompt_tokens_details.cached_tokensusage.prompt_tokens_details.cache_write_tokens
Bedrock (Converse)usage.cacheReadInputTokensusage.cacheWriteInputTokens

One thing that confuses people: on Anthropic and Bedrock, input_tokens / inputTokens don't include cached tokens. Total input is reads plus writes plus input tokens.

2. The five usual causes

Nothing asked for caching

Claude needs a cache_control marker (Bedrock's Converse API calls it a cachePoint). Libraries and frameworks often add it for one route and not others, or not at all. If you call Claude through a wrapper, check what it actually sends.

The prompt is below the minimum

Prompts shorter than the model's minimum are simply not cached, with no error. The minimum is 512 tokens on Claude Fable 5.2 and the 5.5 models, and up to 4,096 tokens on some older models. The minimum counts the whole prompt up to the cache marker.

Something changes before the cache marker

The cache only matches an identical start of the prompt, in the order tools, then system, then messages. Anything that differs earlier breaks everything after it:

  • a timestamp, request ID or user name in the system prompt
  • tool definitions that change between calls (this invalidates the whole cache)
  • switching tool_choice, or adding or removing images (invalidates the messages part)
  • JSON whose key order isn't stable

Put stable content first and anything that changes per request after the marker.

The cache expired

The default cache lives five minutes and resets on each hit. If calls are further apart, every call writes a new cache and none reads it. A one-hour cache is available ("ttl": "1h"), but writing it costs twice the input price instead of 1.25 times.

You're reading the wrong number

See the table above: a low input_tokens with a high cache-read count is caching working, not a bug.

3. The fix for each route

Anthropic API

The simplest option is automatic caching: one top-level cache_control, and Claude places the marker on the last block it can cache.

response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    cache_control={"type": "ephemeral"},
    system=LONG_SYSTEM_PROMPT,
    messages=messages,
)
print(response.usage.cache_read_input_tokens)

OpenRouter

OpenRouter accepts the same top-level cache_control for Claude. With the OpenAI SDK, pass it through extra_body:

client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=OPENROUTER_KEY)
response = client.chat.completions.create(
    model="anthropic/claude-sonnet-5.5",
    messages=messages,
    extra_body={"cache_control": {"type": "ephemeral"}},
)
print(response.usage.prompt_tokens_details.cached_tokens)

For finer control, put the marker on a content block instead (up to four per request):

{"role": "system", "content": [
    {"type": "text", "text": LONG_SYSTEM_PROMPT,
     "cache_control": {"type": "ephemeral"}}
]}

Amazon Bedrock

With the Converse API, add a cachePoint after the content to cache:

response = bedrock.converse(
    modelId=MODEL_ID,
    system=[{"text": LONG_SYSTEM_PROMPT},
            {"cachePoint": {"type": "default"}}],
    messages=messages,
)
print(response["usage"].get("cacheReadInputTokens"))

With InvokeModel and the Anthropic request format, put "cache_control": {"type": "ephemeral"} on a content block, as on the Anthropic API. Use explicit markers on Bedrock: AWS lists automatic caching for newer Claude models, but Anthropic's docs say a top-level cache_control returns an error there, so don't rely on it.

What it saves

A cache read costs a tenth of the normal input price on most Claude models, a twentieth on Claude Opus 5.5 and Sonnet 5.5, and a fortieth on Claude Fable 5.2. Writing the cache costs 1.25 times the input price for the five-minute cache. So any prompt you resend more than once within five minutes is cheaper cached.

On Claude Sonnet 5.5 at list price that's $0.10 instead of $2.00 per million input tokens. For an agent that resends a 30,000-token prompt on every step, that is most of the bill.

Checklist

  • Cache reads above 0 on the second identical call?
  • Prompt above the model's minimum (512 tokens on the 5.5 models)?
  • Nothing that changes per request before the cache marker?
  • Calls less than five minutes apart, or a one-hour cache?

Want someone to check your code for this and the other usual leaks? Get a free cost audit of your repo, or run the free LLM cost audit skill yourself. And once caching works, compare where Claude is cheapest.

Sources: Anthropic prompt caching docs, OpenRouter prompt caching docs, AWS Bedrock prompt caching docs, all checked 29 November 2026.

Pay less for the same models

One URL change. Keep OpenRouter as your backup.

Try SayGM