← Guides
how-to · 4 min

Prompt caching: the first lever to pull on a RAG bill

If your requests share a long opening block - a system prompt, a document, a tool schema - you are paying full price to recompute it every call. Here is how much caching saves and how to turn it on.

Obolith · Last updated: 2026-09-10

Most teams reach for a cheaper model first. For rag and agent workloads that is the wrong first move. The bigger, easier win is prompt caching: stop paying to recompute the part of your prompt that never changes.

Why it works

When request after request starts with the same block - a system prompt, a style guide, a retrieved document, a set of tool definitions - the model does the exact same work on that block every time. If the provider stores the computed state of that prefix, a later request that matches it skips straight to the new part.

You pay a small one-time "cache write" fee, then a cache read rate of roughly 10-25% of the normal input price on every call that hits the cached prefix, within a short time window (usually 5 minutes to an hour).

How much it saves

For a typical RAG call, the repeated prefix - system prompt plus retrieved context - is 80-95% of the input tokens. The answer itself is small. So caching that prefix takes most of the input cost to near-zero.

worked example

4,000 input tokens/call, 3,600 of them a stable prefix

without cache: 4,000 × $0.50/1M ........ $0.0020 / call

with cache: 400 × $0.50 + 3,600 × $0.075 $0.0005 / call

-> the input line drops ~75%

For agents it is even larger, because the growing conversation history is re-sent every step and most of it is unchanged from the last one.

How to turn it on

  • Anthropic - add cache_control breakpoints in the request; up to 4 cached segments.
  • OpenAI - automatic for prompts over 1,024 tokens, no code change; the discount applies to the matched prefix.
  • Google (Gemini) - explicit context caching via the API, or implicit caching on newer models.
  • Open-source servers (vLLM, TGI, SGLang) - prefix caching is on by default when you self-host.

The one rule: put the stable content first (system prompt, documents, tool schemas) and the variable content last (the user turn). A cache only matches from the start of the prompt, so a changing token near the top invalidates everything after it.

When it does not help

Short prompts (a plain chatbot with a one-line system prompt), or workloads where every request is genuinely unique with no shared prefix. And a model with no cache pricing at all - Obolith's pricing table shows the cache-read rate where the provider offers one.

See which models have cached-input pricing →Model the saving for your workload →

Figures are illustrative. Confirm current prices on the provider’s own site before deciding.