How to Handle a Sharp LLM API Price Increase: Cache Hit Rate and Output Control
This article explains how to respond when a new model generation raises API prices several times over. Using a typical repricing as an example, it shows why the widening gap between price tiers matters more than the headline rate, how to structure cache-friendly requests with a stable prefix, four ways to compress output, and how to apply routing, batching, budget guardrails, and cost observability. A final checklist helps teams keep per-task cost under control during a period of rising prices.
1. Read the price structure first: three signals in a typical repricing
When a new-generation model of an AI coding tool went live, its billing rates rose noticeably: output went from roughly CNY 27 to CNY 100 per million tokens, uncached input from CNY 6.5 to CNY 20, and cache-hit input from CNY 1.1 to CNY 2. In relative terms, output is close to 4x, input about 3x, and cache-hit input rose more moderately. What deserves attention is not the unit price itself, but that the gap between tiers has widened.
Listing the three ratios separately makes the trend clearer:
| Metric | Previous generation | New generation | Change |
|---|---|---|---|
| Uncached input / cached input | ~6x | ~10x | Wider |
| Output / cached input | ~25x | ~50x | Wider |
| Output / uncached input | ~4.2x | 5x | Slightly wider |
The conclusion is straightforward: cache hits are the only relatively cheap tier in this repricing, and output is the most expensive one. The focus of cost optimization must shift from “send fewer tokens” to “make requests hit the cache as often as possible and keep output short.”
2. Why a widening tier gap hurts the bill more than a higher unit price
A higher unit price scales linearly; a wider tier gap is structural. Let the uncached input of a request be I, the cached input be H, and the output be O. The cost of a single request can be abstracted as:
Cost = I * P_in_miss + H * P_in_hit + O * P_out
When P_out / P_in_hit goes from 25 to 50, the same block of cacheable context becomes twice as expensive in relative terms if it is not served from cache. Three common forms of engineering waste are amplified as a result:
- The system prompt and tool definitions are resent in full every time, and slight changes (timestamps, random IDs, concatenation order) make the prefix inconsistent, so the cache misses entirely.
- Long context is repeatedly stuffed back in: retrieval results, conversation history, and code snippets are pasted in whole, making the input side the main cost.
- Output has no limit: the model tends to restate, explain, and summarize again, and output tokens often run several times the input.
3. How to construct cache-friendly requests
Cache-based billing usually depends on an “exact prefix match.” Platforms differ in hit granularity and minimum length thresholds, but the engineering practice is consistent: put stable content first and volatile content last.
Recommended layering order:
[Layer 1] Long-term stable: role definition, safety policy, output format constraints[Layer 2] Semi-stable: tool/function definitions, field schema, glossary[Layer 3] Session-level: multi-turn history, confirmed facts[Layer 4] Request-level: this turn's retrieval snippets, user input, random identifiers
Implementation points that go with it:
- Never insert timestamps, request IDs, or randomly ordered candidate sets into the stable prefix.
- Deduplicate retrieval results and sort them deterministically before concatenation.
- Use a “rolling window + summary compression” approach for conversation history to avoid unbounded growth.
- Before release, run a regression with fixed inputs, measure the hit rate, and make the hit rate one of the core monitoring metrics.
Illustrative pseudocode:
def build_messages(system_v2, tools_v3, history, query):# Version the first two layers; changes require review to avoid pointless invalidationprefix = render(system_v2) + render(tools_v3)return prefix, trim(history, max_tokens=4000) + [user(query)]
4. Output is the real battleground: four compression techniques
With output priced at nearly 5x uncached input, output length has the largest marginal impact on the bill.
- Structured constraints: require JSON output with a field whitelist and no extra explanatory fields.
- Explicit length budgets: state “no more than N words / no more than N items” in the prompt, which is cheaper than truncating after the fact.
- Plan before code: have the model give key points first and expand into implementation only after confirmation, avoiding one-shot generation of large blocks of useless content.
- Small-model or rule-based fallback: push deterministic tasks such as classification, extraction, and formatting down to a lightweight model or template logic.
{"schema": {"fields": ["title", "summary", "risks"], "max_items": 5}}
5. Routing, batching, and budget governance
- Tiered routing: split traffic by task difficulty, sending simple requests to a lightweight tier and reserving the high-capability tier for complex reasoning.
- Batching and asynchrony: combine non-real-time tasks into a single submission and use the platform’s batch channel for a better unit price.
- Budget guardrails: set token quotas and alert thresholds per business line, with automatic degradation on abnormal growth.
- Observability: instrument uncached input, cached input, and output tokens separately, and attribute them to specific endpoints and callers.
- Cost regression: on every prompt or model version change, run “cost per task” on a fixed evaluation set rather than looking at quality metrics alone.
6. Rollout checklist
- Is the stable prefix versioned, and are there pointless changes to it?
- Is the cache hit rate on a monitoring dashboard with threshold alerts?
- Does the output have explicit length and format limits?
- Is there model routing tiered by difficulty?
- Is token-level cost attribution and budget circuit-breaking in place?
7. Closing
The essence of this repricing is that it re-prices the value of both the cache and the output side. For developers, the response is not mysterious: keep the request prefix stable to raise the hit rate, make output shorter and more structured, and route tasks by difficulty. Turn these three things into engineering standards, and cost per business task stays controllable even in a period of rising unit prices. If an organization already uses related capabilities on Baidu AI Cloud, it can combine them with general cloud offerings such as monitoring and alerting and logging services to bring token cost and hit rate into a unified observability system.
