Skip to content

Caching in Shared Models

During a typical multi-stage conversation with an LLM, each time you send a new message the model has to consider both your new message and all the previous messages or documents in the conversation.

Because the earlier parts of your conversation don’t change, the state of the model after each message can be saved and reused, which makes answering each new message faster.

This is also called “KV caching” or “prompt caching” by other providers.

A shared model serves many customers at once. As with any shared web service, requests from multiple customers ultimately run on the same hardware. Caching is one of the places where Think isolates customers from each other: caches can only ever be reused inside the Project that created them. This page explains how cache usage is reported, when caches can be shared, what an attacker could and couldn’t learn from them, and how to control caching.

Responses from Shared Models contain a usage key which describes the number of input and output tokens used, including whether input tokens were retrieved from the cache.

For example, after calling https://models.think.evroc.com/v1/chat/completions

{
[...]
"usage": {
"prompt_tokens": 74,
"total_tokens": 138,
"completion_tokens": 64,
"prompt_tokens_details": {
"cached_tokens": 40
}
}
}

In this case, the first 40 tokens in the prompt were retrieved from the cache.

Reduced billing applies for tokens retrieved from cache.

There is no guaranteed lifetime for caches (and hence whether a subsequent request can take advantage of caching). Typical lifetimes are minutes to hours.

Cache sharing only applies when all of these conditions hold:

  • The API keys of the requests belong to the same evroc Project.
  • The beginning (the prefix) of the messages is exactly identical, message by message, from the first message.
  • For embedding and reranking requests, cache sharing can also apply when one of the documents in the request is identical.
  • For more detail, see the Controlling Caching section.

Caches are never shared across customer boundaries. A cache entry created in one Project can’t be reused by a request from another Project, even when the request content is identical.

The sequence must match from the beginning: a message in the middle of one conversation that happens to match a message in the middle of another conversation doesn’t share a cache. Prefix matches matter most in two situations: prompts that many requests start with (a shared system prompt, a document kept at the start of the context), and long conversations where each turn repeats all previous content.

Transcription models don’t use caching.

A cache entry is the internal state of the model after ingesting your text — the tensors the model computed, not a copy of the messages. It can’t be used to recover the original message content.

Caches are stored only on the machine running the LLM model.

The principal attack possible against caches is a timing one, and it stays inside your Project: an API key belonging to the same Project can guess the start of another user’s conversation, send it, and infer from the response time whether another user in the Project has recently started a conversation identically — a cache hit comes back faster. It doesn’t leak the message content, but it does leak the fact that a matching prefix exists. The attack doesn’t work from outside the Project, because caches are never shared across customer boundaries.

If users within your Project shouldn’t be able to infer anything about each other’s prompts, scope cache reuse to each user — see controlling caching.

Caching can’t be turned off for individual requests. Currently all non-transcription models are served with caching enabled.

What you can control is who your caches can be shared with. Our OpenAI-compatible endpoints use the following fields in the request body (if set) — requests that differ in either of them never share caches:

  • user
  • prompt_cache_key

The following requests will not share caches, despite using the same API key and project:

Terminal window
curl https://models.think.evroc.com/v1/chat/completions \
-H "Authorization: Bearer $EVROC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zai-org/GLM-5.3",
"user": "tenant-1",
"messages": [{"role": "user", "content": "Tell me a story."}]
}'
curl https://models.think.evroc.com/v1/chat/completions \
-H "Authorization: Bearer $EVROC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zai-org/GLM-5.3",
"user": "tenant-2",
"messages": [{"role": "user", "content": "Tell me a story."}]
}'

You can de facto disable cache reuse for a single request by setting prompt_cache_key to a random value you throw away. For another request to reuse that cache, it would have to be an exact prefix match, in the same Project, and carry the same random prompt_cache_key — a fresh random value makes that impossible. The cache entry still exists in memory on the model machine until it’s evicted: a random cache key stops reuse, not residency.