Token Cost Analysis for LLMs: A Practical Multi-Model Routing Strategy for Cost-Efficient AI Applications
This article breaks down the real cost differences between LLM tiers, showing how flagship models can be 200x more expensive than lightweight ones. It explains how to reverse-engineer token consumption rates from API logs, estimate throughput under quota limits, and design a multi-model routing architecture where high-cost models handle planning and reasoning while low-cost models handle execution and batch tasks. It also covers the impact of context caching on input cost reduction and offers actionable guidance for building scalable, budget-conscious AI applications.
The high cost of calling large language model (LLM) APIs is one of the biggest obstacles to scaling AI applications in production, especially for AI coding assistants and agent-based workflows. Developers often default to using the most capable flagship model for every step of a complex pipeline. That approach can exhaust budgets rapidly and, in some cases, trigger platform rate-limit interruptions during peak usage. In reality, different model tiers carry vastly different token price points—differences that can span multiple orders of magnitude across input, output, and cache-hit scenarios. Knowing how to measure these costs and design a cost-aware routing strategy is essential for any senior developer shipping LLM-powered applications.
Reverse-Engineering Token Consumption from Real Usage Data
Token pricing models are rarely published in a way that makes cross-tier comparison straightforward. Instead of relying on marketing documentation, you can derive accurate consumption rates by instrumenting your own API calls. By recording the input tokens, output tokens, and total credits consumed for each request, and then fitting the data with a linear regression model (R² = 1.0, residual ≈ 0 in a recent test run), you can infer the underlying cost coefficients for each model tier.
For the purpose of this analysis, common LLM offerings can be grouped into four functional tiers:
- Flagship planning model: ~80K credits per 1M input tokens; ~400K credits per 1M output tokens.
- Mid-tier reasoning model: ~32K credits per 1M input tokens; ~112K credits per 1M output tokens.
- Mainstream execution model: ~4K credits per 1M input tokens; ~8K credits per 1M output tokens. With cache hits, input cost drops dramatically to ~80 credits per 1M tokens.
- Ultra-lightweight fine-tuned model: ~2K credits per 1M tokens for both input and output.
The gap between tiers is striking. The flagship model’s output cost is 200 times that of the ultra-lightweight model. Meanwhile, when the mainstream execution model hits its context cache, the input cost falls to just 2% of the normal (cache-miss) rate. Ignoring these differences and uniformly routing all traffic to the strongest model does more than waste computing power—it can break the project budget.
Throughput Estimates Under Fixed Quota
Once the cost rates are known, you can calculate how many tokens each tier can handle within a set quota. Assuming a platform window quota of 60,000 credits per 5 hours (or 600K credits per week), and a typical agent interaction with an input/output token ratio of roughly 8:2 (without cache optimization), the estimated throughput is as follows:
- Flagship planning model: ~417K tokens per 5 hours
- Mid-tier reasoning model: ~1.25M tokens per 5 hours
- Mainstream execution model: ~12.5M tokens per 5 hours
- Ultra-lightweight fine-tuned model: ~30M tokens per 5 hours
This data confirms a fundamental trade-off: performance and throughput are inversely related under a fixed cost ceiling. With the same budget, an ultra-lightweight model processes over 70 times more tokens than a flagship model. Relying solely on the “strongest” model is simply not sustainable in real engineering environments.
Designing a Multi-Model Routing Architecture
The most practical solution is a multi-model collaborative architecture. The guiding principle can be summarized as: “expensive models think, cheap models do.” On platforms such as Baidu AI Cloud, similar strategies can be implemented by combining object storage and logging services to archive call records and adjust routing policies over time. For agentic workflows and AI coding assistants, a sensible role-based tiering looks like this:
Flagship planning model — for “thinking.” At the start of a task, this model handles intent recognition, complex task decomposition, and high-level workflow planning. At the end, it performs quality review and logic validation on the final output (e.g., code blocks or business reports). Because of its strong context understanding and reasoning ability, it is best reserved for low-frequency, high-value decision points.
Mid-tier reasoning model — for “reasoning.” When the execution path hits complex logic nesting, algorithm design, or intermediate steps that require deep thought, route the context to this model. It strikes a balance between capability and price, and comfortably handles most tasks requiring chain-of-thought prompting.
Mainstream execution model — for “doing.” This is the workhorse of the system. It handles routine code generation, function completion, and text expansion at high frequency. Its low cost per token enables massive parallelism and high concurrency without worrying about runaway expenses.
Ultra-lightweight fine-tuned model — for “batch processing.” Tasks such as log parsing, data cleaning, simple classification, and format conversion require very little reasoning but often involve enormous data volumes. This tier maximizes throughput and minimizes per-call expense.
A smart routing gateway can inspect incoming requests and dispatch them to the appropriate tier. The pseudocode below illustrates this pattern:
def route_model(task):if task.type == "PLANNING" or task.type == "REVIEW":return ModelTier.FLAGSHIPelif task.type == "COMPLEX_REASONING":return ModelTier.ADVANCED_REASONINGelif task.type == "BATCH_PROCESSING":return ModelTier.LITEelse:# Default to the mainstream execution model for routine tasksreturn ModelTier.FLASH_EXECUTION
The Cost-Saving Power of Context Caching
One of the most effective optimizations comes from a single number in the earlier cost analysis: the mainstream execution model’s cache-hit input cost is just 2% of the normal rate. That is not a minor efficiency gain—it is a game-changer for production systems.
In multi-turn agent conversations or long-context code generation tools, a large portion of each request often consists of fixed system prompts, project background, and library dependency definitions. If every request sends these long prefixes to the model as fresh input, the cost multiplies quickly. The right approach is to select models and API endpoints that support context caching, and to warm up the cache with common prefixes.
When a subsequent request carries an identical prefix, the platform reads it from cache and only computes the incremental part. This not only reduces token consumption substantially, it also cuts time-to-first-token (TTFT), improving the end-user experience. Combined with logging and monitoring, developers can track cache hit rates in real time and use the data to refine prompt structures and context organization.
Conclusion
LLM token billing is not an opaque black box. By keeping careful logs and fitting the data, developers can uncover the underlying cost structure of any model API. The path to cost-effective production applications lies not in relying on a single high-end model for everything, but in adopting a layered routing strategy: flagship models for planning, mid-tier models for reasoning, low-cost models for execution, and ultra-lightweight models for batch workloads. Combined with aggressive use of context caching, this approach makes it feasible to build high-quality, high-throughput AI applications under real budget constraints.
One important caveat: the cost figures in this article were derived from empirical testing over a specific time window. Actual pricing may shift as platforms adjust their billing policies. Teams should establish a continuous cost-monitoring loop to keep the architecture economical over the long run.
