Skip to main content
Prompt caching saves processing time by caching computed results for repeated prompt prefixes – not the prompt text itself, but the work done to process it. When multiple requests share the same opening text – like a system prompt or document – SambaNova serves the cached result instead of reprocessing those tokens from scratch. The first few requests populate the cache on the serving node(s); savings build up as your prefix is observed multiple times. For sustained traffic, hit rates typically reach 90%+ once the prefix has been seen a few times.
Prompt caching is available on MiniMax-M2.7 on SambaCloud. Automatic Prefix Caching (APC) is enabled by default – no changes to your request are required.

When to use prompt caching

Prompt caching delivers the most savings when a large portion of your input is repeated across requests: If cached_tokens stays at 0 across requests, your inputs do not share a cacheable prefix – check whether your system prompt or context block is stable across calls.

How it works

Automatic Prefix Caching (APC) is always on for MiniMax-M2.7. It detects shared prefixes across requests and reuses cached computations transparently – no API changes required. Keep the leading portion of your messages stable and consistent across requests to maximize cache hits. A prefix is matched when the leading token sequence of the messages array is identical to a cached request. Any change to the prefix – rewording the system prompt, inserting a message before it, or reordering content – starts a new cache entry. Changing only the user message while keeping the system prompt identical reuses the cached prefix. Cache state is local to each serving instance. On multi-instance deployments, your prefix is cached independently on each instance after it is served there.

Read cache usage from the response

Every response includes a prompt_tokens_details object showing how many tokens were served from cache:
cache_creation_tokens is non-zero on the first request that builds the cache entry and 0 on subsequent cache hits. The number of non-cached input tokens is prompt_tokens - cached_tokens.

Billing

Cached tokens are billed at a lower rate than standard input tokens. The full pricing for your model – including the cached input rate and cache write rate – is available via the /v1/models endpoint and on the SambaCloud pricing page.
The billing formula for a cache-enabled request:
For example, a request with 5797 total input tokens where 4096 are served from cache: only 1701 tokens are billed at the standard input rate, and 4096 at the lower cached rate. Output billing is unchanged.

Code example

Caching activates only when the shared prefix reaches 4096 tokens. The system prompt below is shorter for readability – replace it with your actual document to observe cache hits in practice.

Limitations

  • Prompt caching is available on MiniMax-M2.7 only. Other models return cached_tokens: 0.
  • Cache state is local to a single node and is not shared across nodes.
  • Maximum cacheable prefix length: 192000 tokens.
  • A prefix must contain at least 4096 tokens to qualify for caching.
  • Cache eviction uses an LRU (least recently used) policy. Cache persistence varies with system load and is not guaranteed.