LLM Inference Cost Estimation and Plan Selection: A Practical Guide
Comparing per-million-token prices across LLM inference providers often leads to wrong conclusions, because the real bill is not a linear function of a single unit price. This article breaks down the cost of a request into cached input, uncached input, output, and time-of-day multipliers, then examines the three variables that decide the final ranking: cache hit rate, input-to-output ratio, and peak-hour multipliers. It also shows how to convert subscription plans into an equivalent price multiple so they can be compared against pay-as-you-go billing, and closes with a five-step measurement checklist and common pitfalls to avoid.
1. Why Comparing Unit Prices Often Gives the Wrong Answer
When evaluating LLM inference services, the most common approach is to put the “price per million tokens” of different options side by side. The flaw in this approach is that a real bill is not a linear scaling of the unit price; it is determined by several variables acting together.
The cost of a single request can usually be abstracted into four parts: input tokens that hit the cache, input tokens that miss, output tokens, and a price multiplier that depends on the time of day. A simplified calculation framework looks like this:
def cost_per_1e8(cache_hit, miss_in, out, p_cache, p_miss, p_out, peak_ratio=1.0):# Unit: CNY per 100 million tokensreturn (cache_hit * p_cache + miss_in * p_miss + out * p_out) * peak_ratio
If any one of the cache hit rate, the input/output ratio, or the time-of-day multiplier changes, the ranking can flip. The right way to assess cost is therefore to build the model first, then plug in the real distribution of your own workload.
2. Three Decisive Variables
2.1 Cache Hit Rate: The First Lever on the Cost Curve
Mainstream inference services generally offer context caching, and the cached portion is billed at a significantly lower price than uncached input. Because the cached unit price is typically only a fraction of the regular input price, a small change in hit rate gets amplified into a visible difference on the bill.
In a high-hit-rate scenario (for example, 98% hits, 1.5% uncached input, 0.5% output), the cost per 100 million tokens across options converges into a very narrow band, and the option with the lower cached price wins. When the hit rate falls back to around 95%, the weight of uncached input and output rises, and the option with a higher cached price but lower prices elsewhere becomes the better deal.
This shows that the cached price cannot be viewed in isolation; it must be evaluated jointly with the input and output prices. A practical approach is to compute the hit-rate distribution from one week of real logs, then plug both the P50 and P95 values into the model.
2.2 Input-to-Output Ratio: The Underestimated Cost Amplifier
The unit price of output tokens is usually several times that of input, and output volume is the hardest to compress. Code generation and long-form writing workloads may have an input-to-output ratio close to 1:1, while retrieval-augmented and document-summarization workloads are typically input-heavy and output-light. Ignoring this ratio can push the estimate off from reality by a multiple.
2.3 Time-of-Day Multipliers and Peak Windows
Some services apply a higher multiplier or stricter quota constraints during fixed hours of the day, especially for a few hours on weekday afternoons. The shorter the window and the closer it sits to active development hours, the harder it hits interactive coding workloads. When evaluating, align the length of the peak window, its time zone, and your team’s working rhythm, rather than looking only at the all-day average price.
3. Converting Subscription Plans to an Equivalent Basis
Subscription plans follow a different pricing logic from pay-as-you-go: they shift the risk of uncertain usage from the user to the provider, so a common conversion basis is needed before comparing them.
The recommended metric is the “equivalent price multiple”:
equivalent multiple = plan price / (included tokens x pay-as-you-go unit price)
The lower the multiple, the better the plan. Taking a commonly published tier structure as an example, the equivalent multiples of three plan tiers under off-peak, high-cache-hit conditions land roughly in the 0.5–0.7 range, meaning the plan price is about half to seventy percent of the equivalent pay-as-you-go cost. Two corrections are needed, though:
- If the actual hit rate is lower than the assumed one, the equivalent multiple rises and the advantage narrows;
- If usage cannot fill the plan quota, the effective unit price is raised, and pay-as-you-go is the safer choice.
A practical decision inequality is:
use_plan = (monthly_tokens <= plan_quota) and (plan_price < pay_as_you_go_cost)
4. A Practical Measurement Checklist
- Sample: collect at least one week of request logs, tagging token counts and timestamps for the three categories: hits, misses, and output.
- Bucket: split by P50/P95 hit rate and peak/off-peak, forming four scenarios.
- Plug in: use one unified model to compute cost per 100 million tokens and the monthly total.
- Validate: add loss factors such as failed retries and truncation of overly long contexts (a 5%–15% buffer is recommended).
- Decide: prefer a plan for stable, predictable workloads; prefer pay-as-you-go for volatile workloads or during trial-and-error phases.
5. Common Pitfalls
- Looking only at the cached price and ignoring input and output prices;
- Using averages instead of distributions, and overlooking the concentrated impact of peak hours;
- Treating the plan quota as “free credit” and ignoring that unused quota is a loss;
- Ignoring engineering-side optimizations such as prompt prefix reuse, result caching, batching, and streaming output, which often cut costs more than switching options.
6. Conclusion
The core of cost optimization is not finding the “cheapest unit price” but building a quantitative model that matches your own workload distribution. Only by folding hit rate, ratio, and time-of-day into one formula, and then comparing pay-as-you-go against plans horizontally with the equivalent multiple, can you make stable, reproducible selection decisions under a budget constraint. If the enterprise side has a complete usage collection, monitoring, and alerting system in place, this estimation process can be fully automated, making cost continuously observable and optimizable.
