CloudCodeTree LogoCloudCodeTree
AI NewsTutorialsAbout
CloudCodeTree Logo
CloudCodeTree
  • AI News
  • Tutorials
  • About
← Back to AI News
The 90% Cost Cut You're Leaving on the Table: Claude API Prompt Caching With cache_control

The 90% Cost Cut You're Leaving on the Table: Claude API Prompt Caching With cache_control

Chris Harper

3 min read

Jul 10, 2026 · 12:12 UTC

AI
Workflow
Best Practices
LLM

TL;DR: Mark your system prompt and tool definitions with cache_control to cut input token costs 90% on every Claude API call after the first — the 5-minute default TTL covers agentic loops; add "ttl": 3600 when a human-approval step gaps the session.

If you're calling the Claude API in an agentic loop — where every step re-sends the same system prompt, tool definitions, and possibly a large retrieval context — you're paying full input price on those repeated tokens every call. Prompt caching fixes this with one field.

How it works

The Claude API caches everything up to and including the block you mark with "cache_control": {"type": "ephemeral"}. On the first call you pay a write premium (1.25×); every subsequent call within the TTL that hits the same prefix bills cached tokens at 0.1× — a 90% reduction.

Marking a cache point

import anthropic

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-sonnet-5-20260630",
    max_tokens=1024,
    system=[
        {
            "type": "text",
            "text": "<your full system prompt here>",
            "cache_control": {"type": "ephemeral"}   # caches everything up to here
        }
    ],
    tools=[...],       # placed before the cache point — also gets cached
    messages=[
        {"role": "user", "content": user_message}    # not cached — changes each call
    ]
)

print(response.usage.cache_read_input_tokens)       # tokens served from cache
print(response.usage.cache_creation_input_tokens)   # tokens written to cache this call

When to use each TTL

ScenarioSetting
Agentic loop where steps fire under 5 min apart{"type": "ephemeral"} (5-min default)
Human-approval steps or slow external calls{"type": "ephemeral", "ttl": 3600} (1-hour, 2x write premium)

The 1-hour TTL costs a 2× write premium instead of 1.25×, but pays for itself the moment a single gap between calls would otherwise expire the cache. For a 10,000-token cached prefix on Claude Sonnet 5 ($3/M input), missing one cache window costs $0.03 vs the ~$0.009 extra you pay for the hourly TTL — the math favors the explicit TTL whenever gaps are plausible.

2026 changes to know

Anthropic changed the default TTL from 1 hour to 5 minutes in March 2026. Agent code written before that change may now miss cache windows without explicit "ttl": 3600. Also, since February 2026, caches are per-workspace (not per-org) — teams sharing an Anthropic organization no longer share a cache pool.

Sources: Prompt caching — Claude Platform Docs · 1-hour TTL announcement — Anthropic on X · Prompt Caching Agent Cost Math — exploreagentic.ai