Time-Based Pricing for LLM APIs: How Bills Are Calculated and How to Save Money
This article explains how time-based (peak/off-peak) pricing affects LLM API bills. It breaks down common billing dimensions—uncached input tokens, cached input tokens, output tokens, and time-of-day multipliers—presents a reusable cost formula with a fully worked numerical example, and shows how cache hit rates and request timing drive daily costs, so teams can recalculate budgets and adjust call strategies when prices change.
1. Why Your Bill Changes After a Price Adjustment
LLM services charge by usage, with the token as the standard billing unit. The same endpoint and the same business logic can produce noticeably different bills under different pricing periods, depending on unit prices and usage structure. More and more providers are adopting time-based pricing, splitting the day into peak and off-peak windows with different unit prices. When prices change, any team relying on models for batch processing, content generation, or code assistance needs to recalculate its budget.
What really determines the budget is the billing structure itself. Developers need to know which items make up the cost, how they add up, and how the time-of-day multiplier applies, so they can quantify the impact on the day a price change takes effect and adjust their call strategy accordingly.
Note that time window definitions, cache TTL, billing units, and discount rules vary across providers. The formulas and examples in this article illustrate the calculation method; refer to each provider’s billing documentation and console for actual parameters.
2. Common Billing Dimensions
Following common industry practice, the cost of a single call typically includes the following components:
| Billing dimension | Meaning | Pricing characteristics |
|---|---|---|
| Uncached input tokens | The portion of the prompt, conversation history, and retrieved context that does not hit the cache | Billed at the standard input rate |
| Cache-hit tokens | The request prefix matches a recent request, and the provider reuses previously computed intermediate results | Usually below the standard input rate. Whether a cache write fee applies and how long the cache is valid depends on the provider |
| Output tokens | The response generated by the model | Usually higher than the uncached input rate; the exact rate depends on the model and provider |
| Time-of-day multiplier | An upward adjustment during peak hours; a discount or no change during off-peak hours | A multiplier, not billed separately |
The time-of-day multiplier is a multiplier. When there is no off-peak discount, it equals 1. During peak hours with a surcharge, it takes a value greater than 1. This article assumes the multiplier applies to the total cost of all three token types. If a provider only adjusts output token pricing, apply the multiplier only to the output term.
3. The Cost Formula with Cache Accounting
First, define the variables:
- N_miss: the number of uncached input tokens in a single request
- N_hit: the number of cache-hit input tokens in a single request
- N_out: the number of output tokens in a single request
- P_miss, P_hit, P_out: the unit prices of the three token types, in yuan per million tokens
- k: the current time-of-day multiplier—1 during off-peak hours, and the provider-specified surcharge multiplier during peak hours
The cost of a single request is:
Cost per request = k × (N_miss × P_miss + N_hit × P_hit + N_out × P_out) ÷ 1,000,000
Keep one accounting rule consistent: the same input token can only belong to one category. If a prefix is judged as a cache hit, it is billed once at the cache rate and must not also be counted at the standard input rate. The uncached portion is billed only at the standard input rate. The total prompt token count equals N_miss plus N_hit, and the total input volume on the bill should match this. If the two do not match, the same content has most likely been counted twice.
The daily cost is the sum of the per-request costs. If peak and off-peak usage are tracked separately, sum each period and then add them together.
4. A Reproducible Worked Example
All numbers below are hypothetical and used only to demonstrate the calculation; they do not represent any provider’s official pricing.
Assumptions:
- Uncached input price P_miss: 2 yuan per million tokens
- Cache-hit price P_hit: 0.2 yuan per million tokens
- Output price P_out: 8 yuan per million tokens
- Off-peak multiplier k = 1; peak multiplier k = 1.5
- Each request has a 3,000-token prompt, of which 2,000 tokens hit the cache and 1,000 do not, plus 500 output tokens
- 10,000 requests per day, 40% of which fall in peak hours
Step 1: compute the off-peak cost per request:
1,000 × 2 + 2,000 × 0.2 + 500 × 8 = 6,400, divided by 1,000,000, gives 0.0064 yuan.
Step 2: compute the peak cost per request: 0.0064 × 1.5 = 0.0096 yuan.
Step 3: compare against the no-cache case. With all 3,000 input tokens billed as uncached, the off-peak cost per request is 0.0100 yuan and the peak cost is 0.0150 yuan.
Putting the scenarios side by side:
| Scenario | Off-peak per request (yuan) | Peak per request (yuan) |
|---|---|---|
| No caching | 0.0100 | 0.0150 |
| 2,000 cache-hit tokens | 0.0064 | 0.0096 |
| Cache hits drop to 1,000 tokens | 0.0082 | 0.0123 |
Step 4: compute the daily cost. With a 40% peak / 60% off-peak split, the blended per-request average is 0.4 × 0.0096 + 0.6 × 0.0064 = 0.00768 yuan, and the daily cost is 10,000 × 0.00768 = 76.8 yuan. Without caching, the daily cost is 0.4 × 0.0150 + 0.6 × 0.0100 = 0.012 yuan per request, or 120 yuan. Caching reduces the daily cost by 43.2 yuan, roughly 36%.
Step 5: observe the impact of a falling hit rate. When cache hits drop from 2,000 tokens to 1,000 tokens, the off-peak cost per request rises from 0.0064 to 0.0082 yuan, an increase of about 28%. With the same peak/off-peak split, the daily cost rises from 76.8 to 98.4 yuan, an increase of 21.6 yuan. The cache hit rate is therefore one of the metrics that most deserves close monitoring.
5. Cost-Reduction Checklist
Cost reduction starts by identifying the largest cost items and then addressing them one by one. The following five measures are ordered by typical benefit, each with an executable action.
- Trim the prompt
