How LLM API Off-Peak Pricing Works: Calculating and Optimizing Your Token Costs

    Many LLM API providers now offer off-peak pricing, where the same workload can cost several times less depending on when it runs. This article explains why dual-track peak/off-peak pricing exists, breaks down the key billing components—input tokens, output tokens, and cache hits—and walks through a practical cost estimation model. It also shares four actionable optimization strategies: scheduling batch tasks during off-peak windows, improving cache hit rates, compressing context and output, and building cost monitoring and alerting into your applications.

    Why LLM APIs Have Peak and Off-Peak Pricing

    In recent years, LLM inference services have widely adopted time-of-day differentiated pricing. The commercial logic is straightforward: GPU inference costs are fixed throughout the day, but request traffic follows a pronounced tidal pattern—heavy during working hours and evenings, with large amounts of idle capacity from late night through early morning.

    To improve resource utilization, providers sell part of their compute capacity at lower prices during off-peak hours (“off-peak pricing”), while maintaining higher unit prices during peak hours—sometimes several times the off-peak rate. Public industry reports show such pricing adjustments are not isolated: one vendor raised off-peak prices, then rolled back input and cache prices to pre-increase levels while keeping some output price increases in place. This “partial rollback, partial retention” strategy reflects the complexity of inference cost structures and signals that users must actively track billing changes.

    Breaking Down the Core Billing Components: Input, Output, and Cache Hits

    Understanding the pricing mechanism starts with knowing which parts of a call generate charges. A typical structure priced per million tokens includes:

    1. Input token costs. These cover the tokens consumed by the prompt, including the system prompt, conversation history, and the current user input. Input is usually the cheapest billing component and has the greatest room for price rollback, because it is mostly “read computation” with relatively low inference overhead.

    2. Output token costs. Generated tokens are decoded one by one, making this the most compute-intensive phase. Output unit prices are therefore typically several times higher than input prices. This also explains why, even when overall prices are rolled back, output prices tend to stay high in many pricing adjustments—output is the biggest cost driver and the source of price rigidity.

    3. Cache hit costs. If the service supports context caching (prefix caching), repeated prefixes can reuse KV cache results, and the cached portion is billed at a unit price far below that of regular input. These prices often have significant room for reduction because the marginal cost is minimal. For scenarios with fixed system prompts or multi-turn conversations, the cache hit rate directly determines the cost curve.

    4. Time-of-day multiplier. Peak prices are usually a fixed multiple of off-peak prices (e.g., 2x). This means the same task, scheduled to run off-peak, can theoretically cut costs in half.

    Real Cost Accounting: A General Estimation Model

    A public case shows that a workload totaling roughly 35 million tokens produced vastly different actual costs across billing periods: about 6 RMB before a price increase; about 11 RMB (up roughly 80%) when run off-peak after the increase; about 23 RMB (up more than 2.5x) when run at peak; and about 8 RMB off-peak and 16 RMB at peak after partial rollback. The case captures the most important lesson in LLM application cost management: the same workload can vary by up to 4x in cost depending on timing and billing plan choices.

    Developers can estimate costs themselves with a simple formula:

    1. # Cost estimation example
    2. def estimate_cost(input_tokens, output_tokens, cached_tokens,
    3. input_price, output_price, cached_price,
    4. peak_multiplier=2, peak=False):
    5. base = (input_tokens - cached_tokens) * input_price \
    6. + cached_tokens * cached_price \
    7. + output_tokens * output_price
    8. return base * (peak_multiplier if peak else 1)

    All prices are in “RMB per million tokens” and must be converted accordingly. It is recommended to encapsulate billing logic in a dedicated module, decoupling token counting from price configuration—when a provider changes prices, you only need to update the configuration to re-evaluate the cost of all workloads.

    Four Practical Paths to Cost Optimization

    1. Task triage and off-peak scheduling. Queue offline batch tasks (such as corpus cleaning, batch summarization, and evaluation runs) and execute them together during off-peak windows; only latency-sensitive online requests should go through the peak channel. A simple scheduled job can significantly reduce costs:

    1. # Scheduled task example: trigger batch processing at 2 AM daily
    2. 0 2 * * * python batch_infer.py --mode off-peak

    2. Improve cache hit rates. Front-load stable content (system instructions, document templates, few-shot examples) so that multiple requests share the same prefix, maximizing the cache hit ratio. Cached tokens are typically priced an order of magnitude lower than regular input, so even small improvements in hit rate yield substantial savings.

    3. Compress context and control output length. Since output unit prices are high, constraining generated content (e.g., setting max_tokens or requesting concise, structured output) delivers direct savings. Summarizing and trimming conversation history reduces both input and cache pressure at the same time.

    4. Build cost monitoring and alerting. At the application layer, log token consumption and estimated costs for every call, aggregate them by project and task, and set daily/weekly budget threshold alerts. When a pricing announcement is published, immediately replay real call data through the new rates to assess cost impact and adjust scheduling strategies.

    Conclusion

    LLM API pricing is in a period of dynamic adjustment, and the gap between off-peak and peak prices is essentially a price signal reflecting compute supply and demand. For enterprise users, rather than complaining about volatility, it is better to incorporate the pricing mechanism into architecture design: make billing parameters configurable, schedule tasks off-peak, leverage context caching, and make costs observable. With these four practices in place, even if prices change again, your application’s overall cost structure remains controllable and predictable.