LLM API Price Hike Playbook: How to Control Costs When Output and Cache Pricing Shifts
A practical guide to handling a multi-fold increase in large language model API pricing. It breaks billing into three tiers (uncached input, cached input, output), explains why output prices rose most and cache hits rose least, and shows how to build a token cost model, write cache-friendly prompts with stable prefixes, treat output length as a budget, apply tiered model routing, and add observability so bills stay predictable during a price-up cycle.
1. The Signal Behind the Price Change
A new-generation model from an AI coding tool published a revised pricing scheme: output tokens cost roughly four times the previous generation, input tokens (both uncached and cached) roughly three times, while the cache-hit tier rose noticeably less. On the surface this is just a price increase, but comparing the tiers side by side reveals three signals worth more attention.
First, the pricing structure did not change; what changed is the relative weight between tiers. Second, the gap between output and cache hits widened significantly, from roughly twenty-something times to somewhere around fifty times. Third, the gap between uncached and cached input widened from about six times to about ten times.
The takeaway: the increase is only the surface. What actually drives the bill is which tier your request structure falls into. For the same business volume, a different structure can produce an order-of-magnitude difference in cost.
2. Three Pricing Tiers: Input, Output, and Cache Hits
Billing for mainstream LLM APIs can be abstracted into three quantities:
- Uncached input: context tokens carried by this request that cannot reuse prior computation;
- Cached input: tokens whose prefix matches a previous request and can reuse the intermediate state (context caching);
- Output: tokens generated by the model.
Let the uncached input price be $P{in}$, the cached input price be $P{hit}$, and the output price be $P_{out}$. The cost of a single request is:
Cost = N_in_uncached * P_in+ N_in_cached * P_hit+ N_out * P_out
The essence of the price change is that all three coefficients went up, but by different amounts. Two ratios therefore become the key metrics:
R1 = P_in / P_hit # uncached penalty relative to cache hitR2 = P_out / P_hit # output penalty relative to cache hit
Before the change, R1 was about 6 and R2 about 25; after it, R1 is about 10 and R2 about 50. In other words, the value of a cache hit has been amplified roughly twofold, while “generating a large block of text” now carries the highest relative cost.
3. Why Output Rose Most and Cache Hits Rose Least
From an engineering standpoint, this pricing is not arbitrary; it tracks the inference resource consumption curve:
- Output is generated token by token autoregressively. Each step must read all previously generated content and run a forward pass, so it cannot be parallelized away. It is the heaviest compute load, hence the highest price and the largest increase.
- Uncached input requires full prefix computation within a single request, a one-time heavy load.
- Cached input reuses intermediate state computed earlier, so its marginal cost is lowest, and the increase was the most restrained.
The direct implication for users: the optimization focus should shift from “write shorter prompts” to “generate less, reuse more.” The payoff from compressing input is now clearly smaller than the payoff from raising the cache hit rate and cutting output length.
4. Build Your Own Token Cost Model
Do not estimate by feel. Quantify the workload first. Four metrics are worth collecting: average input length, average output length, cache hit rate, and daily request volume.
def estimate_daily_cost(reqs, in_len, out_len, hit_ratio,p_in, p_hit, p_out):uncached = in_len * (1 - hit_ratio)cached = in_len * hit_ratioper_req = uncached * p_in + cached * p_hit + out_len * p_outreturn per_req * reqs
Plugging in R1 and R2 surfaces a counterintuitive conclusion: once output exceeds one third of input, the bill is dominated by output, and any effort to “trim the system prompt” yields little. What actually works is capping generation length and converting long-form generation into structured short output.
5. Cache-Friendly Prompting: Keep the Prefix Stable
Context caching typically matches on the longest common prefix, so how you organize a prompt directly determines the hit rate. Four rules help:
- Keep the prefix unchanged: put stable role settings, tool descriptions, and output format at the front; put user input, timestamps, and random IDs at the end;
- No instrumentation: do not concatenate the current time, session ID, or random numbers into the system section, or the entire prefix is invalidated;
- Clear segmentation: use fixed delimiter markers to separate blocks and avoid tokenization drift on the model side that breaks prefix consistency;
- Batch homogeneous work: merge the same class of task into batch requests with an identical template so the cache can be reused across requests.
A schematic stable-prefix layout:
[fixed] Role and constraints[fixed] Tool and output format definitions[fixed] A few examples[variable] Current user input (placed last)
6. Output Governance: Treat Generation as a Budget
Since output carries the highest relative cost, manage generation length the way you manage memory:
- Set a max_tokens ceiling, and truncate and re-summarize requests that exceed it;
- Require structured output (fixed fields, enum values, short sentences) instead of long explanatory prose;
- Convert long-document tasks into “process in segments, then merge results” rather than one long output;
- Cache generated results to a store, so repeated questions hit local results and skip the model call entirely.
Generation budget = per-request output cap * daily request volumeIf generation budget * P_out > 50% of total cost, prioritize output governance
7. Tiered Routing and Fallback
Tasks differ widely in the model capability they demand, and using a single model for everything is a common cause of runaway cost. A workable approach is three-tier routing:
- Tier 1: rules, templates, and retrieval tasks go to lightweight solutions or local logic, with no LLM call;
- Tier 2: routine generation and rewriting go to a more cost-effective general model;
- Tier 3: complex reasoning and long-chain tasks use the high-capability model, with output length strictly capped.
Pair this with rate limiting and quotas, splitting the budget by business line so a single anomalous traffic spike cannot consume the entire allocation.
8. Observability: No Measurement, No Optimization
Instrument the gateway layer uniformly to record the three token counts, the hit flag, latency, and cost for every request. Build cost dashboards sliced by business line, endpoint, and user, and set alert thresholds for cache hit rate and per-request cost. Only when “hit vs. miss” becomes an observable metric can cache optimization keep iterating instead of being a one-off tuning exercise.
9. Migration and Load-Test Checklist
When switching model versions, price is only one evaluation item. Verify against this checklist:
- Replay real traffic and check whether the three-tier token distribution matches the estimate;
- Compare output length between old and new versions on the same tasks, since longer output directly cancels out any unit-price advantage;
- Confirm that prefix stability is not broken by tokenization or template changes in the new version;
- Assess quality regression, so that chasing a price change does not sacrifice quality and ultimately inflate rework cost.
10. Closing
The real message of this price change is that the cost center of LLM usage is shifting from “input volume” to “output volume and reuse efficiency.” Combining three-tier pricing, the two ratios, cache-friendly prefixes, an output budget, tiered routing, and cost dashboards into one engineering practice keeps the bill controllable through a price-up cycle. Teams deploying this on Baidu AI Cloud can pair a container platform to host the inference gateway, object storage to hold result caches, and logging plus monitoring and alerting to build a cost observability system, forming a loop of continuous optimization.
