---
title: "Claude Prompt Caching: 6 Tricks That Cut Your API Bill"
subtitle: "Breakpoints, TTL math, Batch stacking, and a two-session split. Measured on OpenRouter, $0.003 vs $0.022 per turn"
url: "https://alphasignal.ai/news/claude-prompt-caching-6-tricks-that-cut-your-api-bill"
author: "Adham Khaled"
author_url: "https://alphasignal.ai/author/adham__khaled__"
published: "2026-09-09T16:00:00.000Z"
updated: "2026-09-09T13:34:52.327Z"
type: "Tutorial"
topics:
  - "Infra"
  - "Agents"
  - "Business"
subtopics:
  - "Inference Optimization"
  - "Monitoring"
upvotes: 4
comments: 0
truncated: true
---

# Claude Prompt Caching: 6 Tricks That Cut Your API Bill

> Breakpoints, TTL math, Batch stacking, and a two-session split. Measured on OpenRouter, $0.003 vs $0.022 per turn

Automatic caching billed us $0.022 per turn for the same 8,400 tokens that cost $0.003 once we placed the cache marker by hand.

And as far as we know, Anthropic's **automatic caching** means one switch (the system decides what to save) but **manual caching** means you mark the exact caching point with `cache_control`.

So with the same model, the same afternoon, the six checks below decide whether the tokens you already paid for get re-read for pennies or re-billed at full price. And every one comes with code you can paste plus the meter reading that proves it worked.

Here is the whole game in four objects:

* Your conversation history is the context window: everything the model must re-read before answering.
* The saved copy of that history is the KV cache.
* A reuse of the copy is a hit at roughly a tenth of the price.
* A rebuild from scratch is a miss at full price plus a write fee.

So they're history, saved copy, hit, miss, and also the lunch (when you go away for a while) which is the enemy, because the copy expires after five minutes unless you pay to keep it longer.

My last piece showed why the bill grows the way it does. Models re-send history every turn, so cost climbs with the square of the session, and walking away can cost more than the afternoon you just worked ([Coding Agent Cost: Why Sessions Get Expensive](https://alphasignal.ai/news/coding-agent-cost-why-sessions-get-expensive)).

From the other side, the routing companion proved the same point. One mid-session model switch cost 5 to 11 times a warm turn ([Model Routing Layers and the Prompt Cache Tax](https://alphasignal.ai/news/model-routing-layers-and-the-prompt-cache-tax)). This is the sequel that tells you what to type.

What follows is the breakpoint rule, the TTL (Time to Live) math, the prove-it meter, the Batch double-dip, the two-session split, and the thinking cap. Each trick has Python, cURL, a dollar figure from list prices or my own runs, and the exact usage field to read.

![](https://imagedelivery.net/kokADdxuw1FCXyR2p8D2CQ/9f3325d4-5e43-482c-7295-04a018acc500/public)

## Where does the breakpoint go?

A breakpoint is a sticky note that instructs Anthropic to cache everything above this line. When you tell the Claude API to cache your prompt, it evaluates the exact sequence of digital bytes above the breakpoint. If a single character changes in the text you are trying to save, the system treats it as an entirely new document and charges you accordingly.

![](https://imagedelivery.net/kokADdxuw1FCXyR2p8D2CQ/498c41ae-66a6-4f45-d9a0-b3f182e67c00/public)

Anthropic's docs have an example where they put the breakpoint on a block holding a timestamp that changes regularly. Every request writes a new cache entry keyed on a new hash, so you pay the write fee every turn and read nothing, ever.

I ran that exact mistake against the fix on Sonnet 5 with an 8,400-token prefix. The trap billed $0.02243 a turn with zero tokens read.

Against the fix, the same bytes billed $0.00299 with 8,427 tokens read. Six checks each, and not one crossed over.

So the mechanical rule is to find the longest prefix that stays byte-identical across your requests, system instructions through stable brief, and put `cache_control` there. Then let the timestamp, the user message, and the run ID live below it, uncached and changing freely.

```
import anthropic

client = anthropic.Anthropic()

SYSTEM_PREFIX = open("system-brief.txt").read()  # stable bytes, no clocks

resp = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=512,
    system=[
        {"type": "text", "text": SYSTEM_PREFIX,
         "cache_control": {"type": "ephemeral"}},
    ],
    messages=[{"role": "user", "content": "summarize ticket-4821"}],
)
print(resp.usage.cache_read_input_tokens,
      resp.usage.cache_creation_input_tokens)
```

```
curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 512,
    "system": [{"type": "text", "text": "YOUR STABLE PREFIX",
                "cache_control": {"type": "ephemeral"}}],
    "messages": [{"role": "user", "content": "summarize ticket-4821"}]
  }'
```

And here is the twist my runs forced into this piece. The fully automatic mode, one top-level `cache_control` field and no placement thinking, billed $0.02237 with zero reads across all six checks.

Automatic caching parks its breakpoint on the last block, which is your varying message, so it falls into the same trap with better marketing. It only helps chats that grow by appending, where each turn's new last block still finds the earlier write inside its 20-block lookback.

Four breakpoints, a 20-block lookback, and a per-model floor make up the whole rulebook. Opus 5 starts at 512 tokens, Sonnet 5 at 1,024, Haiku 4.5 at 4,096, per Anthropic's cache docs.

Below the floor the request runs full price with no error, so a short hot prefix is worth padding past the line. Also keep the prefix out of the rewrite-every-turn habit. A `CLAUDE.md` that injects `git status` or the clock is a miss engine wearing a config file as a disguise.

![](https://imagedelivery.net/kokADdxuw1FCXyR2p8D2CQ/2af36b2b-c8d9-4b59-2a3a-c455a0b51300/public)

OpenAI delta: same rules, different buttons. Nothing needs placing, and the minimums idea and suffix discipline transfer.

Check it with the meter. `cache_read_input_tokens` above zero means the trick landed. Both fields at zero means something upstream varies that you have not found yet.

## Buy the right TTL, not the longest one

TTL (Time to Live) is how long the saved copy lives, a parking meter for your prefix. Anthropic has two options for caching life. Per [their pricing page](https://platform.claude.com/docs/en/about-claude/pricing), the five-minute cache charges 1.25 times the base input price when writing the cache. They also have a longer one-hour caching option, which charges double the base price.

_Preview only. Full text requires an AlphaSignal Pro account._

## Sources

- [Anthropic prompt caching docs](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)
- [Anthropic pricing (cache \+ Batch)](https://platform.claude.com/docs/en/about-claude/pricing)
- [Anthropic Batch API](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
- [Anthropic thinking docs](https://platform.claude.com/docs/en/build-with-claude/thinking)
- [Claude Code prompt caching](https://code.claude.com/docs/en/prompt-caching)
- [OpenRouter prompt caching](https://openrouter.ai/docs/guides/best-practices/prompt-caching)
- [OpenRouter models/prices](https://openrouter.ai/api/v1/models)
- [Coding-agent cost, part 1](https://alphasignal.ai/news/coding-agent-cost-why-sessions-get-expensive)
- [Routing layers and the cache tax](https://alphasignal.ai/news/model-routing-layers-and-the-prompt-cache-tax)
