Measuring LLM Inference Costs and Tiered Scheduling in Practice

    This article shows how to turn a vague sense that LLM usage is expensive into explainable numbers. It explains how to break a bill down into input, output, and cache-hit token usage, fit per-tier consumption rates from historical call logs, and validate the model with controlled experiments. It then compares the cost gradient across four model tiers, converts a fixed quota into the token volume each tier can support, and outlines a tiered routing strategy, caching and context practices, observability dashboards, guardrails, and common mistakes. The figures are order-of-magnitude references, not official pricing.

    1. Why You Still Need to Do the Math Under Pay-as-You-Go

    When teams adopt LLM services, they often focus on the listed unit price and overlook the real input-to-output ratio, cache hit rate, and retry overhead in production traffic. The result is a quota that runs dry near the end of the month, with no clear explanation of where the spend went. The first step toward a reliable technical choice is to decompose the bill into an interpretable model: treat total consumption as a weighted sum of three token categories—input, output, and cache hits—then run a regression fit against historical call logs to back out the unit consumption rate for each model tier.

    A minimal working estimation script looks like this (illustrative; adjust field names to your own logs):

    1. def estimate_cost(input_tok, output_tok, cache_hit_tok, rate):
    2. return (input_tok * rate["in"]
    3. + output_tok * rate["out"]
    4. + cache_hit_tok * rate["cache"])
    5. # rate holds the unit consumption rates fitted from historical data
    6. rates = {
    7. "tier_reason": {"in": 8.0, "out": 40.0, "cache": 0.16},
    8. "tier_general": {"in": 3.2, "out": 11.2, "cache": 0.064},
    9. "tier_fast": {"in": 0.4, "out": 0.8, "cache": 0.008},
    10. "tier_lite": {"in": 0.2, "out": 0.2, "cache": 0.002},
    11. }

    2. Measurement Method and Fit Validation

    The point of measurement is not to guess prices but to obtain clean data from controlled experiments. Keep the prompt template, temperature, and maximum output length fixed, then collect data in three rounds: input-heavy tasks (summarization, classification), output-heavy tasks (long-form generation), and mixed tasks (code edits with context). Record the three token counts and the quota deducted in each round, then apply a least-squares fit.

    When the goodness of fit approaches 1 and the residuals approach zero, the consumption model closely matches the real bill, and the back-derived rates become actionable. Systematic deviation usually comes from three sources: retries and timeouts not being counted, system prompts being billed repeatedly, and partial billing caused by interrupted streaming output. Account for these three items before fitting again, and the error will converge noticeably.

    3. Cost Gradient Across Four Model Tiers

    The typical gradient obtained with the method above (in quota consumed per million tokens, order-of-magnitude illustration only):

    • Reasoning tier: input about 80,000, output about 400,000;
    • General balanced tier: input about 32,000, output about 112,000;
    • Fast execution tier: input about 4,000, output about 8,000, cache hit about 80;
    • Lite batch tier: input and output both about 2,000.

    The most striking gap is between the two ends: the reasoning tier’s output cost can reach roughly two hundred times that of the lite tier, while the fast execution tier’s input cost drops to about 2% of the normal value on a cache hit. The relationship between “model tier” and “cost” is therefore not linear but a matter of orders of magnitude, so selection must be tiered by task.

    4. Quota Conversion: How Much Work Each Tier Can Do

    Assume a quota of 60,000 per 5 hours and 600,000 per week, with an input-to-output structure of 8:2 and caching ignored for now. The token volume each tier can support is roughly: reasoning tier about 417,000, general balanced tier about 1.25 million, fast execution tier about 12.5 million, and lite batch tier about 30 million. The same budget buys output capacity that differs by tens of times.

    The conversion formula can be applied directly:

    1. budget = 60000
    2. ratio_in, ratio_out = 0.8, 0.2
    3. tokens = budget / (ratio_in * rate["in"] + ratio_out * rate["out"])

    5. Tiered Scheduling Strategy

    The conclusion is simple: expensive tiers do the “thinking,” cheap tiers do the “doing.”

    • Planning and final review: the reasoning tier, for breaking down requirements, drafting plans, and reviewing risks;
    • Complex reasoning: the general balanced tier, for multi-constraint reasoning and cross-file analysis;
    • Main execution: the fast execution tier, carrying the bulk of coding and rewriting;
    • Batch simple tasks: the lite batch tier, such as format conversion, tag extraction, and batch summarization.

    In practice, introduce a unified gateway layer that routes by task label and records tokens and quota deductions for every call, forming a data source that supports continuous regression.

    6. Caching and Context Management

    Cache hits are the highest-leverage part of cost optimization. Stable system prompts, fixed tool descriptions, and reusable knowledge snippets should be placed up front and kept unchanged, with the variable parts at the end, to raise the prefix reuse rate. Compressing conversation history and retrieving on demand instead of concatenating everything also significantly reduces input-side overhead.

    7. Observability and Guardrails

    No measurement, no optimization. Build three dashboards: cost per task, cache hit rate, and retry rate. Then set guardrails: a per-task token cap, a daily quota circuit breaker, and alerts on abnormal consumption. When the retry rate climbs, investigate prompt stability first rather than switching straight to a more expensive tier.

    8. Common Mistakes

    First, looking only at unit price and not at structure, ignoring scenarios with a high output share. Second, treating caching as a default capability without ordering the context. Third, budgeting with averages, which hides the extreme consumption of long-tail tasks. Fourth, betting everything on a single tier with no fallback path.

    9. Conclusion

    The essence of cost governance is turning “feels expensive” into explainable numbers. Fit the rates from logs first, then route by task tier, and combine that with cache management and observability guardrails to amplify effective output by an order of magnitude under a fixed quota. Note that the figures above are order-of-magnitude references back-derived from personal measurement, not official pricing; the rules may change at any time, so defer to your actual bill.