Browse docs ▾
API reference

Prompt caching

Reused prompt prefixes - long system prompts, shared context, few-shot examples - can be served from the provider's cache at a steep discount. boldrouter passes caching through and bills cached tokens at the reduced rate automatically.

On by default

Caching is enabled on every request. Providers that cache automatically (OpenAI, Google) need nothing from you; for Anthropic, the gateway adds a cache breakpoint on your system prompt so a reused prefix is cached.

Opt out per request with the x-bold-cache: off header (or "cache": false in the body). Every response echoes x-bold-cache: on / off.

How cached tokens are billed

Cached prompt tokens are billed at a fraction of the normal input rate - each provider's published cache-read price. The rest of the prompt and the completion bill as usual.

FieldTypeDescription
OpenAIopenaiCached input billed at 0.25× the normal input rate (75% off).
AnthropicanthropicCached input billed at 0.1× the normal input rate (90% off).
GooglegoogleCached input billed at 0.25× the normal input rate (75% off).
MistralmistralNo prompt caching.
xAIxaiCached input billed at 0.16× the normal input rate (84% off).
DeepSeekdeepseekCached input billed at 0.02× the normal input rate (98% off).
PerplexityperplexityNo prompt caching.
Z.aizaiCached input billed at 0.25× the normal input rate (75% off).
MiniMaxminimaxCached input billed at 0.2× the normal input rate (80% off).
NVIDIAnvidiaCached input billed at 0.25× the normal input rate (75% off).
QwenqwenCached input billed at 0.25× the normal input rate (75% off).
XiaomixiaomiCached input billed at 0.01× the normal input rate (99% off).
StreamLakestreamlakeCached input billed at 0.2× the normal input rate (80% off).
W&BwandbCached input billed at 0.2× the normal input rate (80% off).
CoherecohereCached input billed at 0.25× the normal input rate (75% off).
InceptioninceptionlabsCached input billed at 0.1× the normal input rate (90% off).
MoonshotmoonshotCached input billed at 0.17× the normal input rate (83% off).
Black Forest LabsbflCached input billed at 0.25× the normal input rate (75% off).
H CompanyhcompanyCached input billed at 0.25× the normal input rate (75% off).
RekarekaCached input billed at 0.25× the normal input rate (75% off).
Google Vertex AIgoogle-vertexCached input billed at 0.25× the normal input rate (75% off).
ArceearceeCached input billed at 0.25× the normal input rate (75% off).
WriterwriterCached input billed at 0.25× the normal input rate (75% off).
ElevenLabselevenlabsCached input billed at 0.25× the normal input rate (75% off).
DeepLdeeplCached input billed at 0.25× the normal input rate (75% off).
LightOnlightonCached input billed at 0.25× the normal input rate (75% off).

Savings show up in your Usage dashboard ("Cache savings") and feed into the same prepaid balance - see Pricing & billing.

Reading cache hits

The response usage reports cached tokens under prompt_tokens_details.cached_tokens, exactly where OpenAI clients expect them:

json
"usage": {
  "prompt_tokens": 4561,
  "completion_tokens": 12,
  "total_tokens": 4573,
  "prompt_tokens_details": { "cached_tokens": 4552 }
}

Getting cache hits

  • Put the stable, reused content first (system prompt, instructions, shared context) and the variable part last. Caches match on a shared prefix.
  • Keep that prefix byte-identical across requests - any change before the cache breakpoint misses the cache.
  • Caches are short-lived (minutes) and have provider minimum sizes (e.g. Anthropic caches only prefixes above a token threshold), so caching helps most for large, frequently-reused prompts.
The first request with a cacheable prefix is a cache write (no discount yet); subsequent requests within the cache window are reads at the discounted rate. You'll see cached_tokens: 0 on the first call and a large value on the next.