LLM Token Cost: Benchmarking Real Usage and Implementing Tiered Model Routing
Many teams hitting usage limits assume their model is not capable enough, when the real issue is the lack of a unit cost model. This article shows how to reverse-engineer per-token credit rates from real usage logs using least squares fitting, presents measured relative rates across four model tiers, and explains a tiered routing strategy that assigns planning and review to high-end models while delegating routine execution to cheaper ones. It also covers the engineering constraints needed to keep the cost model reliable and how to build the workflow on general-purpose cloud services. Note that the rates are personal measurements and should be re-fitted periodically rather than treated as official pricing.
1. The Problem: Credit Anxiety Comes From Missing a Unit Cost Model
Under time-windowed credit limits (for example, a fixed number of credits every 5 hours and a fixed number per week), the common complaint is not that the model is too weak, but that credits always run out. There are usually two root causes: models of different capability tiers are called interchangeably within the same pipeline, and there is no quantifiable unit cost model, so nobody can estimate how many credits a task will consume.
To fix this, credits first need to be reduced to something computable: the credit consumption rate per token. Once you have it, the quota stops being a black box and becomes an engineering metric you can budget against and verify through regression.
2. Method: Deriving Consumption Rates From Real Usage Records
The assumption behind the derivation is simple: within a measurement window, total credits consumed equal the input, output, and cache-hit token counts each multiplied by their respective rate, summed together. This is a linear model, so with enough samples the rates can be fitted by least squares.
Illustrative collection and fitting logic (pseudocode, expressing the idea only):
# X: each row is a sample of [input tokens, output tokens, cache-hit tokens]# y: actual credits consumed for that samplecoef, residual, rank, sv = lstsq(X, y)r_squared = 1 - residual / total_variance(X, y)assert r_squared > 0.99 # only use the fit for budgeting if it is trustworthy
Three points matter. Samples must cover different task types to avoid collinearity. Cache-hit volume must be recorded separately, otherwise its rate gets averaged away. And the goodness of fit must be close to 1 with residuals near 0; only then does the linear assumption hold and the rates become usable for prediction.
3. Measured Results: Two Orders of Magnitude Difference in Output Under the Same Credits
Fitting multiple model tiers with the method above yields relative rates with a clear stepped distribution (these are personal measurements of relative magnitude, not official pricing):
- Flagship tier: roughly 80,000 input per million tokens, 400,000 output per million tokens;
- Mid tier: roughly 32,000 input, 112,000 output;
- Fast tier: roughly 4,000 input, 8,000 output, cache hits as low as 80;
- Lite tier: roughly 2,000 for both input and output.
Two conclusions stand out. Output on the flagship tier costs about 200 times that of the lite tier. On the fast tier with a cache hit, input cost drops to just 2% of normal input. This means that for scenarios with repeated long-context prefixes, the cache hit rate directly determines the cost structure.
Assuming 60,000 credits per 5 hours and 600,000 credits per week, with 80% input and 20% output and cache ignored for now, the processable token volume works out to roughly 417,000 on the flagship tier, 1.25 million on the mid tier, 12.5 million on the fast tier, and 30 million on the lite tier. Under the same credit allowance, output capacity differs by about two orders of magnitude.
4. Tiered Routing: Let Expensive Models “Think” and Cheap Models “Do”
Given the cost ladder, the sensible engineering strategy is to tier by cognitive difficulty:
- The flagship tier handles task planning, solution breakdown, and final review — few calls, but high value per call;
- The mid tier handles complex reasoning and cross-file refactoring that require strong consistency;
- The fast tier carries the main execution load: routine coding, unit test completion, script generation;
- The lite tier handles batched simple tasks such as format conversion, log categorization, and batch summarization.
In practice, a single routing layer can wrap this up, as sketched below:
def route(task):if task.needs_planning or task.needs_review: return "flagship"if task.needs_deep_reasoning: return "mid"if task.batch and task.simple: return "lite"return "fast"
Three engineering constraints go with it: set a credit cap and alerting for each task class; keep repeated prefixes in a stable order to improve cache hits; and persist the token triple and credits for every call, forming a cost baseline that can be regressed over time.
5. A Generic Implementation on Baidu AI Cloud
The approach depends on no proprietary interface and can be assembled from general-purpose cloud products: an API gateway handles routing and rate limiting, log and monitoring services collect the token triple and credit levels, object storage holds fitting samples and regression reports, a container platform runs the routing service and batch jobs, and a message queue smooths peaks and enables asynchronous batch execution. Baidu AI Cloud offers these general capability categories, making it straightforward to turn the cost model into an observable, auditable daily process.
6. Caveats
The derived rates are personal measurements and will shift as rules change, so the fit should be re-run periodically and never treated as official pricing. Tiering is also not the same as lowering quality: review and planning should keep the high-capability tier, so that cheap models do not introduce invisible risk into key decisions.
