LLM API Selection: Cost, Speed, and Reasoning Overhead
This article presents a practical framework for selecting large language model APIs based on consistent measurement. It explains how to calculate blended per-token costs with cache hits and output share, break response speed into TTFT, generation throughput, and reasoning overhead, make reasoning cost and progress visible, route tasks to different models, and monitor calls for ongoing review. The goal is to base decisions on a team’s own runtime data rather than launch materials alone.
1. Why Reevaluate After a Model Release
When a new model launches, promotional materials usually list parameter scale, context length, unit price, and speed. These numbers mean little in isolation. What actually affects team decisions is the real cost, latency, and output quality for the same type of task within the same time window.
Before evaluation, define a consistent baseline: a fixed task set, a fixed time window, and a fixed measurement method. Otherwise, comparison results will include task differences and time-window differences, making conclusions unreliable.
2. Cost Measurement: From the Bill Back to Unit Tokens
2.1 Standardize the Pricing Unit
Most pay-as-you-go services price by million tokens. The conversion formula is:
Cost per million tokens = Total cost / Total tokens × 1,000,000
Looking only at unit price can easily lead to misjudgment. Many services offer cached pricing for repeatedly read context, and the higher the cache hit rate, the lower the actual average price. Therefore, when measuring, record the input, output, and cache-hit data for each call rather than only totals.
2.2 Calculate the Blended Average Price
If a service distinguishes cache hits from misses, the input unit price can be calculated as a weighted value:
Effective input price = Hit rate × Hit price + (1 − Hit rate) × Miss price
Output share also affects the result. Output price is usually higher than input price. If a type of task has a high output ratio, the overall average price will rise even if the input price is low.
Example code:
def cost_per_million(total_cost: float, total_tokens: int) -> float:"""Return the average cost per million tokens in the same unit as total_cost."""if total_tokens <= 0:raise ValueError("total_tokens must be greater than 0")return total_cost / total_tokens * 1_000_000def blended_input_price(hit_ratio: float, price_hit: float, price_miss: float) -> float:"""Calculate the weighted input price based on cache hit rate."""return hit_ratio * price_hit + (1 - hit_ratio) * price_miss
2.3 Break-Even Point Between Pay-as-You-Go and Monthly Plans
The choice between pay-as-you-go billing and a monthly subscription depends on actual usage. Let the monthly fee be F, the pay-as-you-go price be p per million tokens, and monthly usage be U million tokens. When p × U exceeds F, the monthly plan is more cost-effective.
Use your own actual usage for this judgment, not the quota advertised by the plan. Many plan quotas do not match actual usage intensity, so estimates based on historical data are more reliable.
Example: one test consumed 180 million tokens and cost CNY 31, equivalent to about CNY 0.17 per million tokens. This number only represents that task mix and cannot be directly extrapolated to other scenarios. If the task structure differs, the cache hit rate and output share will change, and the average price will also differ.
3. Response Speed: Break It Into Three Time Segments
The “slowness” users perceive usually comes from three stages:
- Time To First Token (TTFT): the time from sending the request to receiving the first output chunk, mainly affected by queuing and prefill.
- Generation throughput: the number of tokens output per second, affected by model size, service load, and concurrency limits.
- Reasoning-phase overhead: some models first output reasoning content. These tokens consume time but may not be directly shown to users.
3.1 Measurement Method
import timedef measure_stream(stream):start = time.perf_counter()first_at = Nonecount = 0for chunk in stream:if first_at is None:first_at = time.perf_counter()count += 1 # Incremental chunks approximate token count; use the model's tokenizer for exact countsend = time.perf_counter()if first_at is None:return {"ttft": None, "tps": 0.0, "total_tokens": 0}duration = end - first_atreturn {"ttft": first_at - start,"tps": count / duration if duration > 0 else 0.0,"total_tokens": count,}
3.2 Rule Out Network Interference
To determine whether the service has slowed down or the network is the problem, run a control test. In the same time window and network environment, simultaneously request another model or service and observe whether both slow down together. If the control group is normal, the problem is likely server-side load or queuing.
3.3 Performance During Peak Hours
The same model may perform very differently at different times. When server load rises, TTFT increases and generation throughput decreases. Teams should record time-segmented data to identify stable windows rather than using a single test to represent the whole day.
This fluctuation requires product design to consider timeouts, fallbacks, and retry strategies. For example, set a reasonable timeout threshold, switch to a backup model after timeout, and show the current status to users.
4. Reasoning Cost and Visibility
Some models enable reasoning by default, and the serving side does not allow it to be turned off. This creates two practical issues.
The first is cost. Reasoning tokens are also billed. In complex tasks, the length of reasoning content may far exceed the final answer, so teams need to separately account for this cost.
The second is experience. If the interface does not show reasoning progress, users cannot distinguish “the model is still thinking” from “the service is stuck.” When the reasoning process is completely opaque, users may misjudge it as a failure.
Recommended responses:
- Show phase status in the interface, such as “reasoning” and “generating,” and display elapsed time.
- Set an output limit parameter and truncate or degrade requests that exceed the limit.
- Tier tasks by complexity and route simple tasks to models with lower reasoning overhead.
- Track the shares of reasoning tokens and answer tokens separately and include them in cost monitoring metrics.
5. Selection Framework: Route by Task
A single model can hardly satisfy all requirements at the same time. A more reliable approach is to route requests based on task characteristics.
| Dimension | Lightweight tasks | Long-document processing | Code generation | Complex reasoning |
|---|---|---|---|---|
| Latency sensitivity | High | Medium | Medium | Low |
| Output length | Short | Medium | Long | Variable |
| Cost sensitivity | High | High | Medium | Medium |
| Recommended strategy | Prefer small models | Focus on context length and caching | Focus on output quality and stability | Allow longer latency |
Routing example:
ROUTES = {"light": "small-model","long_doc": "long-context-model","code": "code-model","reasoning": "reasoning-model",}def pick_model(task_type: str) -> str:return ROUTES.get(task_type, "small-model")
The model names in the example are placeholders. In actual use, replace them with the official model IDs of the chosen service and refer to the official documentation.
6. Monitoring and Review
For each call, record the following fields: task type, model identifier, input tokens, output tokens, cache-hit tokens, reasoning tokens, TTFT, generation throughput, cost, and whether it was retried.
Aggregate data weekly and compare unit cost and task completion rate rather than only average speed. Averages hide extreme latency during peak hours, and such latency often directly affects user experience.
7. Summary
The core of model selection is measurement with a consistent baseline. First use pricing formulas to calculate unit cost, then use control tests to distinguish network issues from service issues, and finally route by task type. Parameters and promotion in release notes are only a starting point; a team’s own runtime data is the basis for decisions.
Before launch, use the following checklist:
- Whether cache hits and output share are tracked
