MaaS Price Cuts and Prompt Caching Optimization: A Practical Guide
A major cloud provider has reduced the price of cache-hit input tokens for a high-performance large language model service deployed in selected regions to 20% of the previous rate, while leaving other billing items unchanged. This article explains the economics behind context caching, how KV Cache reuse works during inference, and how developers can structure prompts, manage conversations, monitor cache performance, and prepare caches to reduce latency and inference costs.
Recently, a cloud provider announced a pricing adjustment for its high-performance large language model service deployed in selected regional nodes. While other billing items remain unchanged, the price for cache-hit input tokens has been reduced to 20% of the original rate.
This change reflects not only lower infrastructure costs for large model-as-a-service (MaaS) workloads, but also the growing maturity and adoption of context caching. For developers and enterprise users, understanding the technology behind this pricing model—and optimizing application architecture accordingly—is essential for taking full advantage of the savings.
1. MaaS Billing Models and Cache Hits
Under conventional usage-based billing, large language model APIs typically charge according to the number of input and output tokens. However, modern applications often send large amounts of repeated context across multiple requests, particularly in multi-turn conversations, long-document question answering, and retrieval-augmented generation (RAG) systems.
If the model recomputes the same prefix tokens for every request, it wastes substantial compute resources and can significantly increase time to first token (TTFT).
To address this issue, the industry has introduced context caching. Major cloud providers, including Baidu AI Cloud, are exploring and supporting this capability through their MaaS platforms. As a result, the billing model can be divided into three categories:
- Cache-miss input tokens: Regular input-token charges for newly processed context.
- Cache-hit input tokens: When a request prefix matches content already stored in the cache, the compute cost for those tokens is significantly lower. The latest pricing adjustment, for example, reduces it to 20% of the original price.
- Output tokens: Charges for tokens generated by the model.
Cloud providers can offer substantial discounts for cache-hit input tokens because the inference engine can reuse the previously computed KV Cache for an identical prefix. This allows it to skip much of the time-consuming prefill stage and move directly to token generation.
2. How Prompt Caching Works
Understanding cache hits requires a basic look at the inference process in Transformer-based models. In an autoregressive language model, generating each new token requires attention over the tokens that came before it. As the model processes an input sequence, each token is mapped through the attention mechanism to Key (K) and Value (V) tensors. Together, these tensors form the KV Cache.
Prefill and decoding
- Prefill stage: When a new request arrives, the model computes the KV Cache for all tokens in the input prompt. This is computationally intensive and can take considerable time.
- Decoding stage: The model uses the existing KV Cache to generate subsequent tokens one by one.
When two requests share exactly the same prompt prefix, the second request can theoretically reuse the KV Cache generated during the first request’s prefill stage. Cloud providers typically use mechanisms such as prefix hashing to match request prefixes. Once a match is found, most of the computation for the shared prefix can be avoided, leaving only a relatively small amount of memory-reading overhead.
This reuse is the technical foundation for reducing cache-hit input prices to a fraction of standard input-token charges.
3. Application Design Practices for Higher Cache-Hit Rates
For developers, a lower cache-hit price is only part of the opportunity. To achieve meaningful cost reductions in production, applications must be designed to maximize the likelihood that repeated prefixes will match.
3.1 Separate static prefixes from dynamic suffixes
This is the most important strategy for improving cache-hit rates. Static content—such as system instructions, few-shot examples, and long background knowledge—should appear at the beginning of the prompt. Real-time user queries and dynamically retrieved context should be placed at the end.
# Conceptual example: constructing a cache-friendly prompt# Static prefix: fixed instructions and knowledge base summarySTATIC_PREFIX = """You are a professional customer support assistant.Follow these rules strictly:1. Answer only based on the provided knowledge base.2. If the knowledge base does not contain the answer, reply, "I don't know."Knowledge base summary:[...large amount of fixed background knowledge...]"""# Dynamic suffix: content that changes for each requestdef generate_prompt(user_question: str, dynamic_context: str):# Keep the static prefix at the beginning and dynamic content at the endprompt = f"{STATIC_PREFIX}\n\nRelevant retrieved passages:\n{dynamic_context}\n\nUser question: {user_question}"return prompt
3.2 Manage context in multi-turn conversations
In multi-turn interactions, the order and stability of historical messages are critical. Adding dynamic values such as timestamps when assembling the conversation history, or randomly reordering historical messages, can invalidate prefix matching.
A better approach is to append the conversation history in a consistent chronological order and treat it as part of the stable prefix. Only the latest user input should be treated as the dynamic suffix whenever the application design allows it.
3.3 Avoid injecting random identifiers into prompts
Some security filters or logging components dynamically insert random task IDs or session identifiers at the beginning of a prompt. This directly breaks prefix consistency.
When possible, pass tracing information through HTTP headers or other metadata instead of concatenating it into the prompt text.
4. Enterprise Monitoring and Cache Warming
For large-scale enterprise systems, prompt construction alone is not enough. Organizations also need an operational process for monitoring and managing cache behavior.
4.1 Cache warming
For frequently used system instructions or long system prompts, an application can issue a request during off-peak hours through a heartbeat mechanism or an initialization script. This may load the corresponding KV Cache into the inference cluster’s available memory and improve the likelihood that the first production request during a traffic spike will hit the cache.
4.2 Monitor cache-hit rates
Use logging and monitoring systems to collect token usage details returned by the MaaS API. The real-time cache-hit rate can be calculated by comparing the number of cache-hit input tokens with the total number of input tokens.
If the hit rate falls below an expected threshold—for example, below 60%—the system can trigger an alert. Developers can then investigate whether dynamic variables or other prompt changes are contaminating the stable prefix.
4.3 Account for cache lifetimes
Because GPU memory and other inference resources are limited, cloud providers generally assign expiration periods to KV Cache entries. These periods may range from several minutes to several hours.
The application layer should be aware of this behavior. When a session has been inactive for an extended period, the application may need to inform the user or apply a fallback strategy when the session resumes. This helps prevent unexpected increases in compute usage after the cache has expired.
Conclusion
The sharp reduction in cache-hit input pricing is an important sign that MaaS platforms are moving toward more granular and efficient operations. For developers, the change represents more than a lower bill; it also provides a clear architectural direction.
By understanding how Transformer inference uses KV Cache, consistently separating static prefixes from dynamic suffixes, and combining prompt design with logging and monitoring, enterprises can benefit from both lower infrastructure prices and higher cache reuse. The result can be AI applications with lower costs, lower latency, and more predictable production performance.
