Prompt caching
Automatic prefix caching that lowers the cost of repeated context on every model.
Prompt caching is automatic and available on every model. When a request shares a prefix with an earlier request from the same account, the shared portion is read from cache and billed at the model's cache read rate instead of the full input rate.
Why it matters
Coding agents resend a large, stable prefix on every turn: system prompts, tool definitions, and file context. Caching that prefix changes the cost profile of a session substantially. Cache read rates are a small fraction of input rates. Compare them per model on the Models page.
How it works
- Automatic. No request parameters are required. Send your prompt as usual.
- Prefix-based. The longest stable prefix seen for the user is cached and reused on later requests that start with the same tokens.
- Namespaced per user. The cache is scoped to your account, not to individual API keys. Multiple keys on the same account share one cache namespace, and cached prefixes are never shared between customers.
- Per model. Each model has its own cache. Prefixes cached for one model are never reused on another model.
- Billed on read. Cached tokens are charged at the cache read rate; only the uncached portion is charged at the input rate.
Getting the most from caching
- Keep the stable parts of a prompt at the start (system prompt, tools, reference files) and put changing content at the end.
- Reuse the same account and conversation to keep the prefix identical across turns. Any key on the account hits the same cache.
- Prefer one long session over many short ones when the prefix repeats.
Billing
Cache reads appear as their own rate on the Models page and are deducted from the same spend balance as other inference. See Plans and billing for how spend is metered.