Multi-Model Tiered Routing: Reducing Token Spend Without Compromising Quality

    This article explains how to reduce large language model costs by matching each task to the lowest-cost model tier that still meets quality requirements. It covers where token spend comes from, how to profile and tier tasks, how to implement automatic routing and low-to-high escalation, how to validate quality with boundary cases, and how to monitor cost per passed task after deployment.

    1. Background: Same Results, Different Bills

    In real-world operations, many teams connect multiple large language models at the same time. After a batch of test tasks is completed, a common situation emerges: outputs from different models all pass acceptance checks, but token consumption differs significantly. This shows that the boundary of model capability and the boundary of cost do not coincide. When the capability is sufficient to complete a task, continuing to pay for “extra capability” is a waste of resources.

    Therefore, the core question of cost optimization is not “which model is the best,” but “for this type of task, what is the lowest-cost solution that meets the quality requirement?” This approach turns model selection from an experience-based judgment into a quantifiable engineering decision.

    2. Decomposing Costs: Where Token Consumption Comes From

    To control costs, you first need to know where the money is spent. The consumption of a single model call usually consists of the following parts.

    1. Input tokens: This includes system prompts, conversation history, and retrieved document fragments. The longer the context, the higher the base cost of a single call.
    2. Output tokens: The length of the content generated by the model. Output is often priced higher than input, so verbose responses can significantly increase costs.
    3. Reasoning tokens: Some models perform internal reasoning before answering, and this consumption is also counted toward the quota. For complex tasks, the amount of reasoning can be much larger than the final output.
    4. Retries and tool calls: Additional requests are generated when output format is non-compliant, a call fails, or the result needs a second correction. Many teams overlook this item, but it is often a hidden source of cost overruns.

    Looking only at the price per call can easily lead to one-sided conclusions. A more reasonable metric is “average cost per passed task,” that is, total consumption divided by the number of tasks that pass acceptance. This metric reflects unit price, length, retry rate, and pass rate at the same time.

    1. def cost_per_passed_task(records: list[dict]) -> float:
    2. """Each record contains cost (float) and passed (bool) fields."""
    3. total_cost = sum(r["cost"] for r in records)
    4. passed = sum(1 for r in records if r["passed"])
    5. return total_cost / passed if passed else float("inf")

    3. Task Tiering: Assess Difficulty Before Choosing a Model

    Task tiering is a prerequisite for cost optimization. If all requests are sent to the strongest model, costs will inevitably be high; if all are sent to the lightest model, quality risks will be unacceptable. The goal of tiering is to place each request in the tier that is “just enough.”

    Tasks can be evaluated from the following dimensions:

    • Degree of structure: Whether the output has a fixed format, such as a table, JSON, or a specific template. Tasks with clear formats usually require less model reasoning depth, but they do require format-following ability.
    • Reasoning chain length: Whether multi-step calculation, cross-condition judgment, or logical deduction is required. The more reasoning steps, the stronger the model needed.
    • Context size: How long the material to be processed is. Long context itself raises costs, so retrieval or summarization should be used to compress input.
    • Risk level: How high the cost of an error is. For tasks involving financial, compliance, or safety judgments, a high-quality tier should be maintained even if the cost is higher.
    1. from dataclasses import dataclass
    2. @dataclass
    3. class TaskProfile:
    4. input_tokens: int # Estimated input length
    5. needs_reasoning: bool # Whether multi-step reasoning is required
    6. strict_format: bool # Whether the output has strict format requirements
    7. risk_level: int # 1 low, 2 medium, 3 high
    8. def choose_tier(task: TaskProfile) -> str:
    9. # Thresholds are examples and must be calibrated on your own dataset, not copied directly.
    10. if task.risk_level >= 3:
    11. return "premium"
    12. if task.needs_reasoning or task.input_tokens > 32_000:
    13. return "standard"
    14. if task.strict_format:
    15. return "standard"
    16. return "economy"

    Tiering rules are not finalized in one pass. It is advisable to validate them first with a small sample, then continuously revise thresholds based on online failure cases.

    4. Model Tiers and Automatic Routing

    Dividing available models into several tiers by capability and price is a common practice in multi-model architectures. They are usually divided into three layers:

    • Economy tier: Suitable for summarization, classification, simple extraction, and format conversion.
    • Standard tier: Suitable for multi-condition judgment, code modification, document rewriting, and other medium-complexity tasks.
    • Premium tier: Suitable for complex reasoning, high-risk decisions, and scenarios requiring strict validation.

    Automatic routing can reduce the burden of manual selection, but it is not a universal solution. Automatic routing usually judges based on surface features of the request content and may underestimate some implicit complexity. Therefore, it is advisable to retain manual override and fallback mechanisms.

    A more reliable approach is a “low-to-high” escalation strategy: first try the economy tier, and if validation fails, escalate to a higher tier. The following example shows the skeleton of this flow.

    1. from typing import Callable, Any
    2. def run_with_escalation(
    3. task: Any,
    4. tiers: list[str],
    5. run: Callable[[str, Any], Any],
    6. check: Callable[[Any], bool],
    7. ) -> tuple[str, Any]:
    8. for tier in tiers: # For example, ["economy", "standard", "premium"]
    9. result = run(tier, task)
    10. if check(result):
    11. return tier, result
    12. raise RuntimeError("No tier passed validation; route to manual handling")

    Two points require attention in the escalation strategy. First, the validation function must be reliable; otherwise, incorrect outputs from a lower-tier model may be mistakenly judged as passing. Second, escalation increases total latency and cost, so the upgrade ratio of each tier should be tracked to confirm that the strategy actually brings benefits.

    5. Quality Validation: Do Not Rely Only on Sample Pass Rates

    When comparing the costs of different models, you must first confirm that their quality is truly comparable. A common mistake is using test samples that are too simple. When sample difficulty is low, most models will receive full marks, and the conclusion of “completely equivalent” is unreliable.

    It is recommended to build an evaluation set according to the following steps:

    1. Cover typical scenarios: Extract high-frequency tasks from real business operations to ensure the distribution matches online traffic.
    2. Add boundary cases: Include missing fields, abnormal formats, ambiguous input, and very long text. These cases best expose capability differences.
    3. Run multiple times to assess stability: Call the same input multiple times and observe output consistency. Occasional correctness does not equal reliability.
    4. Record complete metrics: Include pass rate, input and output length, latency, retry count, and cost per passed task.

    Only when performance is also close on boundary cases does a low-cost solution have practical replacement value.

    6. Cost Monitoring and Budget Control

    After optimization, continuous monitoring is required; otherwise, costs will rise again with business growth and model version changes. At a minimum, monitor the following metrics:

    • Cost per passed task, broken down by business line and task type.
    • Request share and escalation ratio for each tier.
    • Retry rate and validation failure rate, which often indicate declining output quality.
    • Consumption peaks for individual users or individual tenants.

    For budget control, you can set a daily quota limit for each business line and downgrade to the economy tier or trigger an alert when approaching the threshold. Downgrade policies should be evaluated in advance to avoid a sudden drop in service quality during critical business periods.

    1. import logging
    2. logger = logging.getLogger("llm_cost")
    3. def log_call(task_type: str, tier: str, cost: float, passed: bool) -> None:
    4. logger.info(
    5. "task_type=%s tier=%s cost=%.4f passed=%s",
    6. task_type, tier, cost, passed,
    7. )

    Log fields should include task type and tier so that aggregation and analysis by dimension can be performed later.

    7. Implementation Steps and Considerations

    It is recommended to proceed in the following order:

    1. Review existing call scenarios and count task types and the share of each type of request.
    2. Build an evaluation set containing boundary cases for each task type.
    3. Compare the quality and cost of models in each tier on the evaluation set, and determine the lowest usable tier for each task type.
    4. Implement tiered routing and escalation mechanisms, while retaining a manual override entry point.
    5. After launch, continuously monitor cost per passed task, and re-evaluate whenever model versions or billing rules change.

    Pay special attention to the following points:

    • Safety and compliance scenarios should not be downgraded: For tasks involving private data, financial judgment, or legal risk, cost savings must not come at the expense of compliance.
    • Data isolation: Evaluation and logs may contain sensitive information, so data should be masked and access permissions should be restricted.
    • Billing information should be based on official documentation: Prices and quota rules for different services change, so any numbers in a plan should be rechecked before implementation.
    • Avoid single-point dependency: When multiple tiers and multiple providers coexist, downgrade paths should be designed to prevent a single service failure from causing a full outage.

    In short, the key to multi-model cost optimization is to use data to determine the boundary of “good enough,” and then use engineering methods to route requests reliably to the corresponding tier. This approach is independent of any specific provider and can be continuously iterated as business and technical environments change.