> ## Documentation Index
> Fetch the complete documentation index at: https://platform.kimi.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Use the Context Caching Feature of Kimi API

Context Caching is an efficient data management technique that allows the system to pre-store large amounts of data or information that may be requested frequently. When you request the same information again, the system can serve it directly from the cache without re-computing or retrieving from the original data source, saving time and resources.

In the Kimi API, Context Caching is **automatically enabled for all model requests** without manual creation or management. When the system detects repeated initial contexts (such as system prompts, knowledge documents, tool definitions, etc.), it automatically reuses cached content, bringing you cost optimization and faster response times.

Context Caching is especially suitable for scenarios with **frequent requests and repeated references to a large initial context**, such as:

* QA bots that provide extensive preset content, such as product documentation assistants.
* Frequent queries against a fixed document collection, such as public disclosure Q\&A tools for listed companies.
* Periodic analysis of static codebases or knowledge bases, such as various Copilot Agents.
* Viral AI applications with sudden traffic spikes.
* Agent applications with complex interaction rules.

## Context Caching vs. RAG

RAG (Retrieval-Augmented Generation) is widely used in the industry for cost reduction in long-text scenarios. The main differences between Context Caching and RAG are:

| Dimension        | Context Caching                                                                                           | RAG                                                                                                                           |
| ---------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Business cost    | Highly dependent on business characteristics; in specific scenarios, cost reduction can reach up to 90%   | Independent of business characteristics; any business can reduce costs, but recall accuracy issues may degrade answer quality |
| Development cost | Relatively low; the system handles caching automatically, with no additional integration or tuning needed | Relatively high; requires combining RAG with Embedding and continuous business-specific tuning                                |
| Extra benefit    | Improves response speed in long-text scenarios; average first-token latency can drop to within 5s         | Original text length can be extended to very long, more friendly for scenarios requiring millions of words in one go          |

> **Recommendation**: If your scenario involves **frequent queries against fixed content** (e.g., FAQs, document Q\&A), prioritize Context Caching. If the content is extremely long and query directions are unfixed, consider a RAG solution.

## Automatic Caching Mechanism

Kimi API's Context Caching uses a **fully automatic caching mechanism**:

* **No manual creation required**: The system automatically identifies and caches frequently used initial contexts.
* **No cache ID references needed**: When calling `/v1/chat/completions`, simply pass messages in the normal way, and the system will automatically match caches in the background.
* **No TTL management needed**: Cache lifecycle is managed automatically by the system, with no manual intervention required.

Simply call the API as usual, and the system will automatically trigger cache optimization at the appropriate times.

## Billing

For Context Caching billing and pricing details, see the [billing information on the Product Pricing page](/pricing/chat#billing-logic).

## Notes and Best Practices

1. **Cache match conditions**: The system automatically optimizes caching for frequently repeated initial contexts. Make sure your knowledge content, system prompts, and tool definitions are relatively stable for better cache hit rates.

2. **Combining with multi-turn conversations**: When using Context Caching in multi-turn conversations, place fixed large contexts (such as knowledge documents) at the beginning of the `messages` array (before the system message), then append user questions and model replies. The system will automatically identify and cache these fixed contents.

3. **No extra configuration needed**: Context Caching is automatically effective for all requests. You do not need to modify your API calling method or add extra parameters. Just focus on your prompt design and business logic.
