LLM Model Selection in Practice: Balancing Per-Task Cost and User Experience

    This article presents a practical framework for selecting LLMs by per-task total cost rather than token price alone. It breaks evaluation into cost, quality and user satisfaction, and end-to-end task duration; outlines a reproducible blind-test workflow; provides sample Python code for calculating average per-task cost, duration, and satisfaction from call logs; and recommends tiered routing, common pitfalls, and rollout steps.

    1. Why Model Selection Should Start with Per-Task Cost

    A model’s sticker price is calculated per million tokens, but the business cares about how much it costs to complete one task. For the same code modification task, one model may read more context and produce a longer reasoning process, and the final bill may not be lower. Therefore, model selection should use “total cost to complete one task” as the core metric rather than ranking models by unit price.

    Per-task cost has three components: input token cost, output token cost, and additional overhead from retries, tool calls, and multi-turn interactions. Ignoring any one of these distorts the comparison.

    2. Breaking Down the Evaluation Dimensions

    A complete model evaluation usually covers three dimensions.

    2.1 Cost

    Cost metrics need a consistent definition. The following rules are recommended:

    • Price input and output separately, because their unit prices usually differ.
    • If the service supports context caching, count cached input separately.
    • Record actual pricing during peak and off-peak periods to avoid replacing real bills with ideal prices.
    • Include tokens from failed retries and manual rework in the total.

    2.2 Quality and User Satisfaction

    Quality is difficult to measure with a single automated metric. A common approach is to have real users or senior engineers score the output on correctness, readability, adherence to constraints, and whether a second revision is needed. Satisfaction is a composite judgment. A five-point scale is recommended, and reviewers should write down the reasons for any deductions so that issues can be attributed later.

    2.3 Task Duration

    Duration should be calculated end to end: from submitting the request to the user receiving a usable result, including queuing, generation, tool execution, and waiting for human confirmation. Measuring only the model’s first-token latency underestimates the actual time.

    3. Building a Reproducible Blind Test Process

    Blind testing reduces the influence of brand impressions and subjective preferences on scoring. The steps are as follows.

    3.1 Build a Task Set

    The task set should cover the real distribution of the business. For AI-assisted coding scenarios, for example, tasks can be divided into the following categories:

    • Function-level code generation
    • Defect localization and repair
    • Unit test completion
    • Code explanation and documentation
    • Configuration file and script writing
    • Multi-file refactoring

    Keep enough samples in each category and label difficulty levels for stratified analysis. Task content should be desensitized and must not contain secrets, personal information, or unauthorized business data.

    3.2 Anonymize and Randomize

    The scoring interface should not show model names. Candidate outputs for each task should be presented in random order. Model identifiers should be stored only in the backend and linked after scoring is complete. This step effectively reduces position bias and label bias.

    3.3 Sample Size and Significance

    If there are only a few samples per task category, conclusions can easily be driven by individual samples. In practice, run statistical tests on satisfaction differences, such as paired tests or bootstrap estimates of confidence intervals. Adjust model selection only when the difference is statistically stable.

    4. Calculating Per-Task Cost

    The following example shows how to calculate the average per-task cost of each model from call logs. The price parameters in the code should be filled in by the user based on their own provider’s bill. The example itself does not contain any specific prices.

    1. from dataclasses import dataclass
    2. from collections import defaultdict
    3. @dataclass
    4. class TaskRecord:
    5. model: str
    6. input_tokens: int
    7. cached_input_tokens: int
    8. output_tokens: int
    9. retries: int
    10. duration_s: float
    11. satisfied: bool # satisfaction result from blind testing
    12. def task_cost(rec: TaskRecord, price: dict) -> float:
    13. """price is the price per million tokens; keys include
    14. input, cached_input, and output, filled in by the user based on billing."""
    15. fresh_input = rec.input_tokens - rec.cached_input_tokens
    16. per_attempt = (
    17. fresh_input * price["input"]
    18. + rec.cached_input_tokens * price["cached_input"]
    19. + rec.output_tokens * price["output"]
    20. ) / 1_000_000
    21. # Retry costs are included as well
    22. return per_attempt * (1 + rec.retries)
    23. def summarize(records, prices):
    24. stats = defaultdict(lambda: {"n": 0, "cost": 0.0, "time": 0.0, "ok": 0})
    25. for r in records:
    26. s = stats[r.model]
    27. s["n"] += 1
    28. s["cost"] += task_cost(r, prices[r.model])
    29. s["time"] += r.duration_s
    30. s["ok"] += int(r.satisfied)
    31. return {
    32. m: {
    33. "avg_cost": s["cost"] / s["n"],
    34. "avg_time_s": s["time"] / s["n"],
    35. "satisfaction_rate": s["ok"] / s["n"],
    36. }
    37. for m, s in stats.items()
    38. }

    The three output metrics should be viewed together. A model with the lowest per-task cost but noticeably lower satisfaction may have hidden rework costs that offset the apparent savings. Conversely, a model with the highest satisfaction but long duration can slow down development.

    5. Organizing Model Choices by Tier

    Most teams do not use only one model. A more practical approach is to divide models into tiers and route by task difficulty.

    • Lightweight tier: suitable for low-risk tasks such as format conversion, simple completion, and comment generation, with a focus on low cost and low latency.
    • Standard tier: suitable for regular feature development and test writing, balancing cost and quality.
    • High-end tier: suitable for cross-module refactoring, complex defect localization, and architecture discussions, prioritizing correctness.

    Routing rules can start with simple judgments based on task type and number of files, then iterate based on online feedback. After each routing change, rerun the blind-test task set to confirm that quality has not regressed in any task category.

    6. Common Pitfalls

    First, replacing multi-round statistics with a single test. Scores from one run can fluctuate widely; repeat the test multiple times and record variance.

    Second, looking only at list price. A low list price does not mean low per-task cost; long outputs or frequent retries can push up costs.

    Third, ignoring peak pricing. Many services have actual prices during peak hours that differ from standard prices; use real billing values in evaluation.

    Fourth, using an evaluation set that is inconsistent with production data. If the task set contains only simple examples, the conclusions cannot be extrapolated to complex business scenarios.

    7. Implementation Recommendations

    Proceed in the following steps. First, map the task categories and their proportions in the business. Then build a desensitized task set. Next, complete anonymous blind testing and record cost, satisfaction, and duration. After that, use statistical methods to test differences, define tiers, and design routing rules. Finally, launch with limited traffic, continuously monitor changes in per-task cost and satisfaction, and re-evaluate quarterly or after model version updates.

    Model selection is a continuous engineering problem. By fixing cost definitions, scoring rules, and statistical methods, teams can make explainable decisions with the same yardstick in an environment of rapid model updates.