LLM Token Cost Benchmarking and Tiered Scheduling in Practice

    This article explains why a cheaper per-token price does not always mean a lower total bill, and how to measure real consumption instead of trusting list prices. It shows how to fit input and output consumption rates from your own call logs using least squares, how to convert a quota into usable tokens, and how to route tasks across model tiers so expensive models handle planning and cheap models handle execution. It also covers prefix caching, output length limits, retry costs, and common pitfalls, with a vendor-neutral approach that can be adapted to different platforms and self-hosted gateways.

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

    The most common mistake teams make with model calls is comparing nominal unit prices and concluding “just pick the cheapest one.” A real bill is determined by four variables working together: input length, output length, cache hit ratio, and how finely a task is split up. An expensive model that thinks a problem through in one pass can cost less than a cheap model that retries three times. Conversely, handing bulk simple tasks to an expensive model can drain your quota within hours.

    So the right starting point for cost evaluation is not the price list but your own call logs. Only real records give you a credible estimate of effective throughput.

    2. Method: Backing Out the Consumption Rate from Real Records

    The core idea is to build a linear model. Let a session consume C credits, with In input tokens and Out output tokens:

    1. C = a * In + b * Out + c

    Here a and b are the per-token consumption rates for input and output, and c is a fixed overhead (usually 0). Plug in multiple (In, Out, C) samples, solve for a and b with least squares, then check goodness of fit and residuals. When R² is close to 1 and residuals are close to 0, billing is approximately purely linear and the inferred rates are trustworthy. If the residuals show a systematic offset, that usually means there is a cache discount, tiered pricing, or a minimum billing unit, and you need to add piecewise terms and refit.

    A simplified fitting and validation implementation:

    1. import numpy as np
    2. # Samples: input tokens, output tokens, measured credits
    3. samples = np.array([
    4. [8000, 1200, 620],
    5. [15000, 800, 700],
    6. [32000, 2000, 1450],
    7. ])
    8. X = np.c_[samples[:, 0], samples[:, 1], np.ones(len(samples))]
    9. y = samples[:, 2]
    10. a, b, c = np.linalg.lstsq(X, y, rcond=None)[0]
    11. pred = X @ np.array([a, b, c])
    12. ss_res = ((y - pred) ** 2).sum()
    13. ss_tot = ((y - y.mean()) ** 2).sum()
    14. r2 = 1 - ss_res / ss_tot
    15. print(f"input rate={a:.6f} output rate={b:.6f} fixed={c:.4f} R2={r2:.6f}")

    In practice, turn the sampling script into a scheduled job that writes one record to the database automatically at the end of each session. Each record should contain at least the timestamp, a scenario label, input and output tokens, cached tokens, and credits consumed. Fitting after two weeks of accumulated data is far more robust than a one-off manual tally.

    3. Benchmark Results: How Consumption Rates Differ Across Tiers

    After sampling and fitting several model tiers, you get consumption rate structures that differ by orders of magnitude (the following are relative relationships inferred from personal measurements, not official prices, and the rules may change):

    • Flagship tier: input roughly 80,000 credits/1M, output roughly 400,000 credits/1M;
    • Upper-mid tier: input roughly 32,000 credits/1M, output roughly 112,000 credits/1M;
    • Fast tier: input roughly 4,000 credits/1M, output roughly 8,000 credits/1M, cache hits as low as 80 credits/1M;
    • Lite tier: roughly 2,000 credits/1M for both input and output.

    Two key conclusions are worth remembering. First, the flagship tier’s output cost can be about 200 times that of the lite tier. Output length is a cost amplifier, so long-form generation must be assigned to a tier carefully. Second, after a cache hit, the fast tier’s input cost drops to only about 2% of the normal value. Putting stable system prompts, codebase context, and specification documents into a reusable prefix therefore pays off by orders of magnitude.

    4. Quota Conversion: Turning Credits into “Usable Tokens”

    Assume a quota of 60,000 credits per 5 hours and 600,000 credits per week. With an estimated 80% input and 20% output split and no cache assumed, the roughly supportable token volumes are: about 417,000 for the flagship tier, about 1.25 million for the upper-mid tier, about 12.5 million for the fast tier, and about 30 million for the lite tier. The conversion formula is straightforward:

    1. usable tokens ≈ quota / (0.8 * a + 0.2 * b)

    This metric is more useful for decisions than unit price because it directly answers “is my quota enough to finish this batch of tasks?” Make it a dashboard metric, and pair it with monitoring alerts that fire when 70% of the quota is consumed, so a job does not get throttled halfway through.

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

    Based on the structure above, a four-role split is recommended:

    1. The flagship tier handles planning and final review: breaking down requirements, defining interface contracts, reviewing critical diffs. Input and output are both short, so total cost stays controlled.
    2. The upper-mid tier handles complex reasoning: locating tricky defects and designing cross-module refactoring plans.
    3. The fast tier handles the bulk of execution: writing code in batches against an agreed plan, adding tests, changing configs, with prefix caching pushing cost down another order of magnitude.
    4. The lite tier handles bulk simple tasks: formatting, renaming, comment completion, log categorization.

    In practice, wrap everything in a single routing layer that selects a tier by task label, rather than hardcoding choices all over business code:

    1. TIER = {"plan": "flagship", "reason": "mid", "exec": "fast", "batch": "lite"}
    2. def call_model(task_type, messages, **kw):
    3. tier = TIER[task_type]
    4. return gateway.invoke(tier, messages, **kw)

    Three supporting practices: first, put stable prefixes first, keeping unchanging content at the start of the message list to hit the cache; second, cap output length so the flagship tier is not dragged down by long outputs; third, log the tier and credits for every call to build a regression-able cost baseline.

    6. Common Pitfalls and Risks

    Do not treat one fitting result as a permanent conclusion. Billing rules, model versions, and caching policies can all change, so recompute periodically. Do not ignore retry costs; failed retries are often the main cause of an abnormal bill, so set timeouts and a maximum retry count. Do not push every task onto the cheapest tier, because rework by an expensive model after a simple task fails can raise the total cost. Finally, when sensitive data is involved, prefer a compliant deployment form; cost optimization must not come at the expense of data security.

    7. Summary

    The essence of cost governance is replacing “unit price thinking” with “effective throughput thinking”: fit consumption rates from real logs, evaluate quota with usable token counts, use tiered routing to give thinking to expensive tiers and execution to cheap ones, then apply prefix caching and output length limits for a second round of compression. This method does not depend on any specific vendor and can be moved directly to different platforms and self-hosted gateway environments. It can also be combined with relevant general capabilities on Baidu AI Cloud, such as monitoring and alerting, log services, and container platforms, to form a cost baseline that keeps improving.