LLM Inference Pricing: From Token Accounting to Peak-and-Off-Peak Cost Governance

    LLM inference costs are shaped by far more than the advertised price per million tokens. This article explains how input and output tokens, cache hits, pricing periods, model tiers, retries, and batch efficiency affect total spend. It also covers cost-aware scheduling, observability, routing, budgeting, and practical controls for making inference costs measurable and manageable.

    LLM Inference Pricing: From Token Accounting to Peak-and-Off-Peak Cost Governance

    1. From “API Pricing” to a Cost Meter: Billing Granularity Is Increasing

    In the past, teams evaluating LLM inference costs often focused on a single figure: the price per million tokens. This coarse-grained view may be sufficient at low request volumes. Once inference becomes part of a production system, however, cost is no longer a static unit price. It is influenced by input length, output length, cache hits, request timing, model tier, retry counts, batch efficiency, and other factors.

    Public industry research shows that the price of accessing models with a given level of general-purpose capability has fallen by an order of magnitude over roughly two years. Lower prices do not eliminate the cost problem. Instead, they indicate that inference is moving from a scarce resource used experimentally to a large-scale infrastructure service.

    When an individual request becomes inexpensive, business teams tend to call models more frequently, provide longer context, and build more complex workflows. Total spending can still rise rapidly. The key is therefore not memorizing a particular unit price, but equipping intelligent applications with a “cost meter.” Every request should be measurable and attributable:

    • How many input and output tokens did it consume?
    • How many tokens were served from cache?
    • Did it run during a peak or off-peak period?
    • Which model tier handled it?

    Only with this information can teams optimize inference spending effectively.

    2. Understanding the Billing Model: Input, Output, and Cache Hits

    Token usage is the most common basis for LLM API billing. Input tokens include prompts, conversation context, tool results, and other content sent to the model. Output tokens are generated by the model. Most platforms price input and output separately, and output tokens are typically more expensive because autoregressive generation requires sequential decoding, resulting in higher compute and latency costs.

    A more granular billing dimension is cache usage. For requests with a shared prefix—such as a fixed system prompt, document sections used in long-document question answering, or project context in a coding assistant—some platforms can cache reusable intermediate states.

    Cached input tokens are charged at a lower rate, while uncached input tokens use the standard input price. Caching does more than reduce cost: it can also lower time to first token and improve throughput consistency.

    Caching is not free by default, however. Prefix changes, context reordering, and session-isolation policies can all affect the hit rate. From an engineering perspective, teams should keep prompt structures stable, place variable content later in the context, put shared instructions first, and create reusable context templates for different business domains.

    Peak and off-peak pricing introduces time as another cost dimension. Some platforms set off-peak prices at approximately half of peak prices. This creates an incentive to move batch processing, offline evaluation, data cleaning, and report generation to less expensive periods.

    For interactive workloads, peak and off-peak pricing means capacity planning must distinguish between requests that require real-time responses and those that can tolerate delays. For offline jobs, the scheduler should be cost-aware and select lower-cost periods when deadlines allow.

    3. Engineering Implications of Peak and Off-Peak Pricing: Turning the Scheduler into a Cost Optimizer

    Peak and off-peak pricing is not simply a matter of “running jobs at night.” It requires task classification and deadline management. Requests can generally be divided into three categories:

    • Interactive requests: Sensitive to latency and subject to an SLA. They should be prioritized rather than delayed solely to reduce the unit price.
    • Near-real-time requests: Able to tolerate delays of several minutes. They can be rate-limited during peak periods and accelerated during off-peak periods.
    • Offline batch jobs: Able to tolerate delays of several hours. They should be scheduled as much as possible outside peak periods.

    The scheduler must consider cost, latency, failures, retries, and quotas at the same time. A practical approach is to assign each task a deadline, priority, and cost_sensitivity value. Scheduling should first satisfy hard deadlines, then select the option with the lowest estimated cost among the available time windows.

    Splittable workloads can be scheduled in partitions, preventing a single long-running task from crossing a peak/off-peak boundary and making cost estimation inaccurate. Retries should use exponential backoff and a maximum retry count to prevent failed requests from repeatedly consuming tokens during expensive peak periods.

    4. Cost Observability: Governance Starts with Measurement

    The first step in installing a “cost meter” for AI systems is establishing cost observability. Teams should collect token and spending metrics by business line, model tier, request type, time period, and cache status. Estimated costs should also be reconciled with billing data on a regular basis.

    Important metrics include:

    • Total input tokens
    • Total output tokens
    • Percentage of input tokens served from cache
    • Average output length per request
    • Retry rate
    • Percentage of requests with oversized context
    • Peak and off-peak request distribution
    • Cost per unit of business outcome

    In production, general-purpose cloud capabilities such as logging and monitoring can be used to collect and display these metrics. For example, organizations may use capabilities provided by Baidu AI Cloud where appropriate, based on their existing technology stack and compliance requirements.

    A cost dashboard should not only show how much was spent. It should also explain where the money went and which requests could have been handled more economically.

    For example:

    • If a summarization workflow produces much longer outputs than expected, the prompt may not sufficiently constrain response length.
    • If a question-answering workflow has a low cache hit rate, its context template may be changing too frequently.
    • If batch jobs frequently run during peak periods, the scheduler may not assign enough weight to cost.

    5. Optimization Checklist: From Prompt Design to Model Routing

    1. Prompt and context governance: Place stable system instructions first and variable content later. Remove irrelevant context, use segmented retrieval for long documents instead of concatenating everything, and define output formats and maximum lengths to reduce unnecessary output tokens.

    2. Cache-friendly design: Keep shared prefixes stable, isolate caches by business domain, and avoid placing timestamps, random values, or user-specific identifiers in shared prefixes.

    3. Model-tier routing: Route simple classification, extraction, and format-conversion tasks to lightweight tiers. Use higher-performance tiers for complex reasoning and long-form generation. Set confidence thresholds and fallback strategies so that every request does not default to the highest tier.

    4. Batch processing and off-peak scheduling: Schedule offline jobs during less expensive periods whenever possible. Combine requests that can be processed together. Set cost limits and deadlines for batch jobs to prevent excessive queuing even during low-price periods.

    5. Budgets and alerts: Set daily or weekly budgets for each business line. Trigger alerts for abnormal spending increases, declining cache hit rates, and output-length drift. When a budget is exhausted, trigger degradation, rate limiting, or manual approval.

    6. Retry and failure management: Distinguish retryable errors from non-retryable errors. Avoid indefinitely retrying tasks that generate very long outputs. Record token consumption for failed requests so that teams understand that failed requests can still incur costs.

    6. Pseudocode: Cost Estimation and Monitoring Metrics

    The following pseudocode illustrates the calculation logic only. Pricing parameters should be injected from the applicable contract and platform rules; they do not represent any specific vendor’s pricing.

    1. # Cost estimation pseudocode
    2. def estimate_cost(req, prices, is_peak=True):
    3. input_tokens = req.input_tokens
    4. cache_hit = min(req.cache_hit_tokens, input_tokens)
    5. cache_miss = input_tokens - cache_hit
    6. output_tokens = req.output_tokens
    7. period_factor = 1.0 if is_peak else prices["off_peak_factor"]
    8. cost = period_factor * (
    9. cache_hit * prices["input_cache_hit"]
    10. + cache_miss * prices["input_cache_miss"]
    11. + output_tokens * prices["output"]
    12. ) / 1_000_000
    13. return cost
    14. # Budget alert pseudocode
    15. def check_budget(business_line, estimated_cost, budget):
    16. if estimated_cost > budget.remaining:
    17. trigger_alert("budget_exceeded", business_line)
    18. return "degrade_or_confirm"
    19. return "allow"

    Recommended general-purpose metrics include:

    • tokens_input_total{model_tier,cache_hit}
    • tokens_output_total{model_tier}
    • cache_hit_ratio
    • cost_estimated_total{model_tier,period}
    • request_retry_total
    • p95_latency
    • budget_remaining

    These metrics should support aggregation by business line and reconciliation against billing records.

    7. Risks and Conclusion

    Fine-grained billing creates opportunities for optimization, but it also increases governance complexity. Teams should monitor changes to pricing rules, cache invalidation, uncontrolled output length, tasks that cross peak and off-peak boundaries, and false-positive budget alerts.

    The most important principle is not to sacrifice reliability for cost savings. Interactive workloads should not time out because of off-peak scheduling, and critical tasks should not suffer unacceptable quality degradation because of model fallback or routing.

    LLM inference is entering an era of fine-grained pricing. Tokens are the unit of measurement, cache hits are a cost lever, time periods are scheduling signals, and cost observability is the foundation of governance. Installing a “cost meter” for AI is not about restricting usage. It is about making every inference budget clear, controllable, and valuable.