A Practical Guide to Token Cost Estimation for Multi-Model Tiered Routing
When deploying multi-model applications, cost is rarely as simple as "which model has the lowest unit price." Real systems mix planning, reasoning, execution, and batch tasks, and input/output ratios, cache hit rates, retry counts, and budget cycles all change the final bill. This article abstracts a field-tested approach into a general methodology: build a credit consumption model first, then reverse-engineer the rates of each tier from actual request logs, and finally use tiered routing to reserve high-cost capability for critical work while scaling low-cost capability for execution. Sample data is anonymized and illustrative only; always validate against your own billing and request logs.
A Practical Guide to Token Cost Estimation for Multi-Model Tiered Routing
When deploying multi-model applications, cost is rarely as simple as “which model has the lowest unit price.” Real systems handle planning, reasoning, execution, and batch tasks simultaneously, and input/output ratios, cache hit rates, retry counts, and budget cycles all change the final bill. This article abstracts a field-tested approach into a general methodology: first build a credit consumption model, then reverse-engineer the cost of each tier from actual request logs, and finally use tiered routing so that expensive capability is spent on critical work while cheap capability scales routine execution.
Note: the sample data below is anonymized and for demonstration only. It does not represent any vendor’s official pricing. Actual rules may change with the platform, model version, and operational policy; in engineering practice, always rely on your own bills and request logs.
1. A Unified Cost Model: Breaking the Bill into Computable Terms
The core of a credit-based or token-based budget is decomposing each request into input tokens, output tokens, and cached input tokens. Suppose a model tier charges r_in per million input tokens, r_out per million output tokens, and r_cache per million cached tokens. For a request with x_in input tokens, x_out output tokens, and x_cache cached input tokens, the cost is:
cost = ((x_in - x_cache) * r_in + x_cache * r_cache + x_out * r_out) / 1_000_000
Ignoring caching for now and assuming mixed traffic of 80% input and 20% output, the average cost per million mixed tokens is:
cost_per_mix = 0.8 * r_in + 0.2 * r_out
Given a periodic budget B, the mixed-token capacity it can support is approximately:
capacity = B / cost_per_mix * 1_000_000
The value of this model is explainability: budget consumption is no longer a black-box number but a function of input volume, output volume, cache hit rate, and per-tier rates. Output rates are typically higher than input rates, so long-output tasks amplify cost significantly. Cache hits only affect the input side, but the payoff is substantial for scenarios with repeated system prompts, long document contexts, and extensive tool descriptions.
2. An Anonymized Example: Cost Differences Across Four Model Tiers
To illustrate why tiered routing matters, we construct four anonymized model tiers, with rates in “credits per million tokens”:
| Tier | Role | Input rate | Output rate | Cache rate |
|---|---|---|---|---|
| P | Planning and final review | 80,000 | 400,000 | — |
| R | Complex reasoning | 32,000 | 112,000 | — |
| E | Main execution | 4,000 | 8,000 | 80 |
| L | Batch simple tasks | 2,000 | 2,000 | — |
With 80% input, 20% output, and no caching, the cost per million mixed tokens is:
| Tier | Formula | Mixed cost | Capacity with 60,000 credits / 5 hours |
|---|---|---|---|
| P | 0.8×80,000 + 0.2×400,000 | 144,000 | ~417k tokens |
| R | 0.8×32,000 + 0.2×112,000 | 48,000 | ~1.25M tokens |
| E | 0.8×4,000 + 0.2×8,000 | 4,800 | ~12.5M tokens |
| L | 0.8×2,000 + 0.2×2,000 | 2,000 | ~30M tokens |
Tier P’s output rate is 200 times that of Tier L, and the capacity gap between the top and bottom tiers is nearly two orders of magnitude. Tier E’s cached rate is only 2% of its normal input rate, which shows how critical caching is for repeated-context scenarios. The conclusion here is not “don’t use expensive models,” but “don’t use expensive models indiscriminately.” A reasonable strategy: Tier P handles planning and final review, Tier R handles complex reasoning, Tier E handles main execution, and Tier L handles batch simple tasks. In short, expensive models do the thinking; cheap models do the doing.
3. Fitting with Real Records: Validate Rates Instead of Guessing Them
Reverse-engineering rates requires complete request records: request ID, model tier, input tokens, output tokens, cached tokens, actual credit consumption, timestamp, task type, and budget cycle. Organize the records for a single tier into linear equations, with input, output, and cached tokens as independent variables and credits as the dependent variable, then apply least-squares fitting with non-negativity constraints or solve the linear system directly. With sufficient data coverage and stable rules, in-sample goodness of fit may approach 1 with residuals near 0 — but that only proves in-sample consistency. It cannot be extrapolated into official pricing, nor does it account for version updates and rule changes.
Input: sample set S = {(x_in, x_out, x_cache, y)}Goal: solve for r_in, r_out, r_cacheConstraints: r_in >= 0, r_out >= 0, r_cache >= 0Evaluation: R², residual distribution, error grouped by task type, holdout validation across periods
In practice, avoid fitting on only a handful of requests, and avoid double-counting cached tokens as regular input. For anomalous bills, keep retry chains and failed request records, because retries amplify both output cost and context cost.
4. Tiered Routing: Quality Gating and Budget Watermarks
Routing should consider not only rates but also task risk, output length, context length, quality requirements, and remaining budget. A practical pseudocode sketch:
function route(task, budget):if task.kind in ["planning", "final_review"]:return "P"if task.complexity > HIGH and budget.remaining_ratio > 0.2:return "R"if task.batch and task.risk < LOW:return "L"if budget.remaining_ratio < 0.2 and task.risk < HIGH:return "L"return "E"function execute(task):model = route(task, budget)result = call(model, task)if result.confidence < threshold or validation_failed(result):result = call("R", task) # escalate on low confidence or failed validationif task.kind == "final_review":result = call("P", task)return result
Routing principles: planning tasks produce structured plans, with Tier P ensuring global consistency; complex reasoning goes to Tier R; routine execution goes to Tier E; batch, low-risk, automatically verifiable tasks go to Tier L. When the budget watermark drops below the threshold, low-risk tasks are downgraded, while high-risk tasks keep an upgrade path open. Quality gating can use rule-based validation, confidence thresholds, sampled review, and escalation on failure — preventing “saving money into producing errors.”
5. Monitoring and Governance: Making Cost Observable and Regression-Testable
After launch, continuously track per-task cost, cost per thousand tokens, cache hit rate, escalation rate, downgrade rate, retry cost, and budget burn rate. Break down the bill by task type to identify “high cost, low return” routing strategies. Cache system prompts, tool descriptions, and long document contexts where appropriate, but watch out for invalidation and consistency. Reserve a portion of each budget cycle for review and retries, so that early batch tasks don’t exhaust the budget and leave critical tasks unable to escalate. When running in the cloud, generic capabilities such as log services and monitoring alerts can be combined to build a cost dashboard — but do not rely on unverified proprietary billing assumptions.
6. Boundaries and Conclusion
The core of this method is to decompose cost across four dimensions — input, output, caching, and budget — then validate through fitting against real records, and finally implement “expensive models think, cheap models execute” via tiered routing. It must be emphasized: the anonymized example is not official pricing, and fitted results only reflect in-sample rules. Recalibrate whenever model versions, caching strategies, or operational rules change. The bottom line of cost optimization is quality and correctness; every downgrade and caching strategy should come with validation and rollback mechanisms.
