LLM API Pricing and Gross Margin: A Practical Guide to Cost Estimation
This article explains how large language model API pricing works and how to estimate real costs and gross margins. It breaks down token-based billing with separate input and output rates, shows how sparse architectures like MoE affect inference cost, and distinguishes list prices, limited-time discounts, and negotiated enterprise discounts. It also outlines a minimal cost model and practical advice for model selection and budgeting.
1. Why a Small Price Change Sparked a Big Debate
A cloud provider recently launched a lightweight LLM API. The community noticed that its price was not competitive compared with a limited-time discount offered by similar products, and the provider then made a small price reduction, while a competitor kept a limited-time 50% off promotion. The discussion around whether to follow with a price cut quickly moved beyond price itself to more fundamental questions: what actually determines the cost of an LLM API, and how does the list price relate to the real transaction price.
For developers, the value of this kind of discussion is not to watch from the sidelines, but to build a cost judgment framework that is calculable and verifiable.
2. Understand the Billing Structure First: Why Input and Output Are Priced Separately
Mainstream LLM APIs generally bill by token and price input (prompt) and output (completion) separately, with the output unit price usually significantly higher than the input price. The reason is not complicated:
- The input stage can be processed in parallel, with high compute utilization;
- The output stage is autoregressive decoding, generated token by token, with large memory access and scheduling overhead that is hard to parallelize fully;
- Output also involves longer context caching and GPU memory usage.
So when you see numbers like “0.8/2.7”, you should read them as “input price/output price per million tokens”, not as a single generic unit price. When evaluating cost, you must combine it with the real input-to-output ratio of your workload.
A simplified cost estimation example:
def estimate_cost(input_tokens, output_tokens,price_in_per_mtok, price_out_per_mtok):return (input_tokens / 1e6) * price_in_per_mtok \+ (output_tokens / 1e6) * price_out_per_mtok# Assume an input-to-output ratio of 3:1, with 3M input tokenscost = estimate_cost(3_000_000, 1_000_000, 0.8, 2.7)
If the workload is long-document summarization (input far exceeds output), the input unit price carries more weight; if it is code generation or dialogue continuation (output-heavy), the output unit price is the main issue. Talking about “which is cheaper” without considering the input-output structure often leads to distorted conclusions.
3. How Sparse Architectures Affect Inference Cost
Over the past two years, sparse architectures such as Mixture of Experts (MoE) have been widely adopted: the total parameter count is very large, but each token only activates a small subset of expert networks. The direct effect is that the actual computation per token depends on the activated parameter count, not the total parameter count.
This means:
- GPU memory and deployment cost are mainly determined by the total parameter count (all experts must be resident);
- Compute and throughput cost are closer to the activated parameter count;
- Under the same service quality, sparse models have more room for cost optimization.
It is worth emphasizing that this is only a general rule at the architecture level. Specific implementations, batching strategies, and quantization schemes can significantly change actual overhead, and it cannot be simply equated with “smaller parameter count always means cheaper”.
4. The Layered Logic of List Price, Limited-Time Discount, and Business Discount
The most valuable point in the original discussion is the distinction between three types of prices:
- List price (public price): aimed at long-tail self-service users, transparent but relatively high;
- Limited-time discount: short-term promotion used for user acquisition and mindshare, with uncertainty;
- Business discount: framework agreement price for large customers, usually not public, and the magnitude may far exceed public imagination.
For enterprise procurement, making decisions based only on the public list price is easy to misjudge. A reasonable approach is to use the list price as the upper limit for budgeting, the limited-time discount for short-term optimization, and the business agreement price as the long-term cost baseline, managing the three in layers.
5. Gross Margin Estimation: Why “Looks Cheap” Does Not Mean Losing Money
Combined with sparse architecture and real utilization, a seemingly aggressive price can still retain considerable gross margin. The reasons include low actual activated compute, higher throughput from batching, reduced repeated computation from cache hits, and scale dilution obtained by trading large-customer discounts for volume.
It is recommended that teams build a minimal cost model that includes at least: compute cost per token, average utilization, input-output ratio, cache hit rate, and discount structure. Only by quantifying these variables can you judge whether a price cut is “giving up margin for volume” or “unsustainable”.
6. Actionable Advice for Selection and Budgeting
- Run small-scale stress tests with real business samples, and record the input and output token distribution rather than relying on advertised numbers;
- For cost-sensitive scenarios, prioritize evaluating sparse architectures and batching throughput;
- Incorporate price layering into procurement strategy to avoid being led by a single promotion;
- Set up monitoring alerts and log analysis to continuously track cost per request.
7. Conclusion
Short-term price fluctuations are only surface phenomena. What really determines long-term cost is the combination of billing structure, model architecture, and procurement strategy. Understanding the pricing difference between input and output, the cost characteristics of sparse architectures, and the layered relationship between list price and business discounts is what enables sound decisions on selection and budgeting. If you need a unified cloud resource foundation to support stress testing, monitoring, and cost management, you can build on general capabilities such as the container platform, log service, and monitoring alerts provided by Baidu AI Cloud to form a continuously optimizable cost loop.
