How to Calculate Costs and Select LLMs After API Price Increases
With recent price hikes in leading LLM APIs, enterprises must look beyond single-call prices to understand true project costs. This article explores pricing models, token consumption in multi-turn agent tasks, and practical cost evaluation frameworks, offering engineering practices for cost reduction and a checklist for model selection.
Introduction
A leading LLM provider recently released a new generation model with significantly higher API prices compared to its predecessor. The reported prices are approximately 20 CNY for input, 100 CNY for output, and 1 CNY for cache hits per million tokens. Before actual selection, refer to the official pricing page to confirm whether taxes are included and whether there are separate rates for cache writes and cache reads.
While the price increase might seem justified by industry-leading benchmark scores, the actual cost to an enterprise depends on three factors: the billing method, the actual token consumption of the task, and the effective output achieved per unit cost. Looking only at unit price can easily lead to underestimating total project costs.
1. Distinguish Between Two Billing Methods
Mainstream LLM billing generally falls into two categories that need to be calculated separately.
1.1 Pay-As-You-Go API Pricing
APIs are billed by token, with a single request split into input tokens, output tokens, and cache hit tokens. The output unit price is typically much higher than the input price because generating each token requires step-by-step inference, consuming more compute. Cache hit prices are lower because the provider reuses previously computed prefixes (KV Cache), saving redundant computation. Therefore, if the application layer can consistently reuse system prompts and fixed contexts, input costs can be significantly reduced.
1.2 Subscription Plan Quota Ratios
Subscription plans charge monthly or annually for a specific usage quota. Note that there are two easily confused products in the market. One is a subscription seat charged per user, mainly for personal or team conversational and coding assistants. The other is a prepaid API usage package deducted by tokens. The quota scopes, validity periods, and rate limiting rules differ between the two, so they must be evaluated separately.
2. Token Consumption in Multi-Turn Agent Tasks
In Q&A scenarios, the token count for a single call is relatively easy to estimate. However, in multi-agent and long-horizon tasks, a single business request often requires multiple rounds of planning, tool calling, reflection, and error correction, significantly amplifying costs.
2.1 Context Accumulation
If the complete history is resent to the model in each round, the input for a single round increases linearly with history. Assuming about d new tokens per round, the input for round n is approximately n×d. After n rounds, the cumulative input is approximately d×n(n+1)/2, meaning total consumption grows quadratically with the number of rounds. If the provider offers stable prefix caching, the repeated history can be billed at the cache rate, but caching rules vary by provider. It is necessary to verify prefix matching conditions and validity periods.
2.2 Hidden Overhead of Tool Calls
Each Function Call incurs two costs. First, the model must output structured JSON parameters, counted as output tokens. Second, the tool’s returned result is appended to the context and billed as input tokens in the next round. For example, if a JSON parameter is about 200 tokens and the tool returns about 1,500 tokens, those 1,500 tokens will be repeatedly counted in the input of every subsequent round until the context is compressed or truncated.
2.3 Impact of Reasoning Length
New-generation models typically have stronger instruction-following capabilities and generate longer chains of thought. This improves the success rate of complex tasks but also increases output tokens. Whether this is cost-effective depends on the final pass rate of the task, not just the output length of a single call.
Regarding the actual consumption of different models on similar agent tasks, currently, there are no reproducible test data provided. Enterprises should benchmark on their own business data and avoid directly citing others’ conclusions.
3. Task-Level Cost Evaluation Framework
Before going live, teams should conduct a dry run on core business scenarios, tracking the average number of rounds triggered by a single user request, as well as the input, output, and cache tokens per round. Below is a simple cost calculation function:
def calculate_task_cost(avg_input_tokens, avg_output_tokens, cached_tokens, turns, price_tier):"""avg_input_tokens, avg_output_tokens, cached_tokens are single-round averages.cached_tokens must be a subset of avg_input_tokens, meaning the cache hit portion is already included in the total input.turns is the number of call rounds triggered by a single user request.price_tier unit is currency/million tokens."""if cached_tokens > avg_input_tokens:raise ValueError("cached_tokens cannot exceed avg_input_tokens")uncached = avg_input_tokens - cached_tokensinput_cost = uncached * price_tier["input_price"] / 1_000_000cache_cost = cached_tokens * price_tier["cache_price"] / 1_000_000output_cost = avg_output_tokens * price_tier["output_price"] / 1_000_000return (input_cost + cache_cost + output_cost) * turns
Ensure consistent metrics when using this function. If avg_input_tokens is already a cumulative multi-round value, do not multiply it by turns again, or the result will be double-counted.
For example, assume an average of 20,000 input tokens per round, of which 16,000 hit the cache, 1,000 output tokens per round, 5 rounds total, and use the aforementioned sample pricing. The single-round cost is: uncached input 4000×20÷1,000,000 ≈ 0.08 CNY; cache hit 16000×1÷1,000,000 ≈ 0.016 CNY; output 1000×100÷1,000,000 ≈ 0.1 CNY. The total per round is approximately 0.196 CNY, and 5 rounds about 0.98 CNY. This figure is only for demonstrating the calculation method; real business requires replacing it with statistical values from logs.
4. How to Calculate Subscription Plan ROI
When evaluating a subscription plan, don’t just look at the monthly fee. The basic formula is:
Nominal ROI = Available API Quota ÷ Plan Price
For example, if a 99 CNY plan provides 2,000 CNY worth of usage, the nominal ROI is about 20x. This is a hypothetical example and does not represent any real plan.
The nominal ROI needs adjustment, mainly in three aspects:
- Validity Period: If the quota resets at the end of the month, unused portions have no value.
- Rate Limiting: If concurrency or tokens per minute are limited, the actual available quota during peak business hours will be lower than the nominal value.
- Overage Unit Price: Exceeding the quota is billed at the standard rate, which in the long run may cost far more than the plan’s average unit price.
After adjustments, teams should divide the API equivalent amount converted from actual business volume by the actual amount paid to determine the effective ROI. A plan is worth long-term adoption only if the effective ROI consistently exceeds the team’s cost threshold. If the ROI is only single digits, proceed with caution.
5. Engineering Practices for Cost Reduction and Efficiency
The model’s price itself is uncontrollable, but application-layer design can greatly impact costs.
5.1 Scenario-Based Tiered Routing
Not all tasks require the most powerful model. You can set routing rules at the API gateway: low-difficulty tasks like intent recognition, simple information extraction, and format conversion are handled by lightweight models; high-value tasks like complex reasoning and code generation then call the high-priced new model. Routing rules should be based on offline evaluation results, not gut feelings.
5.2 Fine-Grained Prompt and Context Management
Use Retrieval-Augmented Generation (RAG) to replace putting entire long documents into context, splicing only relevant chunks. Introduce a summarization mechanism in multi-turn conversations to periodically compress history. Place system prompts and fixed templates at the front of the request to keep the prefix stable for cache hits. When tool return results are long, perform field trimming first, putting only the content the model needs into the next round.
5.3 Unified Monitoring via Cloud Platforms
Enterprises can leverage API gateways, logging services, and monitoring alerts provided by cloud vendors to track token usage and costs by business line. Set daily budget thresholds for each business; alert when approaching the threshold, and automatically downgrade to a lightweight model or pause non-critical tasks when exceeding it. This controls total costs at the system level, preventing abnormal calls from a single feature from bankrupting the overall budget.
6. Five Must-Check Items Before Selection
- Pricing Metrics: Confirm the unit, whether taxes are included, and prices for input, output, cache write, and cache read.
- Cache Rules: Confirm prefix matching conditions, cache validity periods, and whether hits are affected by rate limiting.
- Plan Terms: Confirm quota validity periods, rate limit ceilings, and overage unit prices, distinguishing between subscription seats and API usage packages.
- Actual Consumption: Measure average rounds, tool call tokens, and reasoning length using your own business logs; do not use example numbers.
- Quality-Standardized Cost: Compare pass rates of different models on the same task set. A model with a lower unit price might result in higher total costs if it requires multiple retries.
Conclusion
The price increase of new models reflects rising compute and R&D investments. For enterprises, judging whether a model is cost-effective depends not on unit price or benchmark scores, but on the total cost and quality of completing specific business tasks. Teams should first verify pricing and plan terms, measure token consumption with real data, and finally control costs through tiered routing and context management.
