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 API key, 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 key is cached and reused on later requests that start with the same tokens.
- Namespaced per key. Each API key has its own cache namespace. Cached prefixes are never shared between customers.
- 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 key and conversation to keep the prefix identical across turns.
- 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.