LLM Selection Guide: Evaluating Context Window, Cost, and Speed
This article explains how to select a large language model by evaluating context window, maximum output length, knowledge cutoff, token-based cost, and latency. It outlines common misconceptions and provides repeatable methods for cost estimation, latency benchmarking, and building an in-house evaluation set, so teams can compare quality, cost, and speed under one framework.
Large language model services have moved from “can it work?” to “how should we choose a model, calculate cost, and use it reliably?” Model vendors release new versions at intervals and adjust context length, output limits, unit prices, and speed at the same time. If developers look only at the numbers in an announcement, it is difficult to judge which model fits their business. Using a common version update as background, this article abstracts the metrics that matter during model selection, explains what each metric means and where common misconceptions arise, and provides calculation and evaluation methods that can be applied directly. The figures in this article are only for demonstrating the calculation process and do not represent the actual prices or performance of any specific product.
1. Understand the Basic Parameters
Context Window
The context window is the maximum number of tokens a model can receive in a single request. It includes the system prompt, conversation history, retrieved snippets, document content, and the output the model has already generated. A larger window allows an application to place a longer document in a single request and reduces the work of splitting and reassembling content.
However, window size does not equal effective utilization. Information in the middle of a long text is often harder to recall accurately than information at the beginning or end, so engineering teams still need retrieval, summarization, or segmentation strategies. During model selection, verify whether key information can be extracted consistently from your own long-document samples instead of looking only at the maximum window size.
Maximum Output Length
The maximum output length limits the number of tokens generated in a single response and determines whether long reports, code generation, or batch structured output can be completed in one pass. The output limit is not a recommended value. Longer output takes more time and costs more. For most interactive scenarios, keeping output within the necessary range is more cost-effective than pursuing the maximum.
Knowledge Cutoff
The knowledge cutoff is the latest date represented in the training data. It affects the quality of a model’s answers about recent events, new library versions, and new policies. If a business depends on the latest information, it should use retrieval-augmented generation to place external data in the context rather than relying on the model’s own memory.
2. Cost Model: Token-Based Billing
Most model APIs price input tokens and output tokens separately, and some services provide a separate unit price for input tokens that hit the cache. The cost of a single request can be written as:
Cost = input tokens × input price + output tokens × output price + cached tokens × cache price
Prices are usually expressed per million tokens. Output prices are generally higher than input prices, so the cost share of generating long text can be much higher than intuition suggests.
Calculating a price reduction is also straightforward. If the old input price is 10 and the new input price is 8, the reduction is (10 − 8) / 10 = 20%. But whether a price cut actually saves money also depends on the input-to-output ratio of the business, the cache hit rate, and the average length of a single request. The following pseudocode estimates the cost of a single request. The prices are demonstration assumptions; refer to the service provider’s official price list.
function estimateCost(inTokens, outTokens, cachedTokens, priceIn, priceOut, priceCache):perMillion = 1000000return (inTokens * priceIn + outTokens * priceOut + cachedTokens * priceCache) / perMillionold = estimateCost(20000, 2000, 0, priceIn=10, priceOut=50, priceCache=1) // result is approximately 0.30new = estimateCost(20000, 2000, 0, priceIn=8, priceOut=40, priceCache=0.8) // result is approximately 0.24
In this example, input and output prices are reduced together, so the cost per request also drops by 20%. If the business mainly involves long input and short output, the actual reduction will be affected more by input price changes. Use your own real traffic distribution in the calculation rather than a fixed sample.
3. Speed Metrics: Understanding Latency
Model response latency consists mainly of two parts. Time to First Token (TTFT) is the time from sending a request to receiving the first output token. Generation rate is the number of output tokens per second. Total latency can be approximated as:
Total latency ≈ TTFT + output tokens ÷ generation rate
A vendor’s claim of “up to a certain percentage improvement” is usually an upper bound measured under specific conditions. It may not match your prompt length, concurrency level, and network environment. Therefore, test in your own environment.
A basic benchmark should meet these requirements: use a fixed prompt set, repeat each prompt multiple times, report median (P50) and tail latency (P95), record streaming and non-streaming performance separately, and test at different times. The following pseudocode illustrates the approach:
function benchmark(callModel, prompts, runs):ttftList = []totalList = []for prompt in prompts:for i in 1..runs:start = now()firstAt = nullfor chunk in callModel(prompt, stream=true):if firstAt is null:firstAt = now() - starttotalList.append(now() - start)ttftList.append(firstAt)return {ttftP50: median(ttftList),totalP50: median(totalList),totalP95: sortedAt(totalList, min(len(totalList) - 1, floor(len(totalList) * 0.95)))}
4. Build Your Own Evaluation Set
Public leaderboards reflect general capabilities and may not cover your business scenarios. An in-house evaluation set is the most reliable basis for model selection. Consider building one with the following steps:
- Collect 100 to 300 samples from real business traffic, covering common tasks and edge cases.
- Define scoring criteria for each sample, such as factual correctness, format compliance, information completeness, and whether a refusal is appropriate.
- Fix the system prompt, temperature parameter, and output length limit so that different models are evaluated under the same conditions.
- Conduct blind reviews so that reviewers do not know which model produced which result.
- Record token usage, cost, and latency for each sample, and calculate “quality per unit cost.”
The output of this step is a comparison table that places quality, cost, and speed in the same frame, helping the team decide which option is most suitable within budget.
5. Engineering Recommendations
- Model routing: Use lower-cost models for simple tasks such as classification and extraction, and route complex reasoning tasks to higher-capability models.
- Prompt trimming: Remove irrelevant conversation history and limit the number and length of retrieved snippets.
- Output constraints: Specify output format and length limits explicitly to avoid unnecessary long-form output.
- Cache design: Stable system prompts and fixed knowledge snippets are suitable for caching to reduce the cost of repeated input.
- Usage monitoring: Record token counts, latency, and error rates for each request, and set budget alerts.
- Canary migration: When switching model versions, start with a small canary traffic share and compare key metrics before a full rollout.
6. Common Misconceptions
- Comparing only unit prices without calculating the total number of tokens required to complete the same task. Differences in output style across models can cause large differences in total cost.
- Treating the context window limit as the usable limit and ignoring information loss in long text.
- Replacing repeated statistical testing with a single test, which makes conclusions vulnerable to network fluctuations.
- Ignoring the additional cost of retries after failures and timeouts.
- Equating vendor-promoted performance improvements directly with benefits to your own business.
7. Conclusion
Model selection is an engineering decision based on data. The context window, output limit, and knowledge cutoff determine what a model can do; the billing structure determines the cost of doing it once; and speed metrics determine user experience. These three types of metrics should be evaluated within the same framework, with results from your own evaluation set as the basis. If a team can turn cost estimation, latency benchmarking, and quality evaluation into repeatable processes, it can complete evaluation and migration within days when a new version is released, instead of relying on announcements to make decisions.
