Reduce latency for repeated prompts with prefix caching, and isolate cache reuse with cache_salt when needed.
Serverless Inference uses prefix caching on supported hosted models to speed up repeated requests with identical prompt prefixes.When a request shares the same prompt prefix as an earlier request on the same backend, the model reuses the previously computed key-value (KV) cache instead of recomputing the entire prefix. This reduces latency for repeated prompts, long system prompts, and workloads with a stable shared prefix.Prefix caching is automatic on supported models, so you don’t need to enable it in your request. This page describes when prefix caching is most effective and how to control cache isolation with cache_salt.
In some environments, you might need to prevent cache reuse across different users or applications. The cache_salt parameter provides this control.By default, requests with identical prompt prefixes may reuse cache on shared infrastructure when the backend allows it.To isolate cache reuse to a specific trust boundary, set the cache_salt request parameter. Requests only reuse prefix cache when both the prompt prefix and the cache_salt match.Use cache_salt when you want cache reuse within a single user, tenant, session, or application boundary, but don’t want reuse across other callers.
To confirm that prefix caching is active for a request, check the response usage details. On some models, usage details may include cached token counts in usage.prompt_tokens_details.cached_tokens when prefix cache is reused. The availability of that field varies by model and backend.