Skip to main content

Features

  • Automatic Caching: Automatically identifies repeated context content without changing API call methods
  • Cost Reduction: Input tokens that hit the cache are billed at a lower price, significantly saving costs
  • Speed Improvement: Reduces processing time for repeated content, accelerating model response
This mechanism is particularly suitable for the following scenarios:
  • System prompt reuse: In multi-turn conversations, system prompts typically remain unchanged
  • Fixed tool lists: Tools used in a category of tasks are often consistent
  • Multi-turn conversation history: In complex conversations, historical messages often contain a lot of repeated information
Scenarios that meet the above conditions can effectively save token consumption and speed up response times using the caching mechanism.

Code Examples

Install SDK
Environment Variable Setup
See Configure Environment Variables.First Request - Establish Cache
Second Request - Reuse Cache
Response includes context cache token usage information:

Important Notes

  • Caching applies to API calls with 512 or more input tokens
  • Caching uses prefix matching, constructed in the order of “tool list → system prompts → user messages”. Changes to any module’s content may affect caching effectiveness
  • Supported models: MiniMax-M3.1-Flash, MiniMax-M3, MiniMax-M2.7 series, MiniMax-M2.5 series, MiniMax-M2.1 series

Best Practices

  • Place static or repeated content (including tool list, system prompts, user messages) at the beginning of the conversation, and put dynamic user information at the end of the conversation to maximize cache utilization
  • Monitor cache performance through the usage tokens returned by the API, and regularly analyze to optimize your usage strategy

Pricing

Prompt caching uses differentiated pricing:
  • Cache hit tokens: Billed at discounted price
  • New input tokens: Billed at standard input price
  • Output tokens: Billed at standard output price
See the Pay as You Go pricing page for details.
Pricing formula:
Cache hit tokens are returned in the response usage:
  • Anthropic-compatible API: usage.cache_read_input_tokens; usage.input_tokens is the number of new input tokens
  • OpenAI-compatible API: usage.prompt_tokens_details.cached_tokens; usage.prompt_tokens is the total number of input tokens