LLM Selection Guide: Balancing Capability, Speed, and Cost
This guide explains how to choose an LLM by weighing capability, latency, and cost against your business constraints. It covers how to build an evaluation set, measure pass rate and P95 latency, calculate the cost per task, and use a decision matrix to narrow down candidate models. It also includes practical advice on tiered routing, input and output control, and regression testing.
1. Why Model Selection Needs a Multi-Dimensional View
Large language models keep getting more capable, and more vendors are releasing them. Developers rarely ask which model is the strongest. They ask which model fits their business constraints best. These constraints often include a maximum response time, a per-request budget, the length of the input, and a minimum acceptable output quality.
Looking at a single metric can lead to poor decisions. A model with a high leaderboard score may respond slowly or cost more than the budget allows. A cheaper model may be unstable on complex reasoning or long documents. Model selection should therefore compare capability, speed, and cost within one framework, and rely on real business data.
2. Four Core Evaluation Dimensions
2.1 Overall Capability
Overall capability refers to how accurately a model completes tasks. Public leaderboards offer a rough reference, and they typically cover code generation, mathematical reasoning, common-sense question answering, and tool calling. However, leaderboards have several limitations. Test sets may overlap with training data. Scoring rules may not match real business tasks. When score differences fall within a few percentage points, the difference may not be statistically meaningful.
A more reliable approach is to build your own evaluation set. Sample the set from real business workloads, and cover common requests as well as edge cases. Define clear pass criteria for each sample. For example, code generation can be judged by unit tests, and information extraction can be judged by field-level accuracy.
2.2 Context Window
The context window determines how much input a model can receive at once. For scenarios such as code repository Q&A, contract review, and long meeting minute analysis, the window size directly determines whether a solution is feasible.
A large window does not guarantee good long-text performance. A model’s ability to extract information from the middle of a very long input may decline, a phenomenon often called “lost in the middle.” When evaluating, place key information at different positions in the input and measure the model’s actual recall. If your business only needs to process a few thousand words of text, a model with a very large window brings no benefit and only increases cost.
2.3 Latency and Throughput
Latency is usually measured from two perspectives. Time to first token (TTFT) determines how long users wait before they see a response, which matters for chat and other interactive scenarios. Total completion time determines how fast batch jobs finish. Developers should watch percentile metrics such as P50 and P95 rather than only averages, because averages can hide a small number of very slow requests.
Reasoning depth also affects latency. Some models offer adjustable thinking levels. Higher levels usually improve accuracy, but they also mean longer response times and more output tokens. Online services can choose the thinking level dynamically based on task difficulty, using a low level for simple questions and raising it for complex ones.
2.4 Call Cost
Most models charge by token, with input and output priced separately. Output prices are usually higher than input prices. When calculating the cost of a single task, count input and output tokens separately.
The cost of a single task is calculated as follows:
Cost per task = input tokens ÷ 1,000,000 × input price + output tokens ÷ 1,000,000 × output price
The code below demonstrates this calculation:
def estimate_task_cost(input_tokens, output_tokens, price_in_per_m, price_out_per_m):"""Calculate the cost of a single task. Prices are given per million tokens."""cost_in = input_tokens / 1_000_000 * price_in_per_mcost_out = output_tokens / 1_000_000 * price_out_per_mreturn cost_in + cost_out# Sample values for illustration only. They do not reflect the pricing of any actual product.cost = estimate_task_cost(input_tokens=40_000,output_tokens=3_000,price_in_per_m=2.0,price_out_per_m=8.0,)print(f"Estimated cost per task: about {cost:.4f} CNY")
A model’s reasoning process may also be counted as output tokens. As a result, actual costs may be higher than an estimate based only on the visible answer. Before launch, use usage logs from real requests as the source of truth, and set up daily cost monitoring.
3. Building Your Own Evaluation Pipeline
The code below provides a simplified evaluation framework. It measures pass rate, latency, and average cost for several candidate models at the same time. You must implement the call_model function for the API you use. Its return value should include the response text and the cost of that call.
import timedef run_benchmark(models, test_cases, call_model):results = {}for name in models:passed, latencies, costs = [], [], []for case in test_cases:start = time.perf_counter()resp = call_model(name, case["prompt"])latencies.append(time.perf_counter() - start)passed.append(case["judge"](resp.text)) # judge returns True or Falsecosts.append(resp.cost)latencies.sort()results[name] = {"pass_rate": sum(passed) / len(passed),"p50_latency_s": latencies[len(latencies) // 2],"avg_cost": sum(costs) / len(costs),}return results
When running the framework, keep the following points in mind. First, keep the test cases fixed, and use the same dataset for every comparison. Second, make the judge function as automated as possible to reduce subjective human judgment. Third, a model may return different results across repeated calls, so run key comparisons several times and use statistical values.
4. Selection Decision Matrix
After measuring, organize the results in the table below and check them against your business requirements one by one:
| Dimension | Core Question | Metric |
|---|---|---|
| Overall capability | Can the model complete business tasks reliably? | Pass rate on your evaluation set |
| Context window | Can the model fit a full document or codebase? | Recall of key information in long inputs |
| Response latency | Can users accept the wait time? | TTFT and P95 completion time |
| Call cost | Can the cost per task be sustained over time? | Input and output token counts and daily cost |
Set hard thresholds first, such as a minimum pass rate and a maximum P95 latency in seconds. Among the candidates that meet these thresholds, compare cost. This approach reflects business reality better than sorting models by an overall score.
5. Practical Recommendations
- Use a tiered strategy. Route simple tasks to lower-cost, faster models, and send complex tasks to more capable models. Routing rules can be based on input length, task type, or historical failure rate.
- Control input size. Use retrieval, summarization, and deduplication to remove irrelevant context. This lowers cost and reduces information loss in long inputs.
- Limit output length. State the output format and length requirements in the prompt, and set a reasonable maximum output token parameter to avoid unnecessary charges.
- Run regression tests continuously. Model versions and pricing can change. After each model swap or parameter change, rerun the evaluation set to confirm that key metrics have not dropped noticeably.
- Check official sources. Pricing, context length, and feature support should be verified against the latest documentation from the model provider. The figures in this article are examples of the method only. Verify them again before making any real decision.
6. Conclusion
Model selection means translating general benchmarks into business metrics. Capability, speed, and cost constrain each other, and no single model leads on every dimension. Start by defining your business constraints, validate candidate models with your own data, and make the final decision based on cost per task and user experience.
