Providers at a glance
Percentages are of the model’s input rate. The models endpoint has the exact rates for every model.
Types of caching
LLM providers use three main approaches:- Implicit caching: the provider automatically caches repeated prompt prefixes, with no code changes or configuration. Requests with matching prefixes are routed to servers that recently processed the same content. This is the simplest approach and is used by OpenAI, DeepSeek, Gemini, and many open-source models (Qwen, MiniMax, and others).
-
Explicit caching: you declare which content to cache using API parameters (such as headers or request body fields), for more control over what gets cached and when. Anthropic uses this model via the
X-Cache-TTLheader. - Storage-based caching: you create managed caches via API that persist for a defined duration, billed per token-hour. This offers the most control but requires cache lifecycle management. Gemini offers this as a separate feature from its implicit caching.
Turn caching on
To start using prompt caching:Implicit caching (OpenAI, DeepSeek, Gemini)
No code changes needed. Caching is automatic for prompts with repeated prefixes. Place static content (system prompts, instructions) at the beginning of your prompt to maximize cache hits. On Gemini, prefix-only caching works on the provider side with no special parameters.Explicit caching (Anthropic)
Add theX-Cache-TTL: 5m header to opt in to caching. System message caching is then automatic, with no content changes.
Improving cache hit rates (OpenAI)
Add"prompt_cache_key": "your-key" to your request body with a stable key that matches your prompt prefix. This improves server routing for requests with shared prefixes.
Provider details
- Anthropic
- OpenAI
- DeepSeek
- Gemini
- Other models
Anthropic uses explicit caching via the
X-Cache-TTL header. You opt in per request by setting the header, and Gloo AI caches your system messages for you, with no changes to your message content.How it works
-
Set the
X-Cache-TTLheader to either"5m"or"1h". -
Add at most three
cache_controlmarkers of your own on your message content. -
If your request already contains four
cache_controlmarkers of its own, your system messages aren’t cached on that call. The request still succeeds with no error. - Keep per-request values (such as timestamps or user-specific data) in the user message, so your system messages stay identical from call to call.
Endpoint behavior
Minimum cacheable token thresholds vary by model (e.g., 4,096 tokens for Claude Haiku 4.5). See Anthropic’s prompt caching docs for current thresholds.
Billing
Cache writes are billed at a multiple of the standard input rate. Cache reads are billed at 10% of the input rate on most Claude models, and less on some newer ones: 5% on Claude Opus 5.5 and Sonnet 5.5, and 2.5% on Claude Fable 5.1. The models endpoint lists the exact rate for each model.
Supported models
Anthropic caching works with all Claude models available through our API. See Supported Models for the current model list.Example
Cost and rates
How total cost is calculated
The formula above applies to all four providers: cached tokens are billed as
a separate
cache_read segment. On a model with no cache write fee, such as
most OpenAI models and the DeepSeek models, the cache_write term is zero.Checking your rates
Use the models endpoint to see current per-model rates:Best Practices
- Static content first: For all providers, place static content (system prompts, instructions) at the beginning of your prompt. This maximizes prefix matches for implicit caching and ensures stable blocks for explicit caching.
- Use explicit caching when available: For Anthropic models, add the
X-Cache-TTLheader to opt in. For OpenAI, useprompt_cache_keyto improve routing for requests with shared prefixes. - Pre-warm on startup: Send an initial request with your standard system prompt to warm the cache before serving users.
- Monitor cache impact: Compare your token usage and billing over time. Effective caching shows up as lower input costs. Check your usage in the Gloo Studio billing dashboard.
- Expect fewer cache hits after failover: Caches are held by each provider, so a request that fails over to another provider does not read the cache built on the original one.
Next steps
Step-by-step tutorial
Restructure a prompt for caching and measure the savings.
Completions V2
Core routing mechanisms and streaming details.
Supported Models
Model IDs, capabilities, and current pricing.
Provider Failover
What happens when the provider serving your model fails.

