LLM API Pricing: Inference Costs and Model Selection Logic
This article explains the cost structure behind LLM API pricing: how input and output tokens, KV cache and GPU memory, batching utilization, and idle capacity affect inference costs. It then discusses pricing and quota design, including breakeven estimation and the gap between quota ceilings and actual usage, and defines speed metrics such as TTFT and generation throughput.
Introduction
Prices for large language model services have changed noticeably over the past year or two. For models in the same capability range, different providers may offer unit prices, limited-time quotas, and discount strategies that differ by several times. Developers may easily view these phenomena as marketing tactics in daily use, but they are backed by clear cost structures and engineering logic. Understanding this logic helps assess whether a price is sustainable and supports more reliable model selection in real business scenarios.
This article discusses four layers: the composition of inference costs, methods for designing pricing and quotas, the meaning and measurement of speed metrics, and developer-oriented multi-model fault-tolerance practices.
1. Basic Composition of Inference Costs
The cost of LLM inference mainly comes from compute resources. For a single request, cost is related to the following factors.
1.1 Input and Output Tokens
Models process text by token. Input tokens require forward computation and cache writes, while output tokens are generated one by one; each generated token requires reading model weights and historical cache. Therefore, output is usually more time-consuming and has a higher unit cost. Many providers set different unit prices for input and output based on this difference.
1.2 GPU Memory and KV Cache
During generation, the model stores the key-value cache for the attention mechanism (KV Cache). Longer context uses more GPU memory for the cache. The number of concurrent requests a single accelerator card can serve is limited by memory capacity. Context length, concurrency, and memory usage jointly determine effective throughput per card.
1.3 Batching and Utilization
Accelerator cards often have low utilization at small batch sizes. Inference services usually merge multiple requests into batches, i.e., continuous batching. Fuller batches lower the compute cost per token. A provider’s actual cost largely depends on the average utilization of its cluster.
1.4 Idle Cost
If a provider reserves a large amount of resources to ensure response speed, the idle cost during low periods is spread across requests at other times. This means the real cost of the same model may differ by time period.
2. Design Logic of Pricing and Quotas
2.1 Unit Price and Breakeven
Pricing for subscription or quota products essentially answers one question: how much compute an average user consumes in a period, and what the cost of that compute is. A simplified model can estimate it:
Monthly cost = unit token cost × average monthly token consumption
If the price is below this cost, the provider needs scale, subsidies, or other revenue to balance.
Example code (parameters are hypothetical and only illustrate the calculation method):
def monthly_cost(tokens_per_day, cost_per_million_tokens, days=30):"""Estimate a single user's monthly inference cost (in USD)."""total_tokens = tokens_per_day * daysreturn total_tokens / 1_000_000 * cost_per_million_tokensdef breakeven_tokens(quota_usd, cost_per_million_tokens):"""Given a quota and unit price, calculate the number of million-token units covered."""return quota_usd / cost_per_million_tokensif __name__ == "__main__":# The parameters below are hypothetical and are not real prices for any servicecost = monthly_cost(tokens_per_day=2_000_000, cost_per_million_tokens=3.0)print(f"Hypothetical monthly cost: {cost:.2f} USD")print(f"Millions of tokens covered by a hypothetical $200 quota: {breakeven_tokens(200, 3.0):.1f}")
According to this calculation method, the same quota covers very different token counts under different unit prices. Therefore, the quota amount alone cannot directly reflect the actual value of a service; it must be judged together with the unit price.
2.2 Quota Numbers and Actual Usage
A high quota ceiling does not mean the user will reach that ceiling. Actual usage is constrained by the following factors:
- The unit price determines how many tokens the user can consume per day;
- Whether the workflow relies on long context or multi-turn calls;
- Whether the user already has other substitutable services;
- Whether response speed affects usage frequency.
Therefore, observing real usage changes before and after a quota adjustment is more informative than looking only at the quota number.
2.3 Limited-Time Subsidies and Scale Strategy
Providers sometimes offer high quotas or lower discounts for a period. The goals usually include obtaining user feedback, increasing service exposure, and validating cost assumptions. Whether such strategies are sustainable depends on user retention after the subsidy period and whether unit cost can drop to an acceptable range. When evaluating, developers should treat limited-time policies as unstable factors rather than long-term baselines.
3. Speed Metrics: TTFT and Throughput
3.1 Core Metric Definitions
When measuring inference speed, the following metrics are commonly used:
- Time To First Token (TTFT): the time from sending a request to receiving the first output token, mainly affected by input processing, queuing, and network;
- Generation throughput (tokens per second): the number of output tokens per second during the generation stage, mainly affected by model size.
