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:| Good fit | Poor fit |
|---|---|
| Long system prompt shared across all user turns | Fully unique inputs per request (no shared prefix) |
| Repeated few-shot examples or tool definitions | Very short prompts where savings are negligible |
| RAG context re-sent with each query | Single-use documents where the prefix never repeats |
| Multi-turn conversations with a fixed preamble |
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 aprompt_tokens_details object showing how many tokens were served from cache:
| Field | Description |
|---|---|
cached_tokens | Tokens served from cache. Billed at the cached input rate (lower than standard). |
cache_creation_tokens | Tokens written to cache on this request. Informational only – no additional charge. |
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.
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.

