How to Choose Cost-Effective LLM API Solutions After Price Increases
As LLM API pricing becomes increasingly stratified, developers and enterprises need a more rigorous way to evaluate cost-effectiveness than comparing list prices alone. This article explains the billing structure of input, cached, and output tokens, shows how request scale, task complexity, retries, and post-processing affect total cost, and examines how different workloads—such as general Q&A, long-document processing, code generation, and agent applications—require different model choices. It also covers caching, output-length control, quantifiable evaluation metrics, and tiered routing, providing a practical framework for selecting LLM API solutions that balance task quality, effective task cost, stability, latency, and scalability.
As LLM capabilities continue to improve, API pricing is becoming increasingly stratified. The invocation cost of some high-capability models has risen noticeably, especially the price of output tokens, which is often much higher than that of input tokens. For developers and enterprise users, “which model is cheapest” is no longer a sufficiently accurate question. A more important question is: under the premise of meeting task quality requirements, which solution can provide lower total cost, a more stable invocation experience, and higher business output?
Therefore, judging the cost-effectiveness of LLMs should not rely only on comparing the listed price per million tokens. Instead, it is necessary to build a complete evaluation framework that comprehensively considers input cost, caching cost, output cost, request scale, task complexity, retry ratio, and post-processing cost.
1. First Understand the Billing Structure of LLM APIs
At present, most LLM APIs divide costs into three categories: input tokens, cached hit tokens, and output tokens.
1.1 Input Token Costs
Input tokens are the content that developers send to the model, including system instructions, user questions, conversation history, retrieval results, tool-call parameters, and text processed from uploaded documents.
For simple question answering, the input is usually not large. However, in scenarios such as enterprise knowledge bases, code analysis, and long-document summarization, the input can grow rapidly. For example, a single request may contain:
- A fixed system prompt;
- The user’s current question;
- Multi-turn conversation history;
- Several retrieved document fragments;
- Business rules and formatting requirements;
- Tool-call results.
Therefore, although the input price may appear low, when the request volume reaches hundreds of thousands or even millions of calls, the cumulative cost can still be substantial.
1.2 Cached Hit Token Costs
Caching is typically used to handle recurring context, such as fixed system prompts, long-term business rules, product documentation, or codebase indexes.
If part of the input can be served from cache, its price is usually significantly lower than that of regular input. For applications with long fixed prefixes, caching may be more effective than simply choosing a lower-priced model.
It is important to note that caching does not mean all historical content can be reused permanently for free. The actual cost still depends on cache validity period, hit rate, cache granularity, and whether the request content remains stable. Therefore, when designing prompts, fixed content should be placed as early as possible and frequently changing user content should be placed later to improve the probability of cache reuse.
1.3 Output Token Costs
Output tokens are the answers, code, structured data, or tool-call instructions generated by the model. For many models, the unit price of output is significantly higher than that of input, which is also a major reason why actual bills can exceed expectations.
For example, if an application sends only a few hundred tokens of input per request but the model generates several thousand tokens of output on average, the real cost driver may be output length rather than input. This is particularly likely in long-form report generation, code refactoring, batch data extraction, and multi-turn agent tasks.
2. Why You Cannot Look Only at “Price per Million Input Tokens”
Suppose one model has a low input price but a high output price, while another model has a slightly higher input price but can complete the task with shorter, more accurate answers. Based on input price alone, the former may seem more cost-effective. However, after calculating the full request cost, the result may be completely the opposite.
The base cost of a single request can be estimated as follows:
Single-request cost =input tokens × input unit price+ cached hit tokens × cache unit price+ output tokens × output unit price
If prices are calculated per million tokens, this can be written as:
Cost =input tokens / 1,000,000 × input price+ cached tokens / 1,000,000 × cache price+ output tokens / 1,000,000 × output price
After further considering failed retries, content moderation, retrieval services, log storage, and network transmission, the total business cost should also include engineering overhead:
Total cost =model invocation cost+ retry cost+ retrieval and storage cost+ monitoring and logging cost+ development and operations cost
Therefore, the model unit price is only one part of total cost and cannot be directly equated with business cost.
3. How Different Tasks Affect Model Selection
3.1 General Q&A: Prioritize Lightweight Models
Tasks such as customer-service Q&A, text classification, keyword extraction, intent recognition, and simple rewriting usually do not require the strongest reasoning capability. If the input and output formats are clear, lightweight models are often sufficient.
The characteristics of these tasks are:
- High request volume per single call;
- Short output content;
- Lower requirements for highly complex reasoning;
- Greater focus on response speed and stability.
For these scenarios, priority should be given to testing the lightweight model’s accuracy, refusal rate, and format-following ability. If business metrics meet the requirements, using a high-priced model usually causes unnecessary waste.
3.2 Long-Document Processing: Focus on Input and Caching
Tasks such as contract analysis, knowledge-base Q&A, and technical-document summarization often involve large numbers of input tokens. In this case, input unit price, context utilization, and cache hit rate are more important than output price.
Optimization directions include:
- Chunk documents to avoid sending the complete original text every time;
- Retrieve only content relevant to the question;
- Build caches for fixed instructions and general background;
- Remove duplicate headings, meaningless formatting, and redundant historical messages;
- Control the number of retrieved fragments to avoid excessive context expansion.
It should be emphasized that blindly increasing context does not necessarily improve results. Overly long input may increase cost and may also make it harder for the model to focus on truly important information.
3.3 Code Generation and Complex Reasoning: Focus on Cost per Task
Code generation, fault localization, architecture design, and complex data analysis usually require stronger reasoning capabilities. Even if a high-capability model has a higher per-call price for such tasks, it may reduce overall cost because of a higher first-pass success rate.
For example, a low-priced model may require multiple revisions to produce a runnable result, while a high-capability model may generate code that passes tests in one attempt. In this case, the comparison should be “how much it costs to complete a valid task” rather than “how much one request costs.”
The following metric can be used:
Effective task cost =total invocation cost / number of successfully completed tasks
If a model has a higher per-call price but a significantly higher success rate, its effective task cost may actually be lower.
3.4 Agent Applications: Focus on Loop Count
An agent typically goes through multiple steps such as planning, retrieval, tool calling, result judgment, and final output. One user request may correspond to multiple model calls, or even looped execution.
Therefore, agent scenarios require particular attention to:
- The average number of calls per task;
- Whether each round repeatedly carries historical context;
- Whether tool results are too long;
- Whether a maximum loop count is set;
- Whether unlimited retries occur after failure;
- Whether simple tasks can terminate early.
For agents, it is not enough to choose an appropriate model. It is also necessary to design a clear state-management mechanism to reduce repeated context and invalid reasoning.
4. Caching Is an Important Way to Reduce Costs
In enterprise applications, system prompts and business rules are usually highly stable. If every request is fully billed again, cost will grow linearly with call volume. Caching fixed context can reduce the cost of repeated input.
A reasonable prompt structure can be divided into three parts:
Fixed part:role definition, business rules, output format, long-term knowledgeSemi-fixed part:current session background, user preferences, task typeDynamic part:current question, real-time data, tool return results
The fixed part should remain as stable as possible, avoiding cache invalidation caused by irrelevant timestamps, random IDs, or dynamic fields.
However, more cache is not always better. Excessive cached content may increase management complexity, and an unreasonable expiration policy may cause old rules to remain in effect. Therefore, enterprises should regularly measure cache hit rates and calculate the actual savings brought by caching.
5. Do Not Ignore Output Length Control
Output length is one of the most easily overlooked cost variables. Many applications use instructions such as “please be as detailed as possible” or “fully elaborate” in prompts without setting clear output boundaries, ultimately generating large amounts of unnecessary text.
The following methods can be used to control output cost:
5.1 Specify Format and Length
For example, require that:
- Only a JSON structure be returned;
- Each field not exceed a specified number of characters;
- A summary be limited to a certain number of bullet points;
- Code return only key functions;
- The user question not be restated.
5.2 Separate Analysis from the Final Result
If the business only needs the final answer, do not make the model output a lengthy intermediate process. For tasks that require reasoning, analysis can be completed internally, and only the conclusion, rationale, and necessary execution results should be returned.
5.3 Set Truncation and Timeout Mechanisms
For automated tasks, set a maximum output length, maximum call time, and maximum loop count to prevent abnormal requests from continuously consuming resources.
5.4 Use Tiered Generation
For simple questions, return a short answer first, and expand into detailed content only when the user explicitly requests it. This can reduce average output length and improve interaction speed.
6. Build a Quantifiable Model Evaluation System
When selecting a model, it is recommended not to rely only on subjective experience. Instead, build a test set and cost metrics.
At a minimum, the following data can be measured:
- Task success rate;
- Factual accuracy;
- Format compliance rate;
- Average input tokens;
- Average output tokens;
- Average response time;
- Number of failed retries;
- Cost per effective task;
- Stability during peak periods.
A simple composite score can be defined:
Overall value =business quality score × weight+ stability score × weight+ response speed score × weight- total cost score × weight
Different businesses should use different weights. Customer-service systems may place more emphasis on response speed and stability; R&D assistant tools may place more emphasis on code correctness; document-analysis systems may place more emphasis on long-context processing capability and information-extraction accuracy.
7. Use Tiered Routing Instead of a Single Model
For medium and large applications, the most reasonable approach is usually not to use the same model for all requests, but to establish a model-routing mechanism.
A common tiered strategy is:
- Use lightweight models for simple classification, rewriting, and extraction tasks;
- Use balanced models for medium-complexity Q&A;
- Use high-capability models for high-value, reasoning-intensive, and high-risk tasks;
- Escalate to a higher-capability model when the lightweight model’s confidence is insufficient.
Routing can be based on the following conditions:
- Length of the user question;
- Whether code is included;
- Whether multi-step reasoning is required;
- Whether high-risk business is involved;
- Confidence of the lightweight model;
- Historical failure rate;
- Current system load and budget.
This approach allows high-priced models to be used where they are truly needed while preventing low-priced models from handling tasks beyond their capabilities.
8. How Should Cost-Effectiveness Ultimately Be Judged?
True cost-effectiveness is not the lowest unit price, but the combined result of the following factors:
- Whether task quality meets the bar: A cheap model that cannot complete the task has no practical value.
- Whether effective task cost is reasonable: Calculate how much it truly costs to complete one task successfully.
- Whether output length is controllable: Overly long output significantly amplifies cost.
- Whether cache hit rate is high enough: The more fixed context there is, the more obvious the value of caching.
- Whether failures and retries are controllable: Frequent retries can erase the advantage of a low price.
- Whether response speed meets business requirements: Excessive latency may affect conversion and user retention.
- Whether it remains stable at scale: Small-traffic test results do not necessarily represent production performance.
Overall, cost-sensitive applications should prioritize lightweight models and tiered routing; complex reasoning applications should focus on success rate and effective task cost; long-context applications should focus on optimizing retrieval, caching, and input compression; and agent applications must control call rounds, tool-result length, and failed retries.
Changes in LLM prices are only the surface. What truly determines input-output returns is the combined effect of model capability, invocation patterns, and engineering architecture. Rather than blindly chasing the lowest price, it is better to first establish a complete cost-monitoring and effectiveness-evaluation system, and then allocate appropriate model resources according to different tasks. Only in this way can more stable and sustainable intelligent application results be achieved within a controllable budget.
