Skip to main content
Prompt caching allows providers to reuse previously processed prompt content. When the beginning of your prompt matches a previously cached prefix, the provider skips reprocessing those tokens — reducing both cost and latency significantly.

Inspecting Cache Usage

Cache usage is reflected in the usage object of every response:

OpenAI Automatic Caching

OpenAI caches prompt prefixes automatically. No special request configuration is needed. How it works:
  • Caching happens server-side at OpenAI, triggered automatically when prompts are long enough
  • Minimum prompt length: 1,024 tokens
  • Cache entries expire after ~1 hour of inactivity
  • Cached tokens are charged at a reduced rate (typically 50% discount)

Anthropic Claude Prompt Caching

Anthropic supports two caching modes:
  • Automatic caching (default): Claude caches the system prompt automatically. Minimum 1,024 tokens.
  • Explicit caching (cache_control): You mark specific content blocks with "cache_control": {"type": "ephemeral"} to control exactly what gets cached.

Cache TTL

Supported Models

Explicit Caching Example

Mark content with cache_control to control caching at the content-block level:
For the OpenAI-compatible endpoint, pass via extra_body:

DeepSeek Automatic Caching

DeepSeek caches prompt prefixes automatically, similar to OpenAI. No configuration needed.

xAI (Grok) Automatic Caching

Grok models cache prompt prefixes automatically when the same prefix is reused across requests. No special configuration is required.

Groq Automatic Caching

Groq’s inference infrastructure caches prompt prefixes automatically for supported models. Cache hits reduce latency and are reflected in the response usage object.

Google Gemini Prompt Caching

Gemini supports both implicit (automatic) and explicit caching.

Implicit Caching

Gemini 2.5 Flash and Pro cache large contexts automatically at no extra cost. Cache hits are visible in the response usage.

Explicit Caching via Native Gemini API

For fine-grained control, use the native Gemini cachedContents API. You create a cache object and reference it in subsequent requests:
Use the native Gemini endpoint via ARouter’s provider proxy to work with cached content:
The response includes a name field (e.g., cachedContents/abc123) you reference in subsequent requests:
Cache usage appears in the response:

Provider Sticky Routing

To maximize cache hits, your repeated requests should reach the same provider instance. ARouter supports sticky routing to ensure this for providers that require it. When you include Anthropic cache_control blocks in your request, ARouter automatically routes subsequent requests with the same prefix to the same provider endpoint, preserving cache validity.

How Sticky Routing Works

  1. Your first request with a cache_control block is processed and cached at the provider
  2. ARouter records which provider instance handled the request
  3. Subsequent requests with the same cache prefix are routed to the same instance
  4. Cache hits lower your cost (reads are cheaper than writes) and reduce latency

Verifying Cache Hits

Check the usage object to confirm cache hits across requests:

Provider Cache Support Summary