Understanding LLM API Peak and Off-Peak Pricing: Token Types, Cache Hits, and Cost Optimization
This article breaks down how modern LLM API pricing works beyond the headline numbers. It explains the three token categories (input, output, and cached input), why output tokens cost more due to memory-bandwidth-bound autoregressive decoding, and how peak/off-peak multipliers shift the cost function from token volume alone to token volume multiplied by a time factor. You will also see how prefix caching reduces cost through hit rate rather than unit price, along with practical Python snippets for scheduling deferrable workloads and modeling monthly spend. The goal is to help you treat external pricing as a constraint and optimize prompt structure, batching, and scheduling using data.
1. The Symptom: A More Complex Price Table, a Clearer Underlying Logic
When a cloud provider recently revised its LLM service billing, many developers’ first reaction was that the increases looked arbitrary: the same model has different unit prices at different times of day, the gap between input and output token prices widened, and cached versus uncached input split into two tiers. But if you break the price table down by dimension, the adjustment is not a random hike. It standardizes the ratios among three token categories and layers a time-based scheduling signal on top.
The industry typically divides tokens into three types:
- Input tokens (prompt tokens): the context carried by the user request, including system prompts, conversation history, and retrieved document fragments.
- Output tokens (completion tokens): the body text generated by the model, decoded autoregressively one token at a time.
- Cached input tokens (cache hit tokens): the portion whose prefix is byte-for-byte identical to the previous request and whose intermediate computation can be reused directly.
The core of this adjustment is to bring two ratios back onto a single standard — output unit price / input unit price, and cache hit unit price / uncached input unit price — and then use a peak/off-peak coefficient to adjust the absolute price. Understanding this matters more than memorizing specific numbers, because prices are external variables; the ratios are the constants you actually rely on when making architecture decisions.
2. Why Output Tokens Are Inherently More Expensive
From a computational standpoint, the input phase is a single parallel forward pass: the entire prompt can be fed into matrix operations at once, yielding high hardware utilization. The output phase is token-by-token decoding, where each step depends on the previous result and cannot be parallelized, while repeatedly reading a growing context cache — a classic memory-bandwidth-bound scenario. Under the same compute cost, output throughput is often significantly lower than input throughput. Pricing output at several times the input price is therefore a natural mapping of the cost structure, not a marketing decision.
This leads to a direct engineering conclusion: controlling output length usually has a larger marginal impact on your bill than compressing an equal length of input. Short-output tasks such as summarization, structured extraction, and classification/tagging are inherently cheaper than long-form generation.
3. What Peak/Off-Peak Pricing Actually Adjusts
The load curve of an LLM inference cluster is very steep: requests are dense during daytime working hours, and resources sit idle in the early-morning trough. With a single flat price all day, off-peak compute is wasted, while peak capacity must be provisioned with redundancy. Peak/off-peak pricing essentially transmits the cloud platform’s resource scheduling signal up to the application layer, trading price elasticity for load shifting.
For developers, this means the cost function changes from “depends only on token volume” to “token volume × time-of-day coefficient.” Deferrable batch workloads therefore gain a clear optimization space:
# Illustrative: choose a scheduling window based on how deferrable the task isdef pick_window(task):if task.latency_sla_ms is not None:return "peak" # online interaction, prioritize latencyreturn "valley" # offline batch, wait for the off-peak windowdef estimate_cost(token_in, token_out, unit_price, valley_factor=0.5):# valley_factor is an illustrative value; refer to the official pricing page for actual figuresreturn (token_in * unit_price["in"]+ token_out * unit_price["out"]) * valley_factor
Note: the specific coefficients, effective time windows, and tiering rules should be taken from the provider’s official pricing page. This article does not provide any unconfirmed numbers.
4. Cache Reuse: The Underrated Cost Lever
The pricing logic for prefix caching is that the hit portion is billed at a lower unit price. Its benefit does not come from the unit price itself but from the hit rate. Engineering-wise, you can improve the hit rate in three ways:
- Fix the prompt structure: put system instructions, tool definitions, and examples at the very front and user variables at the end, ensuring the prefix is byte-for-byte identical.
- Append to context within a session rather than rewriting it: any modification to the historical prefix invalidates the cache.
- Group batch tasks by prefix: submit requests with the same template together, avoiding repeated cache flushing by different prefixes.
[fixed system prompt][fixed tool definitions][fixed examples] | [variable user input]└──────────────── cacheable prefix ────────────────┘
5. Cost Estimation and a Selection Methodology
Model the bill as executable code rather than reverse-engineering it from the month-end statement:
def monthly_cost(reqs, price, hit_rate, valley_ratio):total = 0.0for r in reqs:cached = r.in_tokens * hit_ratefresh = r.in_tokens - cachedp = price["valley"] if r.deferrable else price["peak"]total += (cached * p["cache"] + fresh * p["in"]+ r.out_tokens * p["out"])return total * valley_ratio
With this model, four types of decisions become quantifiable: whether it is worth investing engineering effort to compress prompts, whether to shift the entire non-real-time pipeline to off-peak hours, how much the cache hit rate must improve to cover the engineering hours, and whether to favor long context or chunked retrieval under this ratio structure.
6. Neutral Recommendation
In the face of a price adjustment, the rational approach is not to decide whether to “accept it or not,” but to treat the external price as a constraint and re-optimize your token structure and scheduling strategy. If you need finer-grained elasticity and cost control, you can also evaluate general-purpose model services and foundational capabilities such as batching, caching, and monitoring/alerting offered by cloud platforms like Baidu AI Cloud, benchmark them against your own load curve, and draw conclusions from data rather than from the price table.
