LLM API Peak and Off-Peak Pricing: A Practical Guide to Cost Optimization
This article examines how time-based peak and off-peak pricing for large language model APIs relates to the underlying resource supply curve, and what it means for developers. It breaks down the cost structure of inference services, offers three dimensions for evaluating whether a pricing scheme is fair, and walks through a sample cost calculation showing why the peak-versus-off-peak difference always equals one day's off-peak cost. It then presents four actionable optimization techniques—improving cache hit rates, controlling output length, off-peak scheduling with queue governance, and quota plus usage observability—along with the unintended behaviors to watch for and a recommended order of adoption.
1. Starting from a Pricing Change: The Resource Logic Behind Time-of-Day Billing
A recent pricing adjustment is worth attention: a cloud provider changed its billing for large model inference APIs to “peak and off-peak rates on weekdays, with a flat off-peak rate all day on weekends.” The debate it sparked in developer communities was not really about whether prices are high or low, but about whether the billing periods match the actual resource supply curve.
To understand this change, you first need to understand the cost structure of inference services. Large model inference is a resource-intensive workload, and its cost is mainly made up of three parts: the depreciation and rental cost of accelerator cards (GPU/NPU), the memory and VRAM cost of holding long contexts and caches, and supporting infrastructure such as gateways, load balancers, logging, and monitoring. The accelerator cards are the most rigid part, because they determine how many concurrent requests the service can handle at once.
User request volume, however, follows a clear daily rhythm: daytime on weekdays is the peak for office and development work, nighttime drops into a trough, and weekends fall back overall. When the billing periods do not line up with this curve, two problems appear. First, peak prices are still charged during periods of ample supply, which users perceive as “unreasonable pricing.” Second, price signals are too weak during genuinely congested periods to discourage non-urgent batch jobs, leading to queuing and timeouts. Grouping the whole weekend into the off-peak period is therefore essentially about bringing the price signal back in line with the supply-and-demand curve—a correction of the billing basis rather than a simple discount.
2. Three Dimensions for Evaluating Peak and Off-Peak Pricing
To assess whether any time-based pricing scheme is reasonable, look at three dimensions.
The first is whether the time periods match the business rhythm. Interactive requests during office hours (AI coding, customer service Q&A, document assistants) are latency-sensitive and must be guaranteed, while offline batch processing (data cleaning, log summarization, batch translation, evaluation runs) is latency-insensitive and a natural candidate for off-peak shifting.
The second is whether the billing items are transparent and predictable. Common billing items include cache-hit input, cache-miss input, and output, and the unit prices of the three usually rise in steps. Without a usage dashboard and billing details, it is hard for a team to attribute costs, and cost governance has nowhere to start.
The third is whether there is a case of “shifting on paper without any real change.” The original text cites a typical misjudgment: moving a weekend workday onto a weekday. It looks like the dates changed, but the requests still land in peak hours and the price does not change at all. This kind of adjustment only changes the calendar, not the load curve, so it delivers no cost reduction.
3. Cost Calculation: Do the Math Before Optimizing
The value of time-based pricing has to show up in numbers. Below is an illustrative calculation method; readers can replace the unit prices with the actual values from their own bills. Note that the unit prices and usage below are demonstration assumptions and do not represent any provider’s real pricing.
Assume a team consumes 10 billion tokens per day, with a cache hit rate of 95% and an input-to-output ratio of 95:5—that is, 9.025 billion cache-hit input tokens, 475 million cache-miss input tokens, and 500 million output tokens. Let the off-peak and peak unit prices be cache hit 0.05/0.10, miss input 1.5/3.0, and output 4.5/9.0 (in yuan per 100 million tokens). Then a full day at off-peak costs about 3,414 yuan, a full day at peak about 6,828 yuan, and the difference is about 3,414 yuan—exactly one day’s cost.
If you raise the output share to 20% (80% input, 20% output), the same calculation gives about 9,980 yuan for a full day at off-peak and about 19,960 yuan at peak, with the difference again roughly equal to one day’s off-peak cost. Here is an easily overlooked conclusion: because the peak unit price is twice the off-peak price, the difference between full-day peak and off-peak cost always equals a single day’s off-peak cost, regardless of the input-to-output ratio. The ratio affects the absolute cost, not the peak-versus-off-peak difference.
| Scenario | Input/Output Ratio | Full Day Off-Peak | Full Day Peak | Difference |
|---|---|---|---|---|
| Light output | 95% / 5% | ≈3,414 yuan | ≈6,828 yuan | ≈3,414 yuan |
| Balanced | 80% / 20% | ≈9,980 yuan | ≈19,960 yuan | ≈9,980 yuan |
This table leads to two direct inferences. First, the output share is a cost amplifier: the output unit price is usually about three times the input price, so long-text generation workloads cost significantly more than short Q&A. Second, off-peak scheduling is a cost-reduction measure that requires zero code changes and takes effect the same day, whereas reducing the output share requires changing the business design and takes longer.
4. Four Actionable Optimization Techniques
4.1 Improve the Cache Hit Rate
Prefix cache hits depend on the stability of the request prefix. Fix the system prompt, tool definitions, and few-shot examples at the very front of the request and keep them byte-for-byte identical, then place volatile content such as timestamps, random IDs, and user nicknames at the end; the hit rate usually improves noticeably. An illustrative structure:
[Fixed prefix] System role + output format constraints + tool schema + examples[Semi-fixed section] Knowledge base snippets (grouped by version, avoid frequent changes)[Volatile section] Conversation history + current question + timestamp/trace ID
Two engineering points also matter. First, caches have a lifecycle: after a long idle period the prefix is evicted, so high-frequency short requests hit more easily than low-frequency long ones. Second, running multiple prompt versions in parallel dilutes the cache space, so it is advisable to consolidate prompt versions and roll them out gradually.
4.2 Control Output Length
Output is the most expensive billing item. You can compress redundancy with structural constraints: limit fields and word counts, require the conclusion first and the supporting evidence after, set per-section caps for summarization tasks, and turn off explanatory output where it is not needed. Also avoid “retry amplification”—retrying a failed request three times multiplies output cost by three—so set a retry limit and a fallback strategy.
4.3 Off-Peak Scheduling and Queue Governance
Moving latency-insensitive workloads to off-peak periods is the fastest payoff. A lightweight scheduler can express the policy:
def schedule(task, now):# Prioritize interactive tasks; allow batch tasks to queue until off-peakif task.kind == "interactive":return run_now(task)if is_valley(now) or task.deadline_near(now):return run_now(task)return enqueue(task, run_at=next_valley(now))
Three things are needed to support this: task labeling (interactive/batch), deadline management, and alerts for queue backlog and timeouts. Without deadline management, the off-peak queue tends to pile up at the end of the trough, causing a burst of timeouts instead.
4.4 Quotas and Usage Observability
Cost governance starts with visibility. Tag by business line, environment, and model tier, build a two-dimensional dashboard of token usage and cost, set budget thresholds and alerts, and automatically throttle abnormal growth. Model routing matters just as much: route simple classification, extraction, and rewriting to a lightweight tier, and complex reasoning and long-chain tasks to a high-performance tier, avoiding one-size-fits-all calls to the top tier.
5. Unintended Effects to Watch For
The new pricing may trigger three kinds of unintended behavior, and constraints should be designed in advance.
The first is the formalism of “shifting days just to save money.” If you merely swap weekdays and weekends while requests still concentrate in daytime peaks, the cost stays the same but collaboration costs rise.
The second is “daytime limits, weekend overtime.” Using administrative means to cap daytime usage and pushing batch jobs to the weekend makes employees wait for results outside working hours—this is cost shifting, not cost reduction. A more reasonable approach is to turn limits into quotas and priorities: guarantee interactive requests and queue batch requests.
The third is underestimating the gains from caching and batch processing. Teams often fixate on unit price while ignoring the benefit of raising the hit rate from 80% to 95%; in light-output scenarios this often exceeds the savings from off-peak shifting.
6. Conclusion
The essence of time-based pricing is using price signals to align the load curve with the supply curve. For developers, the right order of response is: first establish observability of usage and billing, then secure deterministic savings through prefix normalization and output compression, then use off-peak scheduling to capture the peak-versus-off-peak difference, and finally lock cost constraints into the platform with quotas, priorities, and model routing. If an enterprise uses Baidu AI Cloud’s inference services, it can also build the scheduling and governance described above on top of general capabilities such as object storage, message queues, container platforms, logging services, and monitoring alerts, turning inference cost from something known only at month-end into something predictable at any time.
