← Blog

Claude API System Prompt Caching: A Practical Guide

2026-10-24 · 5 min read · SubToAPI Team

What Is Prompt Caching in the Claude API?

Prompt caching lets you reuse large, unchanging parts of a request — most commonly the system prompt — across multiple API calls without paying full price or full latency to reprocess them every time. Instead of sending the same 3,000-token system prompt and having Claude re-read it from scratch on every request, you mark it as cacheable once, and subsequent requests that reuse it hit a cache instead of running the full prefill pass.

This matters most when you have a long, stable system prompt (instructions, style guides, tool definitions, retrieved context, few-shot examples) that stays identical across many requests, while only the user message changes. That's the exact pattern behind most production chat apps, support bots, and coding assistants — and it's where prompt caching gives the biggest win.

How Prompt Caching Works

Caching is controlled with a cache_control field attached to a content block in your request. You mark the point in the prompt up to which Claude should cache — a "cache breakpoint" — and the API handles the rest:

{
  "model": "claude-sonnet-4-20250514",
  "system": [
    {
      "type": "text",
      "text": "You are a support agent for Acme Corp. Full policy document here... (3,000 tokens)",
      "cache_control": { "type": "ephemeral" }
    }
  ],
  "messages": [
    { "role": "user", "content": "How do I reset my password?" }
  ]
}

The first request with a given cache breakpoint is a cache write: Claude processes the full system prompt and stores the resulting state. Subsequent requests that send the exact same content up to that breakpoint are cache hits: Claude skips reprocessing and reuses the cached state, which is both cheaper and noticeably faster.

A few things to know:

Why Caching the System Prompt Specifically Matters

System prompts are the most common caching target because:

  1. They're reused verbatim. Unlike conversation history, a well-designed system prompt doesn't change between requests — it's the same instructions regardless of which user is talking.
  2. They're often large. Detailed agent instructions, tool schemas, brand voice guides, or RAG context stuffed into the system prompt can easily run several thousand tokens.
  3. They're on the critical path. Since the system prompt is processed before every response, caching it directly reduces time-to-first-token on every single call.

If your app serves many concurrent users against the same system prompt — a support bot, a coding assistant, an internal tool — caching turns a cost that scales with request volume into a cost that's mostly paid once per cache window.

Combining Caching with Tool Definitions

If you're using tool use, your tool schemas are sent as part of the request on every call too, and they can be just as large as the system prompt. The same cache_control mechanism applies — you can cache the tool definitions block separately from the system prompt, so updating one doesn't invalidate the cache for the other.

{
  "system": [
    { "type": "text", "text": "You are a coding assistant...", "cache_control": { "type": "ephemeral" } }
  ],
  "tools": [
    { "name": "run_tests", "description": "...", "input_schema": { } }
  ],
  "messages": [ ... ]
}

Cache Pricing and TTL Basics

The economics are simple in principle: writing to the cache costs a bit more than a normal request (since you're paying to process and store it), but reading from a warm cache costs significantly less than reprocessing the same tokens fresh. If your system prompt is reused across dozens or hundreds of requests within the cache window, the savings compound quickly — you pay the write cost once and the cheap read cost every time after.

The tradeoff only works if requests are frequent enough to keep hitting the cache before it expires. Low-traffic, bursty, or one-off requests won't see much benefit, and in some cases the extra write cost on a prompt that's never reused again is pure overhead.

When Prompt Caching Doesn't Help

If any of these apply, restructure: move per-user or per-request data into the messages array and keep the system block identical across calls. That alone is often the fix that makes caching actually pay off.

Prompt Caching with SubToAPI

If you're already calling Claude through SubToAPI, caching works the same way — cache_control blocks pass straight through on the messages endpoint, including with streaming responses, so you don't need to change your integration to benefit from it. You get the same latency and cost reduction on cached system prompts, plus SubToAPI's usage metadata on top so you can see cache writes vs. cache hits per application key in your dashboard. Start with the quickstart or check pricing before you sign up.

Best Practices

Questions

Does prompt caching change Claude's responses? No. Caching only affects how the prompt is processed internally for cost and latency — it has no effect on the model's output.

How long does a cached prompt stay valid? Caches are short-lived, typically a few minutes, and the TTL refreshes with each cache hit. Continuous traffic keeps it warm; long gaps let it expire.

Can I cache conversation history, not just the system prompt? Yes — you can add a cache_control breakpoint after any stable block of content, including early turns in a long conversation, not only the system prompt.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →