LLM Selection: How Usage and Cost Drive Technical Decisions

    Choosing a large language model is an engineering problem rather than a matter of personal preference. This article explains how to interpret usage and spending metrics, evaluate candidates across quality, latency, context length, billing, compliance, and reliability, and build a reproducible evaluation and cost-estimation process. It also covers model routing, common pitfalls, and practical rollout recommendations.

    1. Why Model Selection Is an Engineering Problem

    In the past, model selection was often based on personal experience. Whether a conversation flowed smoothly or a piece of code ran successfully could influence the decision. But as business scale grows, the criteria must shift from “it feels good to use” to “it can be measured.” The same model may perform very differently in customer service Q&A, code generation, document summarization, and other scenarios. A low cost per call can become a significant expense line at millions of calls per day.

    Model selection is therefore essentially a multi-objective optimization problem. The objectives include output quality, response speed, unit cost, data compliance, and service stability. These objectives often conflict with one another. The highest-quality model is often the most expensive, and the fastest model may not be the best at complex reasoning. Engineering teams need to first clarify the business weight for each objective, then validate candidate models using a reproducible method.

    2. Understanding Usage and Cost Metrics

    Public model usage rankings usually provide two dimensions: call volume and spending. They mean different things and need to be understood separately.

    Call volume reflects how frequently a model is actually used, which can be interpreted as the preference of the market and developers. It shows that a model is repeatedly selected across a large number of real requests, but it does not directly show that it is the best fit for your business. High call volume may come from low prices, easy integration, or stable performance on certain tasks; the reason needs to be judged in context.

    Share of spending reflects what users actually spend on a model. It is not proportional to call volume. If a model’s share of spending is clearly higher than its share of calls, its average cost per call is high, and users are likely using it for complex tasks or requests with high quality requirements. Conversely, a model with a high share of calls and a low share of spending is usually suitable for high-volume, low-complexity requests.

    Understanding this helps with task decomposition. For high-value, high-difficulty requests, a higher unit price can be acceptable. For large numbers of repetitive requests, models with low unit prices and high speed should be prioritized.

    How to Convert Unit Costs

    The cost of a single call consists of input and output. The formula is:

    Cost per request = input tokens × input price per token + output tokens × output price per token

    Daily and monthly costs are estimated from request volume:

    Monthly cost = average daily requests × average cost per request × 30

    Looking only at unit price can lead to misjudgments. A model with a low unit price but verbose output may cost more in practice than a model with a higher unit price but concise answers. Therefore, comparisons should use the “full cost of completing one task,” not the price per thousand tokens alone.

    3. Six Dimensions That Affect Model Selection

    1. Output Quality

    Quality needs to be evaluated by task. General Q&A, structured extraction, code generation, mathematical reasoning, and long-document understanding each require different test sets. Do not use one composite score to represent all scenarios. Quality evaluation should include sub-metrics such as accuracy, completeness, format compliance, and hallucination rate.

    2. Response Latency

    Latency is divided into first-token latency and total completion time. Interactive applications such as chat assistants and input completion are sensitive to first-token latency. Batch tasks such as offline summarization and data cleaning place more emphasis on throughput and total elapsed time. Before selecting a model, clarify which category the scenario belongs to.

    3. Context Length

    The context window determines how much content a model can process at once. Long-document analysis, multi-turn dialogue, and codebase Q&A have high requirements for the window. But the longer the window, the higher the input cost usually is. In practice, a common approach is to retrieve relevant segments first and then pass the necessary content to the model, rather than sending all material at once.

    4. Billing and Rate Limits

    Different providers may use pay-as-you-go billing, reserved capacity, or batch discounts. Rate-limit policies also affect availability during peak periods. Before launch, confirm the requests per minute, daily quota, and handling method after exceeding the limit, and reserve retry and queueing mechanisms in the architecture.

    5. Data Compliance and Privacy

    When user personal information, trade secrets, or regulated data are involved, confirm where data is stored, how long it is retained, and whether it is used for model training. Compliance requirements are usually determined by legal and security teams. Technical teams should write these constraints into hard selection criteria, filter out non-compliant candidates first, and then compare other metrics.

    6. Stability and Availability

    Model services may experience timeouts, rate limits, or version changes. Stability directly affects the online experience. During selection, observe historical availability and pay attention to version update policies. For critical businesses, ensure that at least one backup model can take over at any time.

    4. Building a Reproducible Evaluation Process

    Model selection should follow a fixed process to avoid impression-based decisions each time. The recommended process has four steps.

    Step 1: Define task types. Break the business down into independent tasks, such as intent recognition, information extraction, copy generation, and code completion. Define clear input and output formats and success criteria for each task type.

    Step 2: Build an evaluation set. Sample from real business data and cover common cases and edge cases. Each sample should include an input and a reference answer or scoring rule. The evaluation set should be updated regularly to prevent overfitting after long-term use.

    Step 3: Run offline comparisons. Use the same prompts and parameters to run the evaluation set against all candidate models, recording quality scores, latency, and token usage. Offline comparison can quickly rule out clearly unsuitable options.

    Step 4: Run an online canary release. Select a small portion of real traffic and compare user feedback, task completion rate, and manual review results. Offline metrics and online performance may diverge; canary validation is the final calibration step.

    Example Code: Batch Evaluation Framework

    The following code shows the basic structure of an evaluation. call_model is a call function wrapped by the team and should be implemented according to the actual integrated service; it is only a placeholder example here.

    1. from dataclasses import dataclass
    2. from typing import Callable, Dict, List
    3. @dataclass
    4. class EvalItem:
    5. prompt: str
    6. reference: str
    7. def evaluate_candidates(
    8. candidates: Dict[str, Callable[[str], str]],
    9. dataset: List[EvalItem],
    10. scorer: Callable[[str, str], float],
    11. ) -> Dict[str, float]:
    12. """Run the evaluation dataset against each candidate model and return average scores."""
    13. results = {}
    14. for name, call_model in candidates.items():
    15. scores = []
    16. for item in dataset:
    17. output = call_model(item.prompt)
    18. scores.append(scorer(output, item.reference))
    19. results[name] = sum(scores) / len(scores) if scores else 0.0
    20. return results

    The scorer function can be chosen according to the task. Extraction tasks can use field-level exact matching, while generation tasks can combine rule checks and manual sample scoring.

    5. Estimating Unit Costs

    After quality meets the bar, the next step is to compare costs. The following code estimates the cost per request and monthly cost. Price parameters should be filled in by the team based on each service’s pricing documentation.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Pricing:
    4. input_per_1k: float # Price per 1K input tokens, in CNY
    5. output_per_1k: float # Price per 1K output tokens, in CNY
    6. def estimate_cost(pricing: Pricing, input_tokens: int, output_tokens: int) -> float:
    7. """Calculate the cost of a single request."""
    8. return (input_tokens / 1000) * pricing.input_per_1k + \
    9. (output_tokens / 1000) * pricing.output_per_1k
    10. def monthly_cost(pricing: Pricing, avg_in: int, avg_out: int, daily_requests: int) -> float:
    11. """Estimate monthly cost from average daily requests, assuming 30 days."""
    12. return estimate_cost(pricing, avg_in, avg_out) * daily_requests * 30
    13. if __name__ == "__main__":
    14. # The following numbers are hypothetical and are used only to demonstrate the calculation.
    15. model_a = Pricing(input_per_1k=0.01, output_per_1k=0.03)
    16. model_b = Pricing(input_per_1k=0.002, output_per_1k=0.006)
    17. for name, p in [("Model A", model_a), ("Model B", model_b)]:
    18. cost = monthly_cost(p, avg_in=1200, avg_out=400, daily_requests=50000)
    19. print(f"{name} estimated monthly cost: {cost:.2f} CNY")

    Two points need attention during estimation. First, average token counts should come from real statistics in production logs, not estimates. Second, output length is affected by prompt constraints, so costs should be re-estimated after changing prompts.

    6. Combining Models with a Routing Mechanism

    Most mature systems do not use only one model. A common approach is to route requests by task difficulty: simple requests go to low-cost models, complex requests go to high-quality models, and failures are automatically downgraded.

    1. def route_request(prompt: str, complexity: str, models: dict) -> str:
    2. """Select a model based on task complexity and fall back on failure."""
    3. order = {
    4. "simple": ["fast", "quality"],
    5. "complex": ["quality", "fast"],
    6. }.get(complexity, ["fast"])
    7. last_error = None
    8. for name in order:
    9. try:
    10. return models[name](prompt)
    11. except Exception as exc: # In production, distinguish timeouts, rate limits, and parameter errors
    12. last_error = exc
    13. raise RuntimeError(f"All candidate models failed: {last_error}")

    Complexity detection itself also needs rules or a small model. It can be initially classified based on input length, keywords, or task type. The routing strategy also needs to be validated with the evaluation set to avoid wasting cost by misclassifying simple requests as complex, or affecting quality by underestimating complex requests.

    7. Common Pitfalls

    Pitfall 1: Looking only at leaderboards. Public rankings reflect overall usage and are not equivalent to performance in your business. Leaderboards can be used to narrow the candidate range, but the final conclusion should still be based on your own evaluation set.

    Pitfall 2: Comparing only unit prices. If a low-unit-price model produces verbose output or requires more retries, its overall cost may be higher. Compare the total cost of completing one task.

    Pitfall 3: Choosing once and never revisiting. Model versions are updated, and prices and capabilities also change. It is recommended to re-test quarterly and keep the evaluation set and estimation scripts for rapid iteration.

    Pitfall 4: Ignoring engineering support. Beyond model capability, caching, retries, rate limiting, logging, and monitoring also affect the final experience. These capabilities need to be built after model selection.

    8. Implementation Recommendations

    1. List the core tasks in the business and rank them by call frequency and value.
    2. Build an evaluation set with at least several hundred samples for each task type, with reference answers annotated.
    3. Set hard constraints such as data compliance and minimum availability to filter candidates first.
    4. Record quality, latency, and token usage together in offline evaluation to form a comparison table.
    5. Estimate costs for high-frequency tasks and use monthly cost as one of the decision criteria.
    6. Launch with a small canary traffic share and observe real user feedback before switching all traffic.
    7. Build routing and fallback mechanisms so the business can continue running if a single model fails.
    8. Set a fixed re-test cycle and continuously update the evaluation set and cost model.

    There is no universal optimal answer for LLM selection. The right choice depends on task type, quality requirements, cost budget, and compliance boundaries. By turning subjective judgment into reproducible metrics and processes, teams can maintain consistency and explainability in decision-making as models continue to evolve rapidly.