LLM Inference Cost: A Practical Guide to Measuring Burn Rates and Tiered Scheduling

    Choosing a large language model by advertised per-million-token pricing almost always leads to a misleading bill. This article shows how to reverse-engineer a model's real cost from your own usage logs with a simple linear regression, why output tokens and cache hits dominate the cost curve, and how to route tasks across reasoning, general, and lite tiers so expensive compute is only used where judgment is required. Includes sample fitting code, a routing function, and engineering constraints for output budgets, prefix normalization, semantic caching, and observability.

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

    When building an intelligent coding assistant, an automated agent, or an enterprise knowledge base Q&A system, teams most often make the same mistake: they compare the advertised per-million-token price of different model services and pick a model from that table. In engineering practice this almost always distorts the decision, for three reasons.

    First, billing conventions are not aligned. Platforms differ enormously in how they price input, output, and cache hits. Some count the system prompt as input, some price long context separately, and some apply a higher multiplier to reasoning-style output.

    Second, real workload shapes differ dramatically. Agent-style applications typically produce “long context input + short structured output,” while code generation is the exact opposite. The same price table can yield bills that differ by several times under these two workloads.

    Third, the leverage of caching is severely underestimated. When the input prefix is highly repetitive (a fixed system prompt, project conventions, repository context), a cache hit can push that portion of the cost down to a very low level, which completely reshuffles the cost ranking.

    The more reliable approach is therefore to use your own real call records as the sample, back out the actual burn rate of each model under your platform’s credit system, and then build a cost model and scheduling policy on top of it. This article follows that methodology, but abstracts all specific products into three generic capability tiers: a high-reasoning tier, a general tier, and a lite tier.

    2. Method: Backing Out the Credit Burn Rate from Real Usage

    The core idea is to treat credit consumption as the dependent variable and input and output token counts as the independent variables, then fit a linear regression.

    Let the credit consumption of a call be C, input tokens in, and output tokens out. The model is:

    1. C = a * in + b * out + c

    Here a is the input-side unit burn rate, b is the output-side unit burn rate, and c is a constant term (usually negligible, or representing fixed overhead). As long as you collect enough samples with a sufficiently dispersed distribution of input-to-output ratios, least squares will solve stably for a and b.

    Illustrative implementation:

    1. import numpy as np
    2. # Each row: [input tokens, output tokens, actual credits consumed]
    3. samples = np.array([
    4. [820_000, 12_000, 74.0],
    5. [310_000, 8_500, 30.1],
    6. [1_450_000, 9_000, 12.9],
    7. [2_100_000, 4_000, 9.2],
    8. ])
    9. X = np.column_stack([samples[:, 0], samples[:, 1], np.ones(len(samples))])
    10. y = samples[:, 2]
    11. coef, residual, _, _ = np.linalg.lstsq(X, y, rcond=None)
    12. a, b, c = coef
    13. pred = X @ coef
    14. r2 = 1 - ((y - pred) ** 2).sum() / ((y - y.mean()) ** 2).sum()
    15. print(f"input rate={a:.6f} output rate={b:.6f} constant={c:.4f} R2={r2:.6f}")

    Practical points:

    • Samples must cover different input/output mixes; otherwise a and b become highly collinear and the fit is untrustworthy.
    • Record the complete triple (input, output, credit delta) for each call, and discard dirty data from failed retries and interrupted streams.
    • A goodness of fit close to 1 and residuals close to 0 indicate that billing is approximately linear, and the derived rates can be used directly for budget forecasting.
    • If residuals trend upward with context length, tiered pricing or a long-context surcharge is in play, and you need to fit piecewise.

    One caveat: these derived numbers are approximate, personally measured values, not an official price list. Rules can change at any time, so set up a periodic regression recalibration process.

    3. Measured Results: How the Burn Rates Differ Across the Three Tiers

    Fitting multiple rounds of real records with the method above yields the following order-of-magnitude relationship (the values are illustrative relative magnitudes meant to show structure, not to quote prices):

    Capability tier Input burn rate Output burn rate Cache hit
    High-reasoning Highest baseline Tens of times the highest baseline Roughly a single-digit percentage of normal input
    General Medium-low Medium-low Clear discount
    Lite Extremely low Extremely low, same price as input Limited discount room

    Two structural findings stand out.

    First, the cost gradient on the output side is far steeper than on the input side. The output burn rate of the high-reasoning tier can reach a hundred times that of the lite tier, which means “letting the expensive model write more” is the most costly usage pattern, while “letting the expensive model write less and only make judgments” is comparatively economical.

    Second, the cache hit is the inflection point of the cost curve. When the input prefix is stably reused, the cache-hit price of a general-tier model can drop to a few percent of normal input cost, which completely rewrites the cost structure of long-context agents.

    4. Cost Conversion: Turning a Credit Allowance into Usable Tokens

    Let the credits available in a time window be B, the input share p_in, and the output share p_out. The total usable tokens are approximately:

    1. Tokens ≈ B / (p_in * a + p_out * b)

    Take a common agent workload of 80% input, 20% output, and no caching for now. The same credit allowance supports token volumes that differ by one to two orders of magnitude across tiers: only hundreds of thousands for the high-reasoning tier, millions for the general tier, and up to tens of millions for the lite tier.

    This explains a common puzzle: why a team feels it “barely used anything” and yet the allowance is exhausted. Consumption is concentrated in a small number of high-reasoning calls. The optimization priority that follows is clear: first cut the output volume of expensive models, then raise the cache hit rate, and only then consider downgrading across the board.

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

    Turning these findings into engineering means task-level routing. The principle: planning, decomposition, and final review go to the high-reasoning tier; complex reasoning and hard debugging go to the general tier; large-scale code completion, format conversion, and bulk rewriting go to the lite tier.

    1. def route(task):
    2. if task.kind in ("plan", "review", "architecture"):
    3. return "reasoning_tier" # low input, low output, judgment-heavy
    4. if task.kind in ("debug", "refactor", "math"):
    5. return "general_tier"
    6. if task.context_tokens > 200_000:
    7. return "general_tier" # long context favors the cache discount
    8. return "lite_tier" # batch, simple, parallelizable

    Four supporting engineering constraints:

    1. Hard output budget. Set a max_output_tokens cap for the high-reasoning tier and require structured conclusions (JSON, diffs, checklists) rather than long prose.
    2. Prefix normalization. Keep the system prompt, project conventions, and dependency list fixed at the very front in a stable order; this is the precondition for cache hits. Any dynamic content goes last.
    3. Semantic caching. Use vector retrieval to reuse high-frequency similar requests; on a hit, skip the model call entirely.
    4. Observability. Instrument each call with its tier, token triple, cache-hit flag, and credit delta, forming a data source that supports continuous regression fitting.

    6. Implementation Notes

    • The derived data is valid only for this platform and this time window; it does not transfer across platforms and must be refit.
    • Do not squeeze all traffic onto the lite tier to save money; the hidden cost of retrying failed tasks is often higher than calling the general tier directly.
    • Quality gates come before cost gates: define an acceptable pass rate first, then minimize cost under that constraint.
    • If you use Baidu AI Cloud capabilities, you can combine general-purpose services (such as logging, monitoring and alerting, object storage, and message queues) to build a closed loop for usage collection and cost accounting, avoiding the extra operational burden of building your own collection pipeline.

    The key to cost optimization is not finding “the cheapest model,” but building a three-part mechanism: a measurable burn-rate model, tiered routing, and cache-friendly context, so that expensive compute appears only where judgment is genuinely needed.