LLM Inference Cost: Benchmarking Real Usage and Implementing Tiered Scheduling

    This article shows how to reverse-engineer hidden LLM inference consumption rates from real usage logs using least-squares regression, convert quota into actionable token capacity across four model tiers, and apply tiered scheduling so expensive models handle reasoning while cheaper models handle execution. It covers the measurement method, observed cost gaps of up to 200x, the leverage of prompt caching, capacity formulas, a routing skeleton, and validation practices for keeping the cost model accurate over time.

    1. Background: Why a Low Unit Price Doesn’t Mean a Low Bill

    After integrating large language models into production systems, many teams run into the same puzzle: the per-million-token prices on a quote differ by only a few times, yet the month-end bill differs by an order of magnitude. The reason is not complicated. Real workloads have a “long input, short output, repeatedly replayed context” structure, and the input-to-output ratio, cache hit rate, and retry and truncation strategies all amplify the nominal unit price into actual cost.

    What makes it worse is that most platforms only expose a vague “credits/quota” consumption number externally, without fine-grained itemized pricing. This leaves capacity planning to guesswork: guessing how many requests a model can handle, guessing whether a week’s quota is enough. The approach in this article is the reverse: use existing real usage records to fit a regression, solve for the hidden “credit consumption rate,” and then base model selection and scheduling on those coefficients.

    Note in advance: all numbers below are results I personally measured and back-calculated. They are not any official price list, and the rules may change at any time. Readers should take away the method, not the numbers.

    2. Method: Back-Calculating Consumption Rates from Real Usage

    Let the input tokens of a session be pin, the output tokens be pout, the cache-hit portion be counted separately as pc, and the credits deducted for that session be C. Assuming billing is piecewise linear, we have:

    1. C = a * pin + b * pout + c * pc + d

    Here a, b, and c are the credit consumption rates (credits per 1M tokens) for the input, output, and cache-hit tiers respectively, and d is the fixed overhead (usually 0). With 3 or more linearly independent samples, the coefficients can be solved. In practice I use least-squares fitting and treat the residual as a check:

    1. import numpy as np
    2. # Each row: [input M, output M, cache hit M, credits deducted]
    3. X = np.array([
    4. [0.62, 0.11, 0.05, 62130],
    5. [1.35, 0.24, 0.40, 128400],
    6. [0.28, 0.06, 0.02, 27900],
    7. ])
    8. A = X[:, :3]
    9. y = X[:, 3]
    10. coef, res, *_ = np.linalg.lstsq(A, y, rcond=None)
    11. pred = A @ coef
    12. r2 = 1 - ((y - pred) ** 2).sum() / ((y - y.mean()) ** 2).sum()
    13. print(coef, r2, (y - pred).max())

    The coefficient of determination R² of the fit reaches 1.0, and the maximum residual is approximately zero, which shows that the “piecewise linear billing” assumption holds and the back-calculated coefficients can be used directly for budget estimation.

    Three pitfalls to watch for in engineering: first, samples must cover different input/output ratios, otherwise the coefficient matrix is ill-conditioned and the solution is unstable; second, sessions contaminated by interruptions or retries must be removed; third, the sampling window must span different time periods to avoid mixing abnormal deductions caused by rate limiting or degradation into the model.

    3. Cost Magnitude: Measured Differences Across Four Model Tiers

    Using the method above to back-calculate, the credit consumption rates of four typical model categories fall roughly into the following ranges (unit: credits per 1M tokens):

    Tier Input Output Cache Hit
    Flagship reasoning ~80,000 ~400,000 Not priced separately
    Balanced reasoning ~32,000 ~112,000 Not priced separately
    Fast execution ~4,000 ~8,000 ~80
    Lightweight batch ~2,000 ~2,000 ~80

    Two conclusions are worth remembering:

    • The spread can reach 200x. The output cost of the flagship tier is about 200 times that of the lightweight tier, and the input cost also differs by 40 times. This means “running all tasks on the flagship model” is almost unacceptable in terms of cost.
    • Caching is a lever. After a cache hit, the unit cost of the fast execution tier drops to only about 2% of a normal input, effectively pushing the marginal price of repeated context close to zero. For agent scenarios with fixed system prompts and repeatedly replayed codebases, the gains from this item often exceed those from switching models.

    4. Quota Conversion: Turning Credits into Executable Task Volume

    Let the quota for a period be Q credits, the input share be α, and the output share be β (α + β ≤ 1, with the remainder being cache hits). The total token volume a single model can handle is approximately:

    1. Tokens ≈ Q / (α * a + β * b)

    Taking Q = 600,000 credits/week, converting a 5-hour window at 60,000 credits, and assuming 80% input + 20% output with caching not yet counted, we get:

    • Flagship reasoning: ~417,000 tokens / 5 hours
    • Balanced reasoning: ~1.25 million tokens / 5 hours
    • Fast execution: ~12.5 million tokens / 5 hours
    • Lightweight batch: ~30 million tokens / 5 hours

    The point of this conversion is to turn “model selection” into a “capacity problem.” When a requirement needs to process 30 million input tokens per week, the answer is already unique: it can only fall on the lightweight or fast execution tier, and the flagship tier is only suitable for the small portion filtered out from it.

    5. Tiered Scheduling: Let Expensive Models Think and Cheap Models Execute

    Based on the coefficients above, tasks can be graded by “reasoning depth requirement,” forming a top-down funnel:

    1. Planning and final review (flagship tier): handles only low-frequency, high-value steps such as requirement breakdown, solution selection, and final code review. Input can be long, but output must be short.
    2. Complex reasoning (balanced tier): handles medium-frequency tasks such as cross-file refactoring, difficult defect localization, and algorithm design.
    3. Main execution (fast execution tier): handles the vast majority of coding, rewriting, and test generation. Combined with cache hit rate optimization, it is the throughput workhorse.
    4. Batch simple tasks (lightweight tier): format conversion, comment completion, log categorization, batch summarization, and so on, pursuing the lowest unit cost.

    Four supporting engineering practices deliver the largest measured gains:

    • Stable prefix. Put the system prompt, tool definitions, and project conventions at the very front and avoid volatile concatenation like timestamps, to maximize cache hits.
    • Output budget. Use max_tokens and structured output to constrain length. Output cost is usually more than 5 times input cost, so compressing output is more cost-effective than compressing input.
    • Context trimming. Truncate retrieved snippets by relevance and avoid stuffing an entire repository into the window.
    • Failure degradation. When the high-price tier times out or exceeds budget repeatedly, automatically degrade to the next tier and mark it for review, rather than retrying indefinitely.

    A schematic scheduling skeleton:

    1. TIERS = [
    2. ("flagship", 80_000, 400_000),
    3. ("balanced", 32_000, 112_000),
    4. ("fast", 4_000, 8_000),
    5. ("lite", 2_000, 2_000),
    6. ]
    7. def estimate(tier, pin_m, pout_m, hit_m=0.0):
    8. _, a, b = tier
    9. return a * pin_m + b * pout_m # The hit portion is charged at a lower coefficient separately
    10. def route(task, budget):
    11. order = ["flagship", "balanced", "fast", "lite"]
    12. for name in order:
    13. cost = estimate(next(t for t in TIERS if t[0] == name),
    14. task.in_m, task.out_m)
    15. if cost <= budget and task.depth <= DEPTH[name]:
    16. return name
    17. return "lite"

    6. Post-Launch Validation and Common Pitfalls

    After launch, closed-loop validation is mandatory, otherwise the cost model will quickly become distorted:

    • Instrumentation alignment. Record input, output, and cache-hit tokens along with the deducted quota for every call, bucketed by model.
    • Rolling refitting. Re-solve the coefficients with new samples every week and monitor whether R² falls below 0.98. Falling below it means the billing structure or workload structure has changed.
    • Quality gatekeeping. After tiering, watch the rework rate. If the second-pass modification rate of lightweight-tier tasks rises noticeably, the tiering thresholds are too loose.
    • Budget guardrails. Set daily/weekly quota caps and alerts for each tier to avoid a single abnormal retry eating the entire week’s budget.

    There are three common pitfalls: only looking at output unit price while ignoring long input context; treating caching as a default capability without doing prefix governance; and running batch tasks on the flagship tier and then trying to compensate with “prompt optimization” — the savings from prompt optimization are usually far smaller than the difference brought by tier selection.

    7. Conclusion

    The core of cost governance is not finding the “cheapest model,” but establishing a quantifiable allocation mechanism: first fit consumption rates from real usage, then use a formula to convert quota into task capacity, and finally use tiered scheduling to separate high-value reasoning from high-frequency execution. This method does not depend on any specific vendor’s pricing; when the rules change, you only need to refit the coefficients, and the conclusions still hold.