LLM API Peak and Off-Peak Pricing: A Practical Guide to Cost Optimization

    A static per-token price no longer reflects what you actually pay. This article breaks down time-based LLM API pricing into a practical cost model built from three token segments and a time-of-day multiplier, then walks through a reproducible coding-session example. It covers four actionable optimizations—cutting output tokens, stabilizing the cacheable prompt prefix, shifting batch jobs off-peak, and routing by task difficulty—plus engineering notes for connecting coding tools through an Anthropic-style endpoint and a lightweight gateway, and a pre-launch checklist for cost control.

    1. The Bottom Line: Static Unit Prices No Longer Describe Real Cost

    When budgeting, many teams grab a single “price per million tokens” and multiply it by call volume. That linear model systematically distorts real cost under today’s time-based billing. A more complex pricing structure has emerged across the industry: the same model has two price tiers within a single day—peak and off-peak—where the peak price is typically twice the off-peak price. Cache-hit tokens are priced separately and far lower than new input. Output tokens cost significantly more than input, commonly around three times as much.

    So when you ask “what fraction of the original price is this discount,” you first need to confirm three things: when the price takes effect, whether a time-of-day multiplier is applied, and whether input, output, and cache are priced as three separate segments. The “one-quarter price” mentioned in the original text was the product of an early promotional discount becoming permanent, and that entire price list was retired once time-based pricing launched. This is a classic case of “estimating a new bill with an old answer,” and the underestimate often exceeds half.

    2. Three Multipliers in the Cost Model

    Abstracting the bill into a formula is more durable than memorizing specific numbers:

    1. Total cost = (new input × P_in + cache hits × P_cache + output × P_out) × K_time
    • P_in: the unit price of new input tokens, the most expensive input tier;
    • P_cache: the unit price of cache hits, usually a few percent of P_in, a difference of two orders of magnitude;
    • P_out: the output unit price, generally 2–3 times P_in;
    • K_time: the time-of-day multiplier, 1 at peak and 0.5 off-peak (definitions vary by vendor, but “peak doubles the price” is the common pattern).

    Peak hours generally fall on weekday daytime—roughly 9 a.m. to 12 p.m. and 2 p.m. to 6 p.m. in China Standard Time, which is exactly the window when coding activity is most concentrated. Weekends and public holidays are usually billed at the off-peak rate all day. This means your cost peak overlaps heavily with your work peak, and without shifting load off-peak, your bill will inevitably balloon.

    3. A Reproducible Example

    Take a typical coding session: 50,000 new input tokens, 200,000 cache hits, and 30,000 output tokens.

    • Off-peak: about $0.097;
    • Peak: about $0.19;
    • Early “one-quarter price” period: about $0.05.

    The conclusion is direct: for the same task, off-peak costs twice as much as the early price, and peak costs four times as much. Note that output is only 30,000 tokens here, yet it contributes the bulk of the cost—which is exactly where the next optimization comes from.

    4. Four Actionable Optimizations

    1) Cut output, don’t pinch input. Output costs three times input, so saving 1,000 output tokens is worth roughly saving 3,000 input tokens. Concretely: ask the model for a diff instead of the full file, constrain the scope of changes, turn off verbose explanations, and use structured formats to constrain replies.

    2) Turn stable context into cache. Content that stays the same every turn—system prompts, project conventions, repository skeletons—should be fixed at the prefix of the request so the server-side prefix cache hits reliably. The cache-hit price is only a few percent of new input, so reusing long context yields order-of-magnitude savings. Conversely, putting a timestamp or random ID at the very front of the prompt invalidates the entire prefix, and all cached content degrades to new input.

    1. # Bad example: volatile content pollutes the prefix
    2. [current time 2026-11-23T10:21:07] [system prompt...] [repo context...] [user question]
    3. # Good example: stable prefix + trailing variable
    4. [system prompt...] [repo context...] [user question] [current time]

    3) Run batches off-peak. Tasks that don’t require sub-second responses—batch refactoring, full test runs, documentation generation, log analysis—should all be scheduled for nighttime or weekends to take the off-peak multiplier directly. Keep interactive coding at peak, and spend the peak budget on scenarios that genuinely need low latency.

    4) Route models by difficulty. Everyday code edits, test scaffolding, and boilerplate are light workloads; a smaller or faster version in the same family is enough, and its price is usually around one-quarter of the flagship model. Switch back to the flagship for complex reasoning and cross-module refactoring. The key to routing is that the routing layer can select automatically by task label, rather than relying on someone to change config manually.

    5. Engineering Notes for Connecting to AI Coding Tools

    Mainstream AI coding tools typically offer two protocol styles of access endpoints: a generic OpenAI style and an Anthropic style. The value of the latter is that you can fill in the tool’s agreed ANTHROPIC_BASE_URL directly, put the target model identifier in the model name field, and add an auth token to get it running—no client changes required.

    Illustrative configuration (replace the placeholders with your own gateway address and key):

    1. export ANTHROPIC_BASE_URL="https://<your-gateway-address>/anthropic"
    2. export ANTHROPIC_AUTH_TOKEN="<your-token>"
    3. # Fill in the model identifier with the name actually exposed by the gateway

    A more robust approach in production is to build a lightweight gateway that consolidates three things: unified authentication and key rotation, model routing by task label, and telemetry that records the three-segment token usage and time-of-day multiplier for every request. With that telemetry, cost attribution becomes accounting rather than estimation.

    6. If You Host This Capability in the Cloud

    When building or purchasing LLM services, you can combine several general cloud product capabilities to lower total cost and operational overhead: use a container platform to host inference and gateway services with elastic scaling, use object storage to archive long context and datasets, use a message queue to stagger and smooth batch tasks off-peak, use a logging service to retain call details for cost auditing, and use monitoring and alerting to set threshold alerts on token consumption and spend. Baidu AI Cloud offers corresponding product forms in these general categories, and you can select based on your own scale, but the core principle stays the same: build the measurable telemetry first, then talk about optimization.

    7. Pre-Launch Checklist

    • Does the price list state the effective date and peak-hour definition (including time zone)?
    • Has the cost model been rebuilt around three-segment pricing plus the time-of-day multiplier?
    • Is the prompt prefix stable and cacheable?
    • Are there batch jobs still running at peak?
    • Is there model routing by difficulty?
    • Are budget alerts and per-request limits set on spend?

    Bake these items into your process, and a pricing-structure change turns from a “bill surprise” into an “expected parameter change.”