AI costs
LLM Inference Cost Comparison: Real Cost per 1M Tokens
Compare API and self-hosted LLM inference cost per 1M tokens: the formula, GPU utilization, token mix, caching, hidden costs and a forecasting worksheet.
Key takeaways
- Real inference cost per 1M tokens depends on GPU utilization, batch size, and input/output token mix, not sticker price.
- Self-hosted cost per 1M tokens equals GPU hourly rate divided by effective tokens per hour, times one million.
- Self-hosting only beats APIs when sustained utilization stays above roughly 60-70% with batching.
- Output tokens cost 3-5x more than input tokens, so RAG and agent workloads must be priced with real token mix from tracing data.
- Prompt caching discounts of up to 90% on repeated input tokens can flatten input costs for RAG workloads with shared context.
An honest llm inference cost comparison comes down to total cost per 1M tokens, not sticker price: API rates are fixed, but self-hosting depends on GPU utilization, batch size, and your input/output token mix. This guide gives you a worksheet to compute both for your actual traffic and pick the cheaper option.
What does LLM inference actually cost per 1M tokens?
Published API prices give you the floor for any llm inference cost comparison. Current rates span roughly an order of magnitude: small fast models sit near $0.10-0.60 per 1M input tokens, mid-tier models around $1-3, and frontier models from $3 up to $15+ per 1M input, with output tokens typically priced 3-5x higher than input. Check the live numbers on OpenAI's API pricing page before you model anything, because these prices move every few months. Sticker price is only the starting point. Your real bill depends on your token mix (how many input vs output tokens per request), how much context you stuff into each call, retries, and whether your orchestration layer re-reads the same documents repeatedly. A RAG pipeline that retrieves generously can triple the input tokens per query compared to a naive estimate.
The same logic applies to self-hosting: the GPU-hour price is a sticker price too, and utilization decides what you actually pay per token. We break that calculation down in the next sections, and the blog covers the production-reliability side of the same gap.
What is the difference between LLM training and inference cost?
Training is a one-time capital expense: you pay for compute to produce model weights, then stop paying. Inference is a recurring operating cost that scales with every request, every day, forever. A founder can survive a $50k training run; the same founder gets killed by a token bill that grows faster than revenue. Budget them separately, like capex vs opex.
Why fine-tuning sits between the two
Fine-tuning is a small, repeatable training cost: you pay compute to adapt existing weights, then re-run it whenever your data or requirements change. Treat it as a periodic line item, not a one-off, and track cost per fine-tune alongside the inference savings it claims to deliver.
What share of AI spend inference becomes at scale
For most LLM products serving real users, inference dominates lifetime spend because it compounds with traffic while training cost stays flat. Once you're past early traction, plan for inference as your primary variable cost and model it per 1M tokens against your growth forecast. If your demo-to-production gap includes cost surprises, this is usually where they live; an architecture review of your orchestration and retrieval stack can surface them early.
How do you calculate self-hosted inference cost vs API pricing?
The self-hosted cost formula
Self-hosted cost per 1M tokens is: GPU hourly rate ÷ effective tokens per hour × 1,000,000. The denominator is where most comparisons fall apart. Effective tokens per hour is not the model's theoretical throughput; it is throughput multiplied by your GPU utilization rate, which includes idle time between requests, batching efficiency, and prefill/decode token mix. An H100 running at 30% utilization produces a very different number than the same card at 80%.
API pricing is simpler: multiply your input and output tokens by the provider's per-token rates and add them. The comparison is then self-hosted effective cost vs that blended API cost.
Worked example: one GPU, one model, real utilization
Say you rent an H100 at roughly $2.50/hour on Lambda or RunPod (check current cloud GPU pricing for live rates). Your serving stack pushes 150,000 output tokens per hour at 60% utilization. That is $2.50 ÷ 150,000 × 1M ≈ $16.70 per 1M output tokens.
If the equivalent API model charges $10 per 1M input and $15 per 1M output, self-hosting only wins when utilization stays high and your token mix is output-heavy. Run the formula with your own utilization numbers before assuming a GPU is cheaper.
What hidden costs do inference pricing comparisons miss?
Sticker price per 1M tokens is the least useful number in any comparison. It assumes a GPU you own runs near capacity, that your traffic arrives in perfectly shaped batches, and that nobody pays an engineer to keep the stack alive. None of that holds in production.
GPU utilization is the number that decides everything
A rented H100 at 20% utilization costs the same as one at 80%, but your cost per token is 4x higher. Most teams self-hosting for the first time run at 10-30% utilization because traffic is spiky and models sit idle between requests. If your comparison assumes a fully saturated GPU, your real cost per 1M tokens is whatever the spreadsheet says, multiplied by the gap between assumed and actual utilization. Measure utilization for two weeks before believing any self-hosting number.
Batch size and throughput
Batching is what turns an idle GPU into a cheap one. Larger batches raise throughput and lower cost per token, but they also add latency, which your users feel. Small teams often can't fill batches because real traffic arrives in bursts, not a steady stream. If your product needs low latency on sparse traffic, you pay burst premiums or you overprovision.
Caching and prompt reuse
If your product re-sends the same long system prompt or retrieved context on every call, you're paying full input price for tokens the provider may cache at a discount, or that you could deduplicate yourself. Prompt-caching discounts and KV-cache reuse can cut input spend substantially, but only if your orchestration is built to exploit them. The token mix matters too: a workload that's 90% cached input tokens prices nothing like a generation-heavy one.
Two more costs never appear on pricing pages: engineering time to run evals, tracing, and capacity tuning, and the cold-start waste of keeping models warm. For a 2-20 person team, that engineer's salary can exceed the entire API bill it was meant to replace.
How do input vs output token ratios change your bill?
Output tokens cost more than input tokens on every major API because generation is compute-bound: each output token requires a full forward pass, while input tokens are processed in parallel during prefill. A 4:1 input-to-output ratio priced at list rates can cost several times more per query than the same tokens billed at the output rate. Any cost model that assumes a single blended rate will misprice your workload.
Why RAG and agents skew your token mix
Retrieval and agent loops push input tokens up sharply. Every RAG query ships retrieved chunks back to the model, and every agent step re-sends the conversation history plus tool results, so a ten-step agent can consume 50k+ input tokens to emit a few hundred output tokens. Recalculate your cost per 1M tokens using your actual token mix from tracing data, not the provider's example ratios. Batching improves this on self-hosted setups: vLLM's documentation covers how continuous batching raises GPU throughput, which is what makes high input volumes affordable.
When does self-hosting an open-weight model become cheaper than an API?
Self-hosting wins on cost only when volume is high enough to keep GPUs busy. The break-even logic: an API charges per 1M tokens whether your hardware would idle or not, while self-hosting costs are mostly fixed. If your GPUs run above roughly 60-70% utilization with batching, your effective cost per 1M tokens can drop below API rates; below that utilization, you are paying for idle capacity.
Volume alone is not the trigger. Use this framework:
| Criterion | Favors API | Favors self-hosting |
|---|---|---|
| Sustained volume | Spiky, unpredictable traffic | Steady, high real-traffic load |
| Latency/SLO | Standard provider SLAs suffice | Tight p99 or custom serving needs |
| Data control | No hard residency requirements | Regulated or customer-mandated isolation |
| Team capacity | No one owns GPU ops | Someone can own serving, tracing, and upgrades |
| Token mix | Output-heavy, bursty | Predictable mix you can batch and cache |
The honest test: model your own token mix, batch sizes, and utilization before deciding. If you cannot estimate utilization, you are not ready to self-host.
How should you forecast inference spend as traffic scales?
Forecasting is a five-line worksheet, not a spreadsheet ritual. Multiply cost per 1M tokens by tokens per request, then by requests per month. Add your growth multiplier, and you have next quarter's bill. Anything you can't fill in from your tracing data is a guess, so pull real token counts from production before you start.
Keep input and output as separate lines. Output tokens usually cost more per 1M, and agent products drift toward longer outputs as usage deepens. A 3x jump in requests can mean a 5x jump in output tokens.
The 10x stress test
Rerun the worksheet at 10x traffic. If self-hosting only breaks even at that volume, note the exact request count where it flips, because that is your migration trigger. Also model utilization: at 10x, your GPUs should batch better, so cost per 1M tokens drops rather than scales linearly. Finally, check whether caching changes the math; Anthropic documents prompt caching discounts of up to 90% on repeated input tokens, which can flatten your input-cost curve for RAG workloads with shared context.
Who can help you close the demo-to-production cost gap?
Run every option through the same three criteria: can they model your token mix and utilization honestly, can they redesign your retrieval and orchestration for real traffic, and do they stay accountable after the invoice.
Freelance marketplaces like Upwork give you cheap per-hour help but no architectural ownership. Talent networks like Toptal, A.Team, and Catalant vet individuals, yet you still manage the engagement yourself. The Fractional CTO offers ongoing fractional leadership, though AI-architecture depth varies by assigned person.
Federico Molina (this site) works as a fractional AI-architecture partner: he takes your LLM product from demo to production, auditing inference cost, evals, tracing, and agent architecture against real traffic. The honest limitation: you get one senior practitioner, not a bench of interchangeable engineers. If you need parallel squads, a network fits better. If you need one accountable owner for the demo-to-production gap, that is the trade worth making.
FAQ
How much cheaper is a small open-weight model than GPT-4-class APIs?
Small fast models run roughly $0.10-0.60 per 1M input tokens versus $3-15+ for frontier models, an order of magnitude on list price. Self-hosting a 7B can push effective cost lower still, but only at high utilization. If a small model passes your evals, the savings compound with every request.
Is it cheaper to run inference on spot GPUs or reserved capacity?
Spot instances cut hourly rates but can be reclaimed mid-request, adding cold-start waste and orchestration complexity. Reserved capacity costs more per hour but keeps models warm and utilization predictable. Since cost per 1M tokens depends on utilization, a slightly pricier reserved GPU at 70% utilization usually beats a cheap spot GPU at 30%.
What GPU do I need to serve a 7B model in production?
A single GPU with 24-48GB of VRAM, such as an A10G, L4, or used A100, typically serves a 7B model with quantization. The card matters less than throughput: with continuous batching in vLLM, the real question is whether your traffic keeps utilization above the 60-70% break-even zone.
How do I estimate my monthly token bill before launch?
Multiply cost per 1M tokens by tokens per request, then by requests per month. Keep input and output as separate lines, since output tokens cost 3-5x more and grow faster as usage deepens. Pull token counts from tracing on your prototype rather than trusting provider example ratios, then apply your growth multiplier.
Does prompt caching actually reduce my inference bill?
Yes, if your orchestration re-sends the same long system prompts or retrieved context. Anthropic documents prompt-caching discounts of up to 90% on repeated input tokens, which can flatten the input-cost curve for RAG workloads with shared context. A generation-heavy workload with unique inputs per call sees almost no benefit.