LLM Peak and Off-Peak Pricing: A Practical Guide to Task Scheduling

    This article explains how time-of-day (peak and off-peak) pricing for large language model APIs changes the way developers should think about cost optimization, and how to build a scheduling layer around it. It covers a cost model for shifting deferrable traffic to cheaper windows, a three-tier classification scheme based on delay tolerance (interactive, near-line, and offline), a minimal implementation using delayed queues, token buckets, and idempotency keys, and complementary savings from batching, prefix caching, and context compression. It also outlines the observability metrics and capacity planning practices needed to run such a system safely, along with common pitfalls to avoid.

    1. Background: A Late-Night Release and a Pricing Notice

    A model platform quietly shipped a production model update late at night and published the announcement the next day. The notice also previewed a change to API billing: starting at a certain point, pricing would become time-of-day based, with two peak windows during the day and off-peak pricing for all remaining hours set at half the peak rate. The stated reason was to allocate compute resources more sensibly and to encourage developers to schedule workloads flexibly around their business needs.

    From an engineering standpoint, these two events are really one event: inference capacity supply fluctuates noticeably over the course of a day, while demand is concentrated in daytime hours. Using a price signal to push deferrable load into the night is a more economical way to shave peaks than simply adding capacity. For developers, this shifts part of the cost-optimization focus from “pick a cheaper model” to “run the request at the right time.”

    It is worth noting that this kind of “sudden update” is becoming the norm. When serving developers globally, a late-night release avoids peak business hours across multiple time zones at once and reduces release risk. It is also a reminder that any integration must treat model version management as something observable and rollback-capable, rather than assuming the upstream stays fixed.

    2. The Cost Model: Do the Math First

    Time-of-day pricing turns unit price from a scalar into a function of time. Let the peak price be p and the off-peak price be 0.5p, with H peak hours in a day. The expected cost of any request then depends on which window its execution time falls into.

    For a workload with a fixed daily request volume, if every request lands in a peak window, the daily cost is:

    1. C_peak = N * T * p

    If a fraction α of deferrable requests is moved to off-peak hours, then:

    1. C = N * T * p * (1 - 0.5 * α)

    In other words, every 10% of deferrable traffic shifted reduces total cost by roughly 5%; shifting 60% reduces cost by 30%. This linear relationship defines the ceiling on optimization: α can never be 1, because interactive requests inherently fall in daytime peaks. The variable that really determines the payoff is therefore how much of the workload is offline and can wait.

    Note that the formulas above are a general modeling approach. Actual unit prices, window boundaries, and discount ratios should follow the latest announcement from the platform you integrate with. Do not hard-code them; make them configurable.

    3. Task Classification: Tag Requests by Deferrability

    The first step is not writing a scheduler but labeling requests. In practice, requests can be grouped into three tiers by how much waiting users will tolerate:

    • Interactive (S0): chat completion, code completion, search query rewriting. Requires sub-second time-to-first-token, must run in peak windows, and needs streaming output.
    • Near-line (S1): document summarization, single-record extraction, ticket classification. Tolerates seconds to minutes; can run at the tail of a peak window or early in an off-peak window.
    • Offline (S2): batch content moderation, log attribution, dataset labeling, model evaluation regressions, report generation. Tolerates tens of minutes to hours, and is the main source of peak/off-peak arbitrage.

    When rolling out classification, apply the label centrally at the gateway layer and propagate it with the request through rate limiting, retries, and billing metrics. Otherwise each team implements its own scheme and the definitions drift apart.

    1. {
    2. "request_id": "r-20260817-0001",
    3. "tier": "S2",
    4. "deadline": "2026-08-17T09:00:00+08:00",
    5. "model": "chat-large",
    6. "stream": false,
    7. "fallback_tier": "S1"
    8. }

    The deadline is the core of the scheduling semantics: an S2 task is only guaranteed to finish before its deadline, not at a specific moment.

    4. Implementation: Delayed Queue + Token Bucket + Idempotency

    A workable minimal implementation has three parts: a delayed queue layered by tier, token buckets that allocate quota per tier, and an idempotency key that makes retries safe.

    1. # Illustrative pseudocode: time-of-day scheduling and fallback
    2. PEAK = [(9, 12), (14, 18)] # peak windows, must be configurable
    3. def is_peak(now): ...
    4. def price_factor(now): return 1.0 if is_peak(now) else 0.5
    5. def submit(task):
    6. if task.tier == "S0":
    7. return call_model(task) # run immediately
    8. if task.tier == "S1" and not is_peak(now()):
    9. return call_model(task) # drain during off-peak
    10. if task.deadline and task.deadline < now() + lead_time(task):
    11. return call_model(task) # near deadline, degrade to immediate
    12. enqueue_delayed(task, run_at=next_off_peak()) # defer to off-peak window
    13. return "queued"
    14. def worker_loop():
    15. for task in delayed_queue.poll_ready():
    16. if token_bucket.acquire(task.tier):
    17. call_model(task, idempotency_key=task.request_id)

    Three engineering details decide whether this works. First, idempotency: retries and queue redelivery cause duplicate billing, so deduplicate on a business-side unique key. Second, the safety margin lead_time on deadlines, which should be estimated from historical P95 latency to avoid “queued successfully but timed out anyway.” Third, the fallback path: when the off-peak backlog exceeds a threshold, allow S2 to consume peak quota, but under a separate quota cap so it cannot crowd out S0.

    5. Batching, Caching, and Context Compression

    Beyond the time dimension, three cost-reduction techniques are independent of time windows and stack well with peak/off-peak pricing.

    Batch merging. Combining several small requests into one call amortizes fixed overhead. The cost is higher latency, so this applies only to S1/S2. Watch the per-batch token limit and isolate failures: one bad record should not force the whole batch to rerun.

    Prefix cache reuse. Stable prefixes such as system prompts, tool definitions, and long documents recur across calls. A cache hit significantly reduces repeated computation and input billing. Put stable content first and volatile content last, keeping the prefix byte-for-byte identical.

    Context compression. Long context is a cost amplifier. For offline tasks, extract structured results first and send conclusions rather than the source text to the model. For multi-turn conversations, use rolling summaries that compress history into a summary block with a fixed budget.

    1. Stable prefix (system instructions + tool schema) -> cacheable
    2. Semi-stable section (conversation summary) -> refreshed periodically
    3. Volatile section (current user input) -> not cached

    6. Observability and Capacity Planning

    Time-of-day billing makes cost a first-class metric that needs real-time monitoring. At minimum, collect token usage and spend broken down by tier and time window, queue backlog duration, timeout rate, cache hit rate, and number of fallback triggers. With these metrics you can answer two key questions: whether off-peak capacity is being fully used, and whether peak quota is being encroached on by offline tasks.

    For capacity planning, build an intraday heatmap from historical request volume, estimate the peak shortfall and off-peak headroom, and set a target value for α accordingly. A pragmatic rollout is to enable off-peak shifting for S2 only, watch the cost curve and timeout rate for two weeks, then gradually bring in S1. During the transition, keep a switch in place that supports a one-click fallback to all-peak mode.

    7. Common Pitfalls

    • Hard-coding the discount ratio in business code, so you cannot keep up when the announcement changes.
    • Looking only at unit price and ignoring the cost of failures: off-peak timeouts and retries can raise actual spend.
    • Ignoring idempotency, so queue redelivery causes duplicate billing.
    • Shifting everything to off-peak indiscriminately, degrading the interactive experience and driving users away.
    • Assuming the model version stays stable, with no version pinning or regression evaluation, so silent upstream updates cause quality drift you cannot trace.

    8. Conclusion

    Peak/off-peak pricing hands part of the responsibility for compute scheduling back to developers, expanding “writing code” into “designing the time behavior of a workload.” The path to adoption is not complicated: request classification, a delayed queue, idempotent retries, caching and compression, and a metrics feedback loop cover most of the gains in five steps. What deserves sustained investment is the evaluation system: only with pinned versions and comparable metrics can the tradeoff between cost and quality rest on reliable evidence.