How to Calculate LLM Inference Cost Per Million Tokens
LLM inference cost calculation is an engineering framework that translates token generation workloads, hardware amortization, and cluster utilization into an effective financial cost per million tokens served. Estimating inference expenses solely by looking at public API price cards or nominal hourly GPU rental rates produces severe budget variances. Enterprise production deployments must account for prompt-to-generation ratios, memory bandwidth constraints, KV-cache footprint, and non-linear utilization curves.
Production inference economics diverge sharply from offline training. While training maximizes continuous matrix multiplication across days, inference must satisfy strict latency percentiles while handling volatile traffic. Calculating true unit economics requires engineering teams to normalize compute costs, measure memory-bound token generation speeds, and factor in idle capacity reserves required for traffic spikes.
The Fundamental Formula for Cost Per Million Tokens
To determine the true cost of serving language models, teams must separate the compute-heavy prefill phase from the memory-bandwidth-heavy decoding phase. A single blended rate obscures the fact that output tokens consume significantly more memory cycles and GPU time than input tokens.
The standard baseline calculation models the amortized infrastructure hourly rate divided by the effective token throughput per hour. When expressed mathematically:

Cost Per 1M Tokens = (Hourly GPU System Cost / Productive Tokens Generated Per Hour) × 1,000,000
However, productive token generation depends directly on four real-world production variables:
- Active Concurrency: The number of parallel requests actively being decoded in GPU memory simultaneously.
- KV Cache Allocation: Dedicated high-bandwidth memory (HBM3/HBM3e) reserved per context session, which caps maximum batch size.
- Effective Throughput: Sustained output tokens per second across all active worker instances.
- Duty Cycle / Utilization Rate: The ratio of peak productive hours to off-peak idle reservation hours across a 24-hour billing cycle.
Cost Comparison Across Model Sizes and Serving Architectures
Inference costs scale non-linearly with model parameter count. A 70B parameter model requires tensor parallelism across multiple accelerators, increasing inter-GPU communication overhead compared to a single-chip 8B model.
| Model Architecture | GPU Configuration | Average Output Throughput | Effective Cost / 1M Tokens (Dedicated) | Hyperscaler Multi-Tenant Equivalent |
|---|---|---|---|---|
| 8B Parameters (FP16/BF16) | 1x NVIDIA L40S or A100 (80GB) | 140 tokens/sec | $0.08 – $0.14 | $0.30 – $0.50 |
| 70B Parameters (FP8 Quantized) | 2x NVIDIA H100 SXM (Tensor Parallel) | 95 tokens/sec | $0.65 – $0.95 | $1.80 – $2.50 |
| 70B Parameters (BF16 Unquantized) | 4x NVIDIA H100 SXM (Tensor Parallel) | 120 tokens/sec | $1.20 – $1.65 | $3.20 – $4.50 |
| MoE Architecture (e.g., 8x7B) | 2x NVIDIA H100 NVLink | 180 tokens/sec | $0.45 – $0.75 | $1.20 – $1.90 |
Hidden Factors That Inflate Production Inference Budgets
When engineering teams move models from prototyping environments into enterprise production, costs frequently exceed initial spreadsheets by 40% to 120%. This budget discrepancy stems from three systemic factors that generic ROI calculators omit.
First, strict latency Service Level Agreements (SLAs) cap batch sizes. While batching 64 requests together yields maximum tokens per dollar, it degrades P99 time-to-first-token (TTFT) and time-per-output-token (TPOT). In real-time customer-facing applications, teams must run small batches of 4 to 8, sacrificing GPU utilization to maintain acceptable response speeds.
Second, context window bloat consumes exponential KV cache memory. A retrieval-augmented generation (RAG) query injecting 16,000 tokens of context requires massive memory allocation before a single output token is produced. This memory lock prevents other concurrent queries from entering the pipeline, leaving tensor cores underutilized while memory channels remain saturated.
Third, idle capacity waste on multi-tenant public clouds creates financial bleed. Public cloud spot instances face abrupt preemption during enterprise peak hours, forcing organizations to maintain expensive on-demand reservations 24/7 even during low-traffic overnight windows.
Where OneSource Cloud Fits in Inference Economics
For organizations generating upwards of 20 million tokens per day, per-token cloud APIs and unmanaged hyperscaler instances become an inefficient capital allocation. Deploying on dedicated, non-shared infrastructure restores cost predictability and eliminates multi-tenant noise.
OneSource Cloud delivers Private AI Infrastructure specifically engineered for high-concurrency LLM inference. By provisioning dedicated GPU compute fabrics with dedicated NVLink inter-node communication, enterprises achieve deterministic latency without noisy-neighbor degradation.
To eliminate idle resource waste across multiple internal business units, teams deploy OnePlus Platform, OneSource Cloud's AI orchestration platform. OnePlus enables dynamic workload scheduling, automated inference auto-scaling, and fine-grained quota governance. When combined with Managed AI Infrastructure, enterprise operations teams gain 24/7 telemetry monitoring, driver optimization, and cluster capacity planning that keep unit economics tightly controlled.
FAQ
How does prompt length affect cost compared to output length?
Prompt tokens are processed in parallel during the prefill phase, making them compute-bound and relatively inexpensive per unit. Output tokens are generated autoregressively one by one, requiring continuous memory sweeps across high-bandwidth memory for every single token. Consequently, generation tokens cost roughly 3 to 5 times more in hardware cycle time than prompt tokens.
At what volume does a dedicated GPU cluster become cheaper than commercial token APIs?
The crossover point typically occurs between 15 million and 30 million tokens processed daily for 70B class models. Below this threshold, per-token managed API pricing absorbs idle hardware overhead. Above this volume, dedicated single-tenant GPU clusters provide a 40% to 65% reduction in total operating expenditure.
What role does quantization play in reducing token generation costs?
Quantizing weights from FP16 to FP8 or INT4 halves the memory footprint and doubles effective memory bandwidth throughput. This allows teams to serve 70B parameter models on two GPUs instead of four, doubling concurrent batch capacity per node and cutting the hardware cost per million tokens nearly in half without meaningful quality loss.
Can dynamic batching prevent GPU underutilization during low-traffic hours?
Yes. Continuous iteration-level batching dynamically inserts new user requests into the active decoding iteration without waiting for prior sequences to complete. Paired with orchestration tools, dynamic batching maintains high token throughput even when traffic volume fluctuates across business hours.
Summary
Calculating enterprise LLM inference cost requires moving beyond simplistic hourly compute rates. By modeling the mathematical interplay between concurrency, KV cache overhead, latency SLAs, and hardware utilization, infrastructure leaders can defend reliable quarterly budgets. When workload volume scales, transitioning to dedicated, private GPU clusters with managed orchestration delivers the lowest cost per million tokens while securing proprietary enterprise data.