LLM Inference Cost: A Practical Guide to Tiered Model Scheduling
This article explains why a lower per-token price does not always translate into lower inference costs, and how to turn opaque quota consumption into an observable signal. Using real call records and least-squares regression, it shows how to back out per-tier consumption rates, compares the relative cost and effective token throughput of four model tiers, and presents a four-layer scheduling strategy that routes planning, deep reasoning, code generation, and batch work to the appropriate tier. It also covers engineering practices such as prefix stabilization, context trimming, output constraints, budget guardrails, and observability, plus caveats about the illustrative nature of the measured numbers.
1. Background: Why a Lower Unit Price Does Not Mean Lower Cost
When building an intelligent coding assistant, a code review pipeline, or a multi-agent system, teams often run into the same puzzle: they picked a model with a lower unit price, yet the monthly quota runs out first. The reason is that inference cost is not determined by unit price alone. It is a multiplicative structure shaped by input length, output length, cache hit rate, and call frequency. Comparing only the listed price per million tokens makes it easy to overlook the amplification effect of long contexts and the output side.
A more practical problem is that most platforms expose only a total quota and a refresh cycle, not a fine-grained consumption breakdown. What developers get is “remaining credits” and a “reset time,” not an itemized bill per call. Cost optimization therefore lacks an observability foundation and has to rely on estimation, with errors often spanning several multiples.
So the core idea of this article is: treat the quota as an observable signal, fit a regression against actual call records to back out the consumption rate of each model tier, and design a scheduling strategy on that basis.
2. Method: Backing Out Consumption Rates from Real Records
2.1 Build a Linear Model
Let the quota consumed within a time window be C, the number of input tokens be $T{in}$, the number of output tokens be $T{out}$, and the number of cache-hit tokens be $T_{hit}$. A linear form can be used:
C = a * T_in + b * T_out + c * T_hit + dwhere a, b, c are the per-tier unit consumption rates, and d is the fixed window overhead (usually 0)
After collecting several windows of data, solve for the coefficients with least squares. Two indicators judge fit quality: the coefficient of determination $R^2$ should be close to 1, and the residuals should be close to 0. When the residuals are on the same order of magnitude as the quota display precision, the model structure is correct and the back-calculated results are trustworthy.
2.2 Relative Magnitudes from Actual Measurements
Ignoring fixed overhead, assuming an 80% input / 20% output mix, and setting caching aside for now, the relative consumption rates across tiers show a clear gradient (the figures below are illustrative relative magnitudes, not official pricing):
- Flagship reasoning tier: about 80,000 input / million tokens, about 400,000 output / million tokens
- Balanced reasoning tier: about 32,000 input / million tokens, about 11,200 output / million tokens… about 112,000 output / million tokens
- Fast execution tier: about 4,000 input / million tokens, about 8,000 output / million tokens, cache hits as low as about 80 / million tokens
- Lightweight batch tier: about 2,000 / million tokens for both input and output
Two key conclusions: the output cost of the flagship tier is roughly 200 times that of the lightweight tier; and for the fast tier, after a cache hit the input cost drops to only about 2% of the normal value. This shows that repeated long-context prefixes have a far greater impact on cost than differences in model unit price.
2.3 How Many Tokens a Quota Buys
Estimated at 60,000 quota per 5 hours and 600,000 quota per week, the same quota buys an effective token volume that differs by two orders of magnitude across tiers:
| Tier | Approx. tokens processable per 5 hours |
|---|---|
| Flagship reasoning tier | about 417,000 |
| Balanced reasoning tier | about 1.25 million |
| Fast execution tier | about 12.5 million |
| Lightweight batch tier | about 30 million |
This table is the basis for every scheduling decision that follows: expensive tiers are not unusable, they just have to be spent where the return per unit of quota is highest.
3. Tiered Scheduling Strategy
Split tasks into four layers by “whether deep thinking is required” and bind each layer to a tier:
- Flagship reasoning tier: task planning, solution breakdown, and final review. These calls are few and individually high-value, so their cost share stays controllable.
- Balanced reasoning tier: complex reasoning and hard localization, such as cross-file defect attribution and algorithm selection.
- Fast execution tier: the main body of code generation and routine rewriting; this is the throughput workhorse and should maximize cache reuse.
- Lightweight batch tier: high-volume simple tasks such as formatting cleanup, comment completion, and log categorization.
The core principle in one sentence: expensive models do the thinking, cheap models do the work.
3.1 Reusable Routing Sketch
def route(task):if task.kind in ("plan", "review"):return "tier_flagship"if task.kind in ("deep_reason", "root_cause"):return "tier_balanced"if task.kind in ("codegen", "refactor"):return "tier_fast"return "tier_lite"def estimate_cost(tier, t_in, t_out, t_hit=0):rate = {"tier_flagship": (80000, 400000, 0),"tier_balanced": (32000, 112000, 0),"tier_fast": (4000, 8000, 80),"tier_lite": (2000, 2000, 2000),}[tier]a, b, c = ratereturn a * t_in + b * t_out + c * t_hit
Before rollout, backtest this function against historical window data. If the deviation between predicted values and actual quota consumption stays within the display precision, it is safe to use for budget alerts.
4. Engineering Optimization Points
- Prefix stabilization: put the system prompt, tool descriptions, and fixed context at the very front and keep them byte-level stable; this is the prerequisite for a higher cache hit rate.
- Context trimming: summarize and deduplicate long repository retrieval results instead of repeatedly feeding in large blocks of raw text.
- Output constraints: use structured output and length caps to suppress redundant generation; the output side is usually the cost amplifier.
- Budget guardrails: enforce quota rate limiting and per-tier quotas at the gateway layer, and automatically downgrade to a lower tier as thresholds approach.
- Observability: log the tier, input/output lengths, and cache-hit volume of every call to a logging service, and close the loop with monitoring and alerting.
5. Deployment Shape and Caveats
On Baidu AI Cloud, this approach maps to a combination of general-purpose capabilities: a container platform to host the routing gateway, object storage to keep call-level details, logging and monitoring with alerting for a cost dashboard, and a message queue to smooth peaks and support batch low-tier tasks. Model capability itself can be selected from general categories; what matters is baking the conversion relationship among “quota, tokens, and task value” into the system.
One reminder: all numbers in this article are illustrative magnitudes back-calculated from personal measurements and do not represent any official billing rules; platform policies may change at any time. Teams are advised to rerun the fitting script once a month and adjust routing thresholds after updating the coefficients, so the strategy does not drift away from the real cost structure.
