How to Calculate the Compute Cost Behind LLM API Pricing

    A practical guide to understanding whether LLM API pricing is really "below cost." It explains the billing model (prefill vs. decode, input vs. output vs. cached tokens), shows how to normalize quotes across providers before comparing them, and walks through a self-hosted TCO model that reveals the real cost driver: GPU utilization. It also clarifies who actually bears training and R&D costs, where subsidies really occur (monthly subscriptions, not metered APIs), and eight concrete practices for cutting token spend on the application side.

    1. Where the Debate Starts: Is Token Pricing Unsustainable?

    A widely repeated claim about LLM API prices goes like this: current per-token prices are clearly below the real cost, vendors are effectively subsidizing users with outside capital, first building dependency with low prices they can withdraw at any moment.

    The claim sounds convincing, but it conflates three fundamentally different things:

    • the marginal inference cost of a single token;
    • the sunk cost of building a model (training, data, people);
    • the pricing strategy aimed at different customer segments (pay-as-you-go, monthly subscription, enterprise committed-use).

    Once you separate these three, the conclusion that “API price is below cost” often falls apart — and the observation that “subsidies do exist” isn’t entirely wrong either, it just usually happens somewhere other than the API. Let’s first make the billing model clear, then lay out a cost model you can run yourself.

    2. First, Understand the Billing Model: Why Input and Output Prices Differ by Several Times

    Billing by token looks crude, but it maps fairly tightly onto actual hardware consumption. The reason is that a single inference request has two computationally distinct phases.

    Prefill phase: all input tokens are processed in parallel in one pass. This is compute-intensive, with high arithmetic intensity in the matrix multiplications, so hardware utilization can be pushed close to saturation. The per-token cost here is low.

    Decode phase: tokens are generated autoregressively one at a time, and every step must read the full model weights and the KV cache. This is memory-bandwidth-bound, and compute is largely idle. The per-output-token cost is therefore much higher than the input side.

    This explains two common phenomena:

    1. Input prices are far lower than output prices. A typical setup prices output at several to more than ten times the input rate. This isn’t a pricing preference — it’s a direct reflection of the underlying cost structure.
    2. Long-context cost is not linear. In attention, compute scales with the square of sequence length, and KV-cache memory grows linearly with length, so “just stuff the whole document into the context” is routinely underestimated.

    On top of that, the spread of prefix caching (prompt caching) widens the gap further: a repeated common prefix doesn’t need to be recomputed, and the cached portion can be billed at a tiny fraction of the normal input price. Any cost estimate that doesn’t separate input, output, and cache hits will be distorted.

    3. Method 1: Compare Prices Horizontally — But Normalize First

    For the same model, quotes from different providers often differ by several times, so comparing raw unit prices is meaningless. The effective approach is to normalize every quote to the same basis first:

    Normalization dimension What to standardize
    Context length Same input-length band (e.g., 4K / 32K / 128K)
    Caching Prefix-caching support, cache-hit price, cache lifetime
    Batch discount Availability of an async batch channel and its discount rate
    Throughput & concurrency Rate-limit quotas, peak concurrency, queueing behavior
    Availability SLA commitments, regional coverage, recovery time
    Add-on capabilities Structured output, function calling, fine-tuning, private-deployment options

    A practical trick is to define a representative request profile and price against it. For example, fix it as: input of 8K tokens (of which 3K is a reusable prefix), output of 1K tokens, a 35% cache-hit rate, and 500K requests per day. Run each vendor’s pricing through this profile, and the resulting “cost per thousand requests” is the number you can actually make decisions on.

    4. Method 2: Build a Self-Hosted TCO Model to Verify the Real Price-to-Cost Relationship

    Price comparison only tells you the market rate; it can’t tell you where the cost floor is. To judge how much margin sits inside the price, you have to build your own TCO (Total Cost of Ownership) model.

    4.1 Cost-item checklist

    • Hardware purchase and depreciation: GPU servers, high-speed interconnect, storage, networking gear;
    • Facility and colocation: rack rental, power capacity per cabinet, cooling;
    • Electricity: determined by total system power draw and PUE (Power Usage Effectiveness);
    • Bandwidth and traffic: egress bandwidth, cross-region interconnect;
    • Operations labor: inference-engine tuning, monitoring and alerting, incident handling, version upgrades;
    • Capacity headroom: redundant capacity reserved for traffic spikes — it generates no revenue but must still be counted as a cost.

    4.2 An illustrative estimate

    All parameters below are example assumptions for illustration only. They do not represent any real product’s pricing and serve only to demonstrate the modeling method:

    • 8-GPU node purchase cost: USD 500,000, depreciated over 36 months;
    • Average power per card of 1.2 kW, roughly 10 kW per node; with a PUE of 1.3, that works out to 13 kW;
    • Electricity price of USD 0.1/kWh, running 720 hours per month year-round;
    • Fixed monthly costs for space, bandwidth, operations, etc.: USD 2,000/month;
    • At full load, the cluster can sustainably produce 2 billion output tokens per month.

    From this, the monthly total cost:

    1. depreciation = 500000 / 36 ≈ 13889 USD
    2. electricity = 13 kW × 720 h × 0.1 ≈ 936 USD
    3. fixed costs ≈ 2000 USD
    4. total monthly cost ≈ 16825 USD
    5. unit output cost = 16825 / 2e9 × 1e6 ≈ 8.4 USD / million output tokens

    If the market quote lands in the low-teens per million output tokens, then a clear gross margin exists at full load — the opposite of the “selling at a loss just to make noise” intuition.

    4.3 What really matters is utilization

    That conclusion rests on one very strong assumption: running at full capacity. In reality, GPU cluster utilization often sits between 30% and 70%, because you need headroom for traffic spikes, you have to absorb the long tail of request-length distributions, and you take a capacity hit during rolling upgrades. Utilization amplifies unit cost almost linearly:

    Actual utilization Unit output cost (USD / million tokens)
    100% 8.4
    70% 12.0
    50% 16.8
    30% 28.0

    This table is the heart of the matter: an inference business’s competitiveness comes mainly from scheduling and utilization, not from simply piling on hardware. For the same set of cards, lifting utilization from 40% to 70% nearly halves the unit cost. That’s also why leading vendors invest heavily in continuous batching, paged KV-cache management, and request preemption and priority scheduling — these directly shape the cost curve.

    4.4 A reusable cost function

    Codify the logic above and you can recompute with your own hardware parameters and market quotes:

    1. def unit_output_cost(
    2. capex_usd, # Total server purchase cost
    3. months, # Depreciation period (months)
    4. kw_total, # Total power draw (including network and storage)
    5. pue, # Power Usage Effectiveness
    6. price_per_kwh, # Electricity price per kWh
    7. fixed_monthly, # Fixed monthly costs (hosting, bandwidth, operations)
    8. tokens_per_month, # Monthly token output at full load
    9. utilization, # Actual utilization (0-1)
    10. ):
    11. depreciation = capex_usd / months
    12. power = kw_total * pue * 720 * price_per_kwh
    13. total = depreciation + power + fixed_monthly
    14. effective_tokens = tokens_per_month * utilization
    15. return total / effective_tokens * 1_000_000 # USD / million tokens

    5. The Overlooked Cost: Who Bears Training and R&D

    To be honest about it: the TCO above covers only the inference side and leaves out training and R&D entirely. A single training run for a frontier model, data cleaning and labeling, evaluation infrastructure, safety alignment, and labor can add up to hundreds of millions of dollars. This is a classic sunk cost, and amortizing it requires an enormous volume of token calls.

    A more accurate statement is: training and R&D investment is borne by the vendor and its capital backers — it is an investment in the future, not a hidden liability spread across each API call. If you force it onto the current per-token price, almost any price will look like a loss — but that accounting reflects neither marginal decision-making nor explains why vendors keep expanding capacity.

    6. So Where Does the Subsidy Actually Happen?

    Compare two billing models and the difference is plain:

    • Pay-as-you-go APIs: revenue grows linearly with call volume and is tightly coupled to compute consumption. Cutting prices immediately compresses gross margin, so vendors have almost no incentive for long-term subsidies; competition shows up mainly as price cuts and efficiency gains.
    • Monthly subscriptions aimed at individuals: a fixed monthly fee buys a fairly high usage allowance, and users’ actual consumption varies enormously. Heavy users may burn far more compute than average, while light users leave much of their allowance idle. This structure is essentially risk-sharing and cross-subsidization — heavy users are subsidized by light ones, while the vendor takes on the financial risk of mispredicting usage.

    So “subsidies exist” and “token pricing is unsustainable” are two different propositions. The former objectively exists in the subscription model; the latter requires evidence of sustained losses on the inference side, and the TCO calculation doesn’t support that conclusion.

    7. How the Application Side Can Actually Cut Token Spend

    For individuals and teams, rather than arguing over whether the pricing is fair, it’s better to manage the cost items you can control. These practices deliver the most direct payoff:

    1. Build token-level observability. Log the input, output, and cache-hit token counts, unit price, and cumulative cost for every request, then aggregate by tenant, project, and feature module. Without this data, any optimization is guesswork.
    2. Tier models and route intelligently. Use rules, small models, or low-parameter models for deterministic tasks like intent classification, format conversion, and information extraction, and reserve high-capability models for complex reasoning and long-chain tasks.
    3. Groom the context. Replace full-context injection with retrieval, summarize and compress conversation history, and deduplicate and trim irrelevant content. Context length is the most cost-sensitive and most easily overlooked variable.
    4. Constrain output length. Set output limits explicitly and ask for concise, structured responses in the prompt, avoiding long-winded restatements. Output tokens usually cost far more per token than input.
    5. Maximize cache reuse. Put stable system prompts, tool descriptions, and knowledge-base preambles in a fixed position in the context to raise the prefix-cache hit rate; add a result-cache layer for highly repetitive Q&A.
    6. Route offline tasks through the batch channel. Tasks without latency requirements — summarization, labeling, bulk extraction — should use the async batch API, which typically offers a significant discount.
    7. Budget and quota governance. Set quotas and alert thresholds per project, and add circuit breakers for abnormal growth (such as retry storms or looping calls) so a single failure doesn’t turn into a billing incident.
    8. Plan capacity using the real length distribution. Load-test and reserve against P50/P95/P99 request profiles rather than averages; otherwise you’ll hit queueing and timeouts on the long-tail requests.

    8. Conclusion

    Separating the inference-side cost structure, the sensitivity to utilization, and the cross-subsidization of the subscription model yields a few fairly solid conclusions:

    • Pay-as-you-go API pricing broadly matches the underlying compute cost, leaving a sizeable but scheduling-dependent gross margin at full load;
    • The real cost lever is cluster utilization, not the unit price itself;
    • Training and R&D on the order of hundreds of millions of dollars is borne by vendors and their capital backers, and shouldn’t be the basis for judging whether the API loses money;
    • Clear subsidies and risk mismatches mainly appear in the monthly subscription model aimed at individuals;
    • For users, the biggest room for cost optimization lies in their own architecture: context length, model selection, cache hits, and batching — these four usually beat waiting for price drops.