For AI agents, the documentation index lists all pages. Append .md to a documentation URL for Markdown, or request text/markdown.

Skip to Content
spare inference

Prompt caching

Repeated prompt prefixes are served from a provider's cache and billed at the cached input price.

1 min readEdit this page

Input, cached input and output are priced separately. Cached input is input a provider served from its prompt cache, and repeated prefixes are cached for you. See Pricing for the prices.

How caching works

Which requests are cached, the minimum prefix length, how long an entry lasts, and whether you need to do anything to turn it on.

Make requests cache better

How to order a prompt so the repeated part comes first, and what breaks a cache hit.

Caching across providers

Each provider keeps its own cache, so a request that falls back to another provider (see Reliability) may not hit the cache. How this shows up in your cost.

See what was cached

Where cached tokens appear in a request's settlement and in usage.

How is this guide?