LLM Inference Cost Modeling and Plan Selection: A Practical Guide
Comparing per-million-token prices across vendors is misleading because the final bill depends on cache hit rate, input/output ratio, and peak-hour distribution. This article builds a reusable cost model, quantifies how a small drop in cache hit rate can reverse vendor rankings, folds peak-hour pricing into an effective unit cost, and shows how to convert subscription plans into an equivalent discount against pay-as-you-go API pricing. It also lists engineering optimizations and a decision workflow for choosing between subscription and usage-based billing.
1. Why “Unit Price Comparison” Almost Always Leads to the Wrong Conclusion
In LLM application cost assessment, the most common mistake is subtracting one vendor’s “price per million tokens” from another’s to decide who is cheaper. This ignores a basic fact: the bill for a request is not determined by a single price, but by the sum of several price items multiplied by their respective usage volumes.
A typical asymmetric structure looks like this: the cache-hit portion is extremely cheap, the uncached input portion is moderately priced, and the output portion is the most expensive. The three often differ by one to two orders of magnitude. So what really determines the bill is not the listed price, but the combination of three things:
- Cache hit rate: whether the request prefix can be reused;
- Input/output ratio: whether the workload is “read-heavy” or “generation-intensive”;
- Time-of-day structure: whether requests land in peak or off-peak windows.
If any one of these shifts, the ranking of two options can flip. The calculations below quantify each of the three in turn.
2. Building a Reusable Cost Model
Let the total token volume over a period be T, the cache hit rate be h, the input share be r_in, and the output share be r_out. The three billing volumes are:
cache-hit volume = T * huncached input volume = T * r_in * (1 - h)output volume = T * r_outtotal cost = cache-hit volume * P_cache+ uncached input volume * P_in+ output volume * P_out
One easily overlooked detail: the hit rate applies only to the input side; output never receives a cache discount. When the output share is high, the gains from cache optimization are significantly diluted.
Using 100 million tokens as the unit of calculation, plug in two sets of typical parameters (Option A’s cache unit price is roughly twice Option B’s, and its off-peak input and output prices are slightly higher):
| Scenario | Hit rate | Ratio | Option A | Option B |
|---|---|---|---|---|
| High hit | 98% | 1.5% input / 0.5% output | ~12.6 CNY | ~9.4 CNY |
| Medium hit | 95% | same | ~14.9 CNY | ~18.3 CNY |
The conclusion is clear: at a 98% hit rate, the option with the lower cache unit price wins; once the hit rate drops to 95%, the ranking flips immediately. Marginal analysis explains why—every 1 percentage point drop in hit rate moves a batch of tokens from the cheapest price tier to the medium tier, and the cost of that migration is proportional to the price gap between the two tiers. The lower the cache unit price, the larger the migration cost, and therefore the more sensitive the option is to the hit rate.
The engineering implication: if your workload cannot reliably sustain a very high prefix reuse rate, you should not treat “low cache unit price” as the primary decision criterion.
3. Folding Time-of-Day into the Model
Beyond caching, the second structural variable is peak hours. A common industry practice is to apply differentiated pricing or throttling during a fixed set of hours each week (for example, several consecutive hours on weekday afternoons), while settling the rest of the time at a discounted price. Differences in peak-window length across options directly change the effective unit price.
The revised model only needs one additional time weight:
effective cost = off-peak cost * (1 - p) + peak cost * p
where p is the share of requests falling inside the peak window. For deferrable workloads such as offline batch processing, code completion, and document summarization, pushing p close to 0 often yields greater savings than switching options; for online interactive paths, p is determined by the user activity curve and is nearly impossible to compress, so the time-of-day difference must be counted into the price comparison.
4. Converting Subscription Plans to an Equivalent Basis
Subscription plans cannot be evaluated by monthly fee alone; what matters is “how much original-price API quota each unit of plan fee buys.” The conversion steps:
- Take the official token cap for the plan (usually stated under off-peak, high-hit-rate conditions);
- Use the model from Section 2 to compute the original pay-as-you-go price of that token volume;
- Divide the original price by the monthly fee to get the discount multiplier; its reciprocal is the ratio of the plan unit price to the API unit price.
By this method, three tiers (monthly fees of roughly 118 / 538 / 1078 CNY) correspond to original-price quotas of about 160 / 955 / 2229 CNY, meaning the plan unit price lands roughly in the 50%–70% range of the original API price. The pattern: the higher the tier, the deeper the discount, but the greater the idle-capacity risk.
So the criterion for plan selection is the average, not the peak:
if monthly average quota requirement >= plan quota * safety factor (0.7–0.8 recommended)then subscription is better; otherwise pay-as-you-go is better
The safety factor absorbs business fluctuation and avoids buying long-term idle quota for occasional peaks.
5. Engineering Optimization Checklist for Hit Rate and Ratio
The value of the cost model is that it points out what can be optimized. Actionable measures include:
- Prefix stabilization: keep the system prompt, tool definitions, and few-shot examples fixed at the very front of the request, and avoid putting volatile content such as timestamps or random IDs first;
- Session-level reuse: keep the prefix consistent across multi-turn conversations so the history portion keeps hitting the cache;
- Output constraints: control
r_outthrough structured output and length caps, directly suppressing the most expensive tier; - Batching and off-peak scheduling: move deferrable tasks into off-peak windows to lower
p; - Observability: use logging services and monitoring alerts to break down token usage, hit rate, and time-of-day distribution per business dimension, forming a cost dashboard.
An illustrative usage-collection structure:
{"biz": "code_completion","total_tokens": 120000000,"cache_hit_ratio": 0.972,"input_ratio": 0.021,"output_ratio": 0.007,"peak_ratio": 0.08}
6. Decision Workflow and Conclusions
The recommended decision order:
- Measure
h,r_in,r_out, andpfrom real sampled data rather than reusing the ideal values stated in official documentation; - Plug them into the unified model to compute each option’s effective unit price under its own peak-hour rules;
- Compare monthly average usage against plan quota to decide between subscription and pay-as-you-go;
- Recompute every quarter, because both workload structure and vendor policies change.
Three core conclusions: a low unit price does not mean a low cost—hit rate and time-of-day are the real levers; plan discounts in the 50%–70% range are the industry norm, and higher tiers require careful evaluation of idle capacity; and only by wiring the cost model into a monitoring system can optimization keep paying off. If you already use Baidu AI Cloud products, you can reuse the existing metering data from its logging service, monitoring alerts, and container platform to build the dashboard above, with no extra collection pipeline.
