LLM API Cost Analysis: How Cache Hit Rates and Subscription Plans Affect Model Selection
Comparing sticker prices per million tokens is a misleading way to choose an LLM API provider. This article walks through a practical framework for calculating real-world costs based on cache hit rates, input/output token ratios, and subscription plan conversion. It includes a weighted cost formula, sensitivity analysis across different hit-rate scenarios, a method for converting subscription quotas into equivalent pay-as-you-go value, and a step-by-step decision framework for picking the most cost-effective option for your workload.
Why “Cheap List Prices” Don’t Mean “Cheap in Practice”
In LLM API billing, comparing only the “per million tokens” list price often leads to wrong decisions. That’s because mainstream inference services typically split billing into three components:
- Cache hits: Tokens in the context that overlap with a repeated prefix, billed at the cached price—usually 1/5 to 1/10 of regular input pricing;
- Regular input: Non-cached input tokens, billed at the listed input price;
- Output: Tokens generated by the model, typically priced several times higher than input.
This means two models with similar list prices can differ by several times in real-world cost, and two models whose prices differ by 2x can even flip in cost ranking depending on cache hit rate. The right approach to selection is to compute a weighted blended unit price using your own traffic profile, not to read a single cell from a pricing table.
How to Calculate Real Costs
2.1 Build a Traffic Model
Start by estimating the share of the three token types. Take a typical AI coding assistant or chat application: because system prompts and code context repeat heavily, cache hit rates tend to be very high. Assume the following traffic profile:
- Cache hits: 98%
- Regular input: 1.5%
- Output: 0.5%
2.2 Weighted Cost Formula
Blended cost can be expressed as:
Cost per 1M tokens =cache hit rate × cached price+ input share × input price+ output share × output price
As a comparison, take two commonly seen pricing tiers: Model A with a cached price of roughly 0.115 yuan per million tokens, and Model B with an off-peak cached price of roughly 0.05 yuan per million tokens, with input and output prices taken from each model’s published rates.
98% hit-rate scenario: Per 100 million tokens, the weighted cost is about 12.57 yuan for Model A versus about 9.40 yuan for Model B. Here Model B’s off-peak pricing wins clearly—the price gap is amplified by the high hit rate.
95% hit-rate scenario: Model A drops to about 14.92 yuan, while Model B rises to about 18.25 yuan. The reason is that Model B’s regular input price is relatively higher: every percentage point the hit rate falls pushes more tokens into the expensive tier, and costs rebound quickly.
This comparison reveals a key conclusion: cache hit rate is the lifeline of low-cache-price strategies. The higher the hit rate, the more the cached-price difference dominates; once the hit rate slips, the regular input price becomes the deciding factor. So always measure hit rates from real logs before running these calculations—don’t just assume.
2.3 Sensitivity Analysis
In engineering practice, it’s worth building a sensitivity table: take hit rates of 90%, 95%, and 98% on one axis, and off-peak versus peak pricing on the other, then compute the blended cost for each cell. When your traffic fluctuates and hit rates are unstable, a plan with balanced pricing across all token types is usually lower-risk than one that only pays off with extremely high hit rates.
Converting Subscription Plans into Comparable Costs
Beyond pay-as-you-go billing, most platforms offer monthly subscription plans aimed at coding workloads, typically in three tiers (entry, professional, and flagship), each with a weekly token quota. The core question when evaluating a plan is to convert the quota into an equivalent pay-as-you-go dollar amount.
Take one platform’s plan structure as an example (numbers are illustrative):
| Tier | Monthly Fee | Weekly Quota | Equivalent API Value | Effective Discount |
|---|---|---|---|---|
| Entry | ~118 yuan | ~317M tokens | ~160 yuan | ~60% |
| Professional | ~538 yuan | ~1.90B tokens | ~955 yuan | ~55% |
| Flagship | ~1078 yuan | ~4.43B tokens | ~2229 yuan | ~50% |
Subscription pricing works out to roughly 50%–70% of pay-as-you-go rates. Larger quotas come with deeper discounts, consistent with typical volume-pricing logic.
3.1 Watch for Peak-Hour Restrictions
Plans usually include peak-hour throttling clauses, which are easy to overlook. Definitions of “peak” vary widely across platforms: some designate multiple windows every day, others restrict peak hours to a short afternoon window on weekdays. The narrower the peak window, the more usable the quota is—for teams that code intensively during working hours, plans with lenient peak restrictions should be preferred.
3.2 Utilization Determines a Plan’s Value
The discount only materializes when the quota is actually consumed. If your monthly usage only reaches 30% of the entry-tier quota, pay-as-you-go may actually be cheaper. Conversely, for heavy daily coding workloads, the flagship tier’s discount rate—combined with equally strong model capability—delivers a clear per-unit cost advantage. Run one or two weeks on pay-as-you-go first to capture your real usage curve, then decide whether and at which tier to switch.
A Decision Framework
Pulling this together, here’s a simple decision process:
- Profile your traffic: Extract hit rate, input/output ratio, and peak/off-peak distribution from your API logs;
- Compute weighted costs: Calculate blended unit prices for each candidate plan and run hit-rate sensitivity analysis;
- Compare plan conversions: Convert subscription quotas into equivalent API value and compute effective discount rates;
- Assess peak-hour constraints: Check whether your peak usage windows conflict with the plan’s throttling windows;
- Validate at small scale: Roll out the chosen option on real traffic to verify the projections before switching fully.
Summary
Optimizing LLM costs isn’t about “finding the cheapest unit price”—it’s a combinatorial optimization problem. Cache hit rates determine the leverage of cached pricing, the input/output structure determines the weight of regular tokens, and subscription discount rates plus peak restrictions cap the value of flat-rate plans. Put all three variables into a single calculation sheet and replace intuition with real data, and you can identify the genuinely low-cost route that fits your workload. For budget-sensitive teams, it’s worth codifying this calculation into a script and re-running it automatically whenever a vendor changes prices or your traffic structure shifts—keeping costs continuously visible and under control.
