LLM Inference Cost: Benchmarking Real Usage and Tiered Scheduling in Practice

    Summary: A practical guide to controlling large language model inference costs by measuring actual consumption rates instead of comparing advertised per-token prices. It explains how to fit input, output, and cache-hit rates from real usage samples with least squares, how the cost gradient across model tiers affects capacity planning, and how to build a tiered routing layer that assigns high-cognitive tasks to flagship models and repetitive execution to lightweight ones. It also covers engineering guardrails such as output caps, cacheable prefixes, per-task budgets, observability, and periodic recalibration, plus common pitfalls that lead to runaway spending.

    1. Background: Why a Cheap Unit Price Does Not Mean a Cheap Bill

    Once a team connects large model capabilities to real business workflows, the first pressure it feels is usually not output quality but the bill. One easily overlooked fact is that the unit cost gap between model tiers can easily reach two orders of magnitude. Meanwhile, a single seemingly ordinary agent task may involve a dozen rounds of tool calls and long-context replay, ultimately amplifying cost to a level that is hard to predict.

    So the first step in cost governance is not comparing “how much per million tokens,” but building a reverse path from real usage to cost. Only when the consumption rate is measured accurately can model selection, task tiering, and caching strategy have reliable inputs.

    Note that all numbers in this article come from fitting personal usage records. They illustrate the methodology and do not represent any official billing rules. Pricing methods vary across platforms and over time, so recalibrate against your own bills when applying this in practice.

    2. Method: Deriving Unit Consumption Rates from Real Usage

    The idea is straightforward: fix a budget cycle, record the input tokens, output tokens, cache-hit tokens, and credit deductions for every call, then fit the coefficients with least squares.

    1. # Illustration: fit input/output/cache consumption rates from multiple observed samples
    2. # rows: [(input_tokens, output_tokens, cached_tokens, credits), ...]
    3. import numpy as np
    4. def fit_rates(rows):
    5. X = np.array([[i, o, c] for i, o, c, _ in rows], dtype=float)
    6. y = np.array([cr for *_, cr in rows], dtype=float)
    7. rates, *_ = np.linalg.lstsq(X, y, rcond=None) # unit: credits / token
    8. pred = X @ rates
    9. residual = float(np.abs(pred - y).max())
    10. r2 = 1 - ((y - pred) ** 2).sum() / ((y - y.mean()) ** 2).sum()
    11. return rates, r2, residual

    When the samples cover a sufficiently diverse mix of context lengths and output lengths, the goodness of fit can approach 1 and the residual approaches zero, which shows the model is piecewise linear and predictable. This is critical: only when cost turns from a “black box” into a “computable quantity” does engineering optimization become possible.

    There are three pitfalls to avoid in practice. First, the samples must include both very short and very long requests; otherwise the input coefficient is not identifiable. Second, record cache-hit volume separately, since it often differs from normal input by one to two orders of magnitude. Third, keep the measurement scope fixed, and mark the consumption of failed retries and interrupted streams separately to avoid contaminating the fit.

    3. Observed Results: The Cost Gradient Across Tiers

    Under a consistent measurement scope, the fitted relative consumption rates show a clear gradient (the figures below are relative magnitudes for illustration, not official data):

    • Flagship reasoning tier: input is tens of times the baseline tier, output is around a hundred times the baseline;
    • Mid-to-high-end general tier: input and output are several to a dozen times the baseline;
    • High-speed lightweight tier: input is a few thousandths of the baseline, output is close to input;
    • Minimal tier: input and output are priced the same, at the lowest range.

    Two conclusions are worth remembering. First, output is far more expensive than input; output cost on the flagship tier can reach around two hundred times that of the minimal tier, which means “having a large model write a thousand more words” often hurts the budget more than “having it read ten thousand more words.” Second, cache hits can compress input cost to roughly two percent of normal input; in repeated long-context calls, this is the single largest gain.

    4. Converting Consumption Rates into Usable Capacity

    Assume a budget of 60,000 credits per five hours and 600,000 credits per week, a task mix of 80% input and 20% output, and no caching for now. The token volume each cycle can support is roughly:

    Tier Approx. tokens per 5 hours
    Flagship reasoning tier ~400K
    Mid-to-high-end general tier ~1.2M
    High-speed lightweight tier ~12M
    Minimal tier ~30M

    The practical value of this table is capacity planning: with the same budget, the tier you choose directly determines whether you “run a few dozen complex tasks a day” or “run tens of thousands of simple rewrites a day.” Putting the wrong task on the wrong tier is the most common root cause of cost overruns.

    5. Tiered Scheduling: Expensive Models Think, Cheap Models Execute

    The strategy boils down to one sentence: concentrate high-cognitive-load steps on strong models, and push repetitive, verifiable execution down to lightweight models.

    • Flagship tier: task decomposition, solution planning, final review, and difficult troubleshooting;
    • Mid-to-high-end tier: complex reasoning, cross-file refactoring, and steps that require strong instruction following;
    • High-speed lightweight tier: the main execution workhorse, such as batch rewriting, formatting, and unit test completion;
    • Minimal tier: batch simple tasks such as classification and tagging, field extraction, and template filling.

    In practice, introduce a routing layer that decides with rules first and the model second, so you avoid calling a strong model for triage every time:

    1. def route(task):
    2. if task.risk == "high" or task.needs_plan:
    3. return "tier_reasoning" # strong reasoning tier
    4. if task.files_touched > 3:
    5. return "tier_general" # general tier
    6. if task.output_tokens > 4000:
    7. return "tier_fast" # high-speed tier, suppress output cost
    8. return "tier_lite" # minimal tier

    Three engineering constraints should go with it. First, set a hard cap on output length to prevent runaway output cost on the flagship tier. Second, front-load stable system prompts, project conventions, and API documentation as a cacheable prefix to maximize cache hits. Third, set a credit budget and a circuit-breaker threshold for each task, and automatically downgrade to the next tier and retry when the limit is exceeded.

    6. Observability and Continuous Calibration

    Cost governance needs a closed loop. Instrument the gateway layer with unified logging that records at least the request ID, tier, input/output/cache tokens, credit deduction, task success or failure, and retry count, and connect it to monitoring, alerting, and log services to build a trend dashboard. Rerun the fit weekly with new samples and watch for coefficient drift; if the residual suddenly grows, it usually means the platform’s pricing scope or caching policy has changed and recalibration is needed.

    If you use Baidu AI Cloud capabilities to carry this pipeline, you can deploy the router and gateway on the container platform, use object storage to retain call details, and use log services with monitoring and alerting to build the cost dashboard and threshold notifications, turning “reviewing the bill after the fact” into “controlling the budget in real time.”

    7. Common Pitfalls

    • Comparing only unit price, not structure: with different input/output ratios, the conclusion can completely reverse;
    • Ignoring caching: repeated long-context calls without caching effectively mean voluntarily paying tens of times more input cost;
    • Having strong models do batch execution: cost rises linearly while quality gains are minimal;
    • Setting no output limit: the price amplification effect on the output side is the most easily underestimated;
    • Calibrating once and reusing forever: pricing and caching rules can change, so periodic regression is needed.

    8. Conclusion

    The essence of cost optimization is not driving down prices, but scheduling model capability as a tiered resource: measure the consumption rate first, convert it into capacity, then use routing, caching, and budget guardrails to reserve the compute of strong models for the steps that genuinely need thinking. Following this approach, teams can typically reduce per-task cost by an order of magnitude while keeping output quality roughly unchanged.