Cloud GPU vs API vs Buying Hardware: How to Calculate the Real Cost per Million Tokens
A worked method for comparing a rented GPU, a hosted API and your own hardware, including the utilization trap that makes self-hosting more expensive than it looks.
reviewed 2026-11-15 · by Bedino
“Should I run the model myself?” gets answered with feelings more often than arithmetic. The arithmetic is simple, and it often gives a surprising answer: at low utilization, a rented GPU can be several times more expensive per token than a hosted API for the same model.
Cost per million tokens on a rented GPU
For a GPU rented by the hour, serving one model:
cost per 1M tokens = price per hour ÷ 3600 ÷ tokens per second × 1,000,000
The tokens-per-second figure is the aggregate across all concurrent requests. For a single stream it is the bandwidth-bound decode speed (see the tokens-per-second guide); with batching, many requests share each pass over the weights, so the aggregate is several times higher. The calculator assumes about 4× batching and 100 percent busy time.
Worked examples
These use the calculator’s indicative on-demand rates, which you should replace with real quotes: T4 at 0.35 per hour, L4 at 0.70, L40S at 1.60. Each picks the cheapest tier that holds the model plus an 8k context.
| Model | Format | Memory needed | GPU tier | Decode (1 stream) | Cost per 1M tokens at 100% busy | At 25% busy |
|---|---|---|---|---|---|---|
| Llama 3.1 8B | Q4_K_M | 6.9 GiB | T4 16 GB | ~50 tok/s | ~0.49 | ~1.96 |
| Llama 3.1 8B | Q8_0 | 10.3 GiB | T4 16 GB | ~28 tok/s | ~0.86 | ~3.46 |
| Qwen3 32B | Q4_K_M | 21.9 GiB | L4 24 GB | ~11 tok/s | ~4.28 | ~17.1 |
| Llama 3.3 70B | Q4_K_M | 43.9 GiB | L40S 48 GB | ~15 tok/s | ~7.31 | ~29.2 |
Read the right-hand column: if the GPU is busy a quarter of the time, the cost per token is four times as much. A hosted API for a comparable open model is often priced well below those larger-model figures, because the provider keeps its GPUs close to full and batches far more aggressively than a single tenant can.
The lesson is not “never self-host”. It is that utilization is the variable that decides, and you should estimate it honestly.
When self-hosting wins
- High, steady load. If requests arrive around the clock, or you run offline batch jobs that fill the GPU, the 100 percent column applies.
- Privacy or data-residency rules that forbid sending prompts to a third party.
- Models you cannot get as an API: your own fine-tune, a modified base model, an uncommon size.
- Latency control, or no rate limits and no per-token meter.
- Many small requests on a small model. An 8B model on a cheap GPU can undercut API prices even at moderate utilization.
When an API wins
- Bursty or low volume. You pay only for tokens used; there is nothing to idle.
- Large models (70B and up) where you would need several expensive GPUs to match a hosted service’s efficiency.
- No operations capacity. Serving a model reliably — upgrades, monitoring, autoscaling — has a real engineering cost that is not in the formula.
Renting vs buying hardware
For buying, the comparison is a break-even time:
break-even hours = purchase price ÷ (rental price per hour − your running cost per hour)
Running cost is electricity (watts ÷ 1000 × price per kWh) plus a share of the rest of the machine. For example (illustrative numbers, replace with yours): a 450 W card at 0.30 per kWh costs about 0.14 per hour when running flat out. If renting a comparable GPU costs 0.70 per hour, every hour of use saves about 0.56, so a 2,000 card pays for itself after roughly 3,600 hours of real use — about five months of round-the-clock load, or many years at an hour or two a day. Used a few hours a week, renting is the cheaper option and you avoid hardware that depreciates.
Also count what buying does not include: it sits in your house (noise, heat), you do the maintenance, and the hardware ages while models keep growing.
A decision checklist
- Estimate monthly tokens and, more importantly, the shape of the load (steady vs spiky).
- Find the memory the model needs (the multi-GPU and serving guides) and the cheapest tier that holds it.
- Compute cost per million tokens at your real utilization, not 100 percent.
- Compare with the API price for the same or a comparable model.
- Add what the formula leaves out: engineering time, redundancy, monitoring, egress and storage.
- Prefer renting by the hour to test the model for a week before committing to hardware.
Run the numbers
The cloud vs local calculator picks the smallest GPU tier that holds your model and context, computes the cost per million tokens, and compares it with the API price you enter. Change the price field to a real quote, and look at the lower-utilization case by hand with the formula above.
- Why can self-hosting cost more per token than an API even when the GPU is cheap?
- Because you pay for the GPU every hour it is rented or powered, whether or not requests arrive, while an API charges only for tokens used. At low or bursty utilization the idle hours dominate the cost per token. Self-hosting wins when the GPU stays busy, when you need privacy or custom models, or when the API price is high for your model class.
- Which prices does the calculator use?
- Indicative on-demand hourly rates for common cloud GPUs, reviewed periodically, plus an API price you type in. Cloud pricing changes often and varies by provider and region, so treat the built-in rates as placeholders and replace them with a real quote before deciding.
- What utilization should I assume?
- Measure your own. Interactive products with daytime traffic often average well under half of peak; batch pipelines you control can run near full. The calculator's headline number assumes 100 percent busy time with roughly 4-way batching, which is a best case, so compare it with the 25 percent case too.
- What about electricity and cooling if I buy a GPU?
- Include them. A 450 W card running at full load costs 0.45 kWh per hour, so at an electricity price of 0.30 per kWh that is about 0.14 per hour on top of the purchase price, before cooling and the rest of the machine.
- How Much VRAM Do You Need to Fine-Tune an LLM? Full vs LoRA vs QLoRA
- Fine-Tuning Memory Levers: Optimizer, Gradient Checkpointing, Batch Size and LoRA Rank
- Multi-GPU LLMs: Data, Tensor and Pipeline Parallelism, FSDP and ZeRO Explained
- How Many Users Can One GPU Serve? KV Cache, Batching and LLM Concurrency