LLM API Peak and Off-Peak Pricing: A Practical Guide to Cost Optimization
This article explains how time-based and calendar-based pricing for large model APIs affects inference bills, and how engineering teams can control them. It breaks total cost into three variables—cached input, uncached input, and output tokens—shows why load structure determines the size of off-peak savings, and provides a reusable cost estimation function. Four cost reduction paths are covered: improving prefix cache hit rates, slimming inputs with retrieval, batch scheduling with queues, and model routing, along with three anti-patterns to avoid.
1. From “Weekday Make-Up Shifts” to “Weekends as Full Off-Peak Days”: A Pricing Correction
In a discussion about time-of-day pricing for large model APIs, one developer joked that moving a make-up workday onto a weekday is pointless: off-peak hours fall at night, while daytime work still lands in the peak window, so the bill does not get any cheaper. Later, in late August, a cloud provider adjusted its billing rules: weekdays are split into peak and off-peak periods, while Saturday and Sunday are billed at the off-peak rate for the entire day.
The change looks like nothing more than a calendar adjustment, but it is really about aligning the pricing model with the actual resource supply curve. Enterprise workloads are heavily concentrated in weekday daytime hours, while overall request volume drops markedly over the weekend, leaving clusters under low load for long stretches. The previous peak/off-peak split divided the day only by hour ranges and ignored the weekday/non-weekday dimension, which pushed weekend daytime into the peak bucket and contradicted the actual idle capacity. After the fix, the price signal reflects supply tightness more accurately and is easier for enterprises to use in production scheduling and budget modeling.
For consumers of these APIs, there are three direct implications. First, available capacity during non-peak periods is larger, making weekends a natural window for batch jobs. Second, cost models need a calendar dimension; estimating with hourly ranges alone is not enough. Third, if a company tries to shift load into weekday off-peak hours by rearranging work schedules, the payoff is limited—the real lever is moving deferrable workloads to the weekend.
2. Break the Bill into Three Variables Before Estimating
Whatever the specific unit prices are, the skeleton of large model inference cost is stable:
Total cost = cached input × cache hit price+ uncached input × cache miss price+ output tokens × output price
The three variables differ greatly in how controllable they are. Output tokens are determined by business semantics and offer the least room for compression; uncached input depends on prefix stability and caching strategy; cached input depends entirely on engineering effort. So the optimization priority should be: raise the cache hit rate first, slim down inputs second, and only then consider shifting load off-peak.
Take an example of 10 billion tokens consumed per day, a 95% cache hit rate, input accounting for 95% and output for 5%. Input splits into 9.5 billion (of which 9.025 billion are hits and 475 million are misses) and output is 500 million. Under the common structure where the peak unit price is exactly twice the off-peak price:
| Load structure | All-day off-peak | All-day peak | Difference |
|---|---|---|---|
| Input 95% / output 5% | ≈3,414 CNY | ≈6,828 CNY | ≈3,414 CNY |
| Input 80% / output 20% | ≈9,980 CNY | ≈19,960 CNY | ≈9,980 CNY |
Switch to a more balanced mix of 80% input and 20% output (7.6 billion hits, 400 million misses, 2 billion output tokens), and the absolute figure nearly triples; the amount saved by shifting off-peak grows from a little over three thousand to nearly ten thousand. The conclusion is clear: off-peak shifting saves a multiple, and load structure determines the base that multiple applies to. The higher the output share and the lower the cache hit rate, the larger the absolute off-peak savings.
3. A Reusable Cost Estimation Implementation
Turning the model above into code is what makes it usable for capacity planning and budget reviews:
def estimate_cost(billion_tokens, hit_rate,in_ratio, price_off, price_peak, peak=False):"""Estimate daily cost in CNY; price_* are off-peak unit prices."""k = 1.0 if peak else 0.5 # peak is twice off-peaktotal = billion_tokens * 1e9hit = total * hit_ratemiss = total * (1 - hit_rate)return (hit * price_off * k+ miss * price_off * 3 * k+ total * in_ratio * 0 + # placeholder, keeps structure cleartotal * (1 - in_ratio) * price_off * 9 * k)
In practice, it is best to externalize unit prices, the peak/off-peak multiple, and calendar rules as configuration so that price changes do not require code changes. Also persist estimation results by tenant and business line to form a cost baseline that can be reconciled.
4. Four Cost Reduction Paths and Engineering Notes
1. Raise the prefix cache hit rate. Keep stable content such as system prompts, tool definitions, few-shot examples, and long documents at the front and byte-for-byte fixed; avoid inserting volatile fields like timestamps or random IDs at the head; within a session, append to the prefix incrementally and never rewrite it retroactively. Moving the hit rate from 80% to 95% is often more worthwhile than any off-peak shifting.
2. Slim inputs and replace long context with retrieval. Use retrieval-based approaches to inject only the needed snippets instead of stuffing in whole documents; summarize and compress conversation history; aggregate structured data before feeding it to the model to cut wasted tokens.
3. Batch processing and queue-based peak shaving. Put deferrable tasks such as offline summarization, batch translation, log analysis, and regression evaluation into a queue, and schedule them with the policy “weekday off-peak first, weekends as full-day fallback,” combined with rate limiting and retry backoff:
def schedule_window(task, now):if now.weekday() >= 5: # weekends are off-peak all dayreturn "run"return "run" if is_off_peak(now) else "defer"
4. Routing and model tiering. Send simple classification, extraction, and rewriting to lightweight models and complex reasoning to larger models. At the same time, set up monitoring and alerts with thresholds on token consumption, cache hit rate, and peak/off-peak share, so cost anomalies surface within hours rather than at month end.
5. Three Anti-Patterns to Watch Out For
The first is “rearranging work schedules to save money”: shifting load to weekday off-peak hours saves far less than moving it to the weekend, and it disrupts collaboration rhythms. The second is “quota limits plus weekend overtime”: throttling on weekdays and opening up on weekends looks good on the books short term, but over time it transfers fatigue and delivery risk to the team—a classic case of local optimization. The third is “unit price only”: focusing solely on negotiating unit prices while ignoring caching and input structure, which usually determine more than 70% of the bill.
6. Conclusion
The essence of time-based pricing is expressing supply tightness through price. Understand the two dimensions of time period and calendar, break cost into the three variables of cached input, uncached input, and output, then drive it down layer by layer with cache governance, input compression, off-peak scheduling, and tiered routing. Inference cost then turns from a month-end surprise into an engineering metric you can forecast daily and optimize weekly.
