LLM API Price Cuts: Cost Estimation and Model Selection in Practice
Lower per-token prices do not automatically reduce total LLM costs. This article explains token billing components, a practical cost estimation function, engineering tactics such as prompt trimming and prefix caching, and a model selection checklist to help teams track and optimize LLM API spend.
1. New Problems Created by Lower Unit Prices
The unit prices of large language model services have fallen noticeably over time. The same business scale can now be handled with a lower budget, and many scenarios previously shelved because of high cost have entered the trial stage.
However, lower unit prices do not mean lower total costs. More calls, longer contexts, and redundant output can all offset the advantage of lower unit prices. After a price cut, the more important question is how to build a cost model that can be accounted for and continuously optimized.
2. Understanding the Basic Elements of Billing Structures
Most usage-based model services use tokens as the billing unit. A single call usually includes the following three types of billable items.
- Input tokens: all context such as the system prompt, conversation history, and retrieved reference material.
- Output tokens: the response generated by the model. Generation is computed token by token, so the output unit price is generally higher than the input unit price.
- Cache-related tokens: when the provider supports prefix caching, repeated context can be billed at a lower unit price. Whether it is supported, the hit rules, and the pricing should be confirmed in the provider’s official documentation.
Only by understanding these three billing items can you determine where costs are concentrated. Many teams look only at unit prices and ignore output length and context expansion, and their final bills exceed expectations.
3. Building a Cost Estimation Model
The basic approach to cost estimation is to split a request into billable items, multiply each by its corresponding unit price, and then aggregate by call volume. The function below provides a general implementation; users should fill in the price parameters according to the provider’s price list.
def estimate_cost(input_tokens, output_tokens, cached_tokens,price_in, price_out, price_cache):"""price_* are in CNY per million tokens; returns the estimated cost per request in CNY.cached_tokens is the portion of input that hits cache and should be less than or equal to input_tokens."""uncached = max(input_tokens - cached_tokens, 0)total = (uncached * price_in+ cached_tokens * price_cache+ output_tokens * price_out)return total / 1_000_000
Assume a customer service Q&A scenario uses 2,000 input tokens per request, with 1,500 tokens hitting cache, and 500 output tokens. Assume the following prices: CNY 2 per million input tokens, CNY 8 per million output tokens, and CNY 0.2 per million cached tokens. The cost per request is calculated as follows.
- Uncached input: 500 × 2 = 1000
- Cached input: 1500 × 0.2 = 300
- Output: 500 × 8 = 4000
- Total: 5300 / 1,000,000 ≈ CNY 0.0053
At 100,000 requests per month, this is about CNY 530. These numbers are only for demonstrating the calculation method; actual costs depend on the provider’s pricing and billing rules.
4. Engineering Methods to Reduce Costs
1. Streamline prompts
System prompts are billed repeatedly on every call. Split long templates, keep only necessary instructions, and replace large blocks of natural-language description with structured fields. For example, using key-value pairs to specify output requirements is shorter than multi-paragraph descriptions and easier for programs to parse.
2. Reuse context prefixes
Fixed instructions and knowledge snippets should be placed at the very beginning of the request to form a stable prefix; variable content should go at the end. The more stable the prefix, the more of it can hit the cache. Before launch, teams can validate hit rates with real request samples rather than estimating from experience.
3. Control output length
Limit word count, specify a format, or require structured fields to reduce output tokens. When setting a maximum output length, watch for truncation risk; the calling side should validate the returned content for completeness, for example by checking whether JSON is closed and required fields are present.
4. Route by task tier
Simple tasks such as classification, extraction, and format conversion can usually be handled by a smaller model; complex reasoning and long-form writing can be escalated to a more capable model. Routing rules can be based on task type or confidence, automatically falling back when small-model results are unreliable.
def route(task_type, confidence=None):simple_tasks = {"classify", "extract", "format"}if task_type in simple_tasks:return "small_model"if confidence is not None and confidence < 0.7:return "large_model"return "large_model"
5. Batch and async processing
For tasks without strict real-time requirements, such as offline summarization and data labeling, combine them into batches to reduce connection setup and scheduling overhead. Retry mechanisms need limits and backoff strategies; otherwise failed requests will repeatedly incur charges.
5. Model Selection Checklist
Before selection, confirm the following items one by one.
- Have task quality metrics been quantified, such as accuracy, human adoption rate, or benchmark score?
- Have average input and output lengths per request been measured rather than estimated from impression?
- Are peak concurrency and latency requirements clear?
- Is prefix caching supported, and are the hit rules and billing method clear?
- Do data retention, privacy, and compliance requirements meet internal enterprise standards?
- Beyond usage-based fees, are there other additional charges, such as minimum spend, resource reservation, or dedicated channel fees?
- Do the service’s rate-limiting policy, availability metrics, and failover plan meet business requirements?
6. Common Misconceptions
- Comparing only unit prices. A plan with a low unit price but verbose output may have a higher total cost.
- Ignoring failed requests. Timeouts, truncation, and format-error requests also incur costs and should be included in cost statistics.
- Using one-off tests instead of long-term monitoring. Traffic characteristics in test environments often differ from production, so cost metrics need to be recorded continuously under real traffic.
- Compressing costs before considering quality. Establish a quality evaluation baseline before optimizing costs; otherwise it is hard to tell whether cost reduction causes quality loss.
7. Implementation Recommendations
The first step is instrumentation. For each task type, record input tokens, output tokens, cache hits, call latency, and cost to form traceable data.
The second step is to prioritize optimizations by benefit. Usually handle output length and prompt redundancy first; these changes are low-cost and quick to show results.
The third step is to validate every change with an evaluation set. Cost optimization and quality assurance need to advance together; any change should go live only when quality metrics do not decline.
Cost management is long-term work. Unit prices will adjust with market and technology changes; teams should regularly review bills and call structures and include cost metrics in daily operations dashboards.
