LLM Inference Cost Benchmarking and Tiered Model Routing in Practice

    This article explains why a low per-token price does not always translate into low total LLM inference cost, and how engineering teams can address the gap. It covers the three underestimated variables that shape real spending—input-to-output ratio, context cache hit rate, and the actual capability a task demands—and shows how to reverse-engineer your own unit consumption rates from real usage logs using a linear fit. It also illustrates order-of-magnitude cost differences across model tiers, presents a tiered routing strategy that assigns reasoning, refactoring, execution, and batch work to different model classes, and lists practical rollout advice and caveats for internal capacity planning.

    1. The Problem: Why a Cheap Unit Price Does Not Mean Low Total Cost

    In real-world AI applications and AI-assisted coding workflows, teams often run into the same puzzle: with an identical budget or credit allowance, one usage pattern burns through everything in a day, while another lasts an entire billing cycle. The reason is not the price list itself, but three underestimated variables: the input-to-output ratio, whether context caching actually hits, and the real capability a task requires from the model.

    When comparing options, many teams look only at the price per million tokens. Yet real production traffic is usually input-heavy, and a large share of that input is reusable: system prompts, codebase context, and specification documents. Once caching kicks in, the cost of the repeated input portion drops sharply, which can completely reshape the overall cost structure. So the first step in cost governance is not to cut the unit price, but to measure your own usage structure first.

    2. Method: Reverse-Engineering Unit Consumption from Real Usage Records

    A practical approach is to collect actual usage records over a period as samples, treat input tokens, output tokens, and cache-hit tokens as the independent variables, and treat credits or cost consumed as the dependent variable, then run a linear fit. If the model’s billing is itself linear, the fit will show a very high coefficient of determination (R² approaching 1) and residuals close to zero, meaning the reverse-engineered unit consumption rates nearly match the actual billing.

    A sample fitting and reverse-engineering flow looks like this:

    1. import numpy as np
    2. # X columns: [input tokens, output tokens, cache-hit tokens]
    3. X = np.array([
    4. [820_000, 200_000, 0],
    5. [1_500_000, 300_000, 400_000],
    6. [600_000, 150_000, 900_000],
    7. ])
    8. y = np.array([120, 210, 95]) # actual credits consumed
    9. coef, residual, rank, _ = np.linalg.lstsq(X, y, rcond=None)
    10. pred = X @ coef
    11. r2 = 1 - ((y - pred) ** 2).sum() / ((y - y.mean()) ** 2).sum()
    12. print("Unit consumption rates (input/output/cache):", coef)
    13. print("R^2:", r2, "residuals:", y - pred)

    It is worth stressing that these reverse-engineered values are approximations based on personal measurement, not any official price list, and the rules may change with model versions. Their value is giving a team an internal baseline that is comparable and can be regression-tested.

    3. Cost Magnitude Differences: Seeing the Structure by Order of Magnitude

    Among comparable technical options, output costs across model tiers can differ by two orders of magnitude. The output consumption of a flagship reasoning model can be more than a hundred times that of a lightweight model, while the input cost after a cache hit may fall to just a few percent of the normal input cost. Plugging a typical ratio (for example, 80% input, 20% output, ignoring cache for now) into the capacity formula:

    1. supportable tokens ≈ budget credits / (0.8 * input rate + 0.2 * output rate)

    The conclusion is intuitive: under the same credits, a flagship model may support only hundreds of thousands of tokens, a mid-tier model can reach the millions, and a lightweight model can reach tens of millions or more. This is not a quirk of one product, but a general pattern of the capability-cost gradient across general-purpose LLM services.

    4. Tiered Routing: Expensive Models Think, Cheap Models Do

    Given this gradient, a sound engineering strategy is to route tasks by cognitive complexity:

    • Flagship reasoning models: planning, architecture breakdown, final review, and hard reasoning;
    • Mid-tier general models: cross-file refactoring and complex logic implementation;
    • Lightweight fast models: the main execution workhorse, routine code generation, and completion;
    • Lowest-tier models: batch simple tasks such as formatting, comments, and unit-test skeletons.

    A simplified routing sketch:

    1. def route(task):
    2. if task.needs_deep_reasoning or task.is_final_review:
    3. return "flagship"
    4. if task.cross_file_refactor:
    5. return "mid_tier"
    6. if task.batch_simple:
    7. return "lite"
    8. return "fast"

    Supporting engineering practices include: placing system prompts and specification documents up front to maximize cache hits; summarizing and compressing long context; logging input, output, and cache metrics for every call to continuously regression-calibrate the internal cost baseline; and setting budget circuit breakers and fallback paths so the flagship model is not misused by simple tasks.

    5. Rollout Advice and Risk Notes

    Start by sampling and fitting on real traffic for one to two weeks, and set routing thresholds only after confirming the internal unit consumption rates are stable. Use A/B comparison to measure “effective output per credit” before and after tiered routing, and keep human fallback and quality spot checks in place. Finally, a reminder: all reverse-engineered numbers are measured approximations for internal capacity planning only, and should not be used as external commitments or official references.