Guide · 7 min read
Self-hosted LLM vs API cost: how to compare them
By AI Spendbook · Published · Updated
Short answer
Compare cost per million tokens of your own traffic. For self-hosting, divide a month's full deployment cost (GPU hours or depreciation, power, engineering time, monitoring) by the tokens actually served; for an API, price the same tokens at the provider's rates. Utilisation decides it: a GPU idle half the day doubles its cost per token.
Key takeaways
- Self-hosted cost per million tokens = monthly deployment cost / millions of tokens served.
- Break-even tokens per month = fixed monthly self-hosted cost / API cost per million tokens.
- In the hypothetical example, one GPU node at 25% utilisation costs $6.54 per million tokens against $0.70 on an API.
- Batch work that runs overnight is what usually fills idle GPU hours and makes self-hosting pay.

Running an open-weight model yourself looks cheap when you compare a GPU's hourly rate with a per-token price list. The comparison usually leaves out idle hours, engineering time and the capacity you keep in reserve for peaks. A fair comparison puts both options on the same unit and the same traffic.
Self-host an open model, use Bedrock or Together, or pay for API tokens?
| Option | How you pay | Cost moves with | Who runs it |
|---|---|---|---|
| Provider API (per token) | Per input and output token | Usage | The provider |
| Serverless open-model API (for example Bedrock or Together AI) | Per token, at that host's rates | Usage | The host |
| Dedicated endpoint | Per hour for reserved capacity | Time, whether used or not | The host, on capacity reserved for you |
| Self-managed GPUs (rented or owned) | Per GPU hour, or purchase price over its useful life, plus power | Time, plus your team's effort | You |
The first two are variable costs. The last two are mostly fixed: you pay for the hours whether requests arrive or not. That difference drives everything below.
How do you compare self-hosted and API cost on the same traffic?
- Measure your traffic. Input, output and cached tokens per month for the workload you would move, from your own logs. Include peaks: the hour with the most traffic sets how much capacity you need.
- Cost the self-hosted option for a full month. GPU hours at your rate (or straight-line depreciation of owned hardware), power if you own it, storage, monitoring, and the share of engineers' time spent on serving, upgrades and incidents.
- Measure capacity. Tokens per hour the deployment sustains at your latency target, from a load test with your prompt lengths. Vendor throughput figures rarely match your prompt mix.
- Price the same tokens on the API. Use the provider's published rates, or your contract rates, for input, output and cached tokens.
- Compare cost per million tokens and find the break-even volume. Then check quality on your own examples, because an open model that needs more retries costs more per accepted result.
self-hosted cost per million tokens = monthly deployment cost / millions of tokens served
break-even tokens per month = fixed monthly self-hosted cost / API cost per million tokens
Worked example
Every figure in this example is hypothetical, chosen to show the method. None is a quote from a GPU vendor or model provider. Use your own rates and measured traffic.
| Input (hypothetical) | Value |
|---|---|
| GPU node rate | $8.00 per hour, 24 hours a day, 30 days |
| Engineering time on serving | 0.25 of an engineer at $15,000 a month, fully loaded |
| Monitoring and storage | $300 a month |
| Traffic | 1,200 million input tokens and 300 million output tokens a month |
| Measured capacity of one node | 6,000 million tokens a month at the latency target |
| API rates for a comparable model | $0.50 per million input tokens, $1.50 per million output tokens |
| Self-hosted | API | |
|---|---|---|
| Monthly cost | $5,760 GPU + $3,750 engineering + $300 = $9,810 | 1,200 x $0.50 + 300 x $1.50 = $1,050 |
| Cost per million tokens | $9,810 / 1,500 = $6.54 | $1,050 / 1,500 = $0.70 |
| Utilisation | 1,500 / 6,000 = 25% | Not applicable |
At this volume the API is about nine times cheaper per token. The break-even volume is $9,810 / $0.70, about 14,000 million tokens a month. That is more than twice what one node can serve, so reaching it would need a second node, which raises the fixed cost and moves the break-even again. Self-hosting wins on cost only when traffic is high and steady enough to keep the GPUs busy.
Where each self-hosted figure comes from: GPU $8.00 x 24 hours x 30 days = $5,760; engineering 0.25 x $15,000 = $3,750; plus $300 monitoring and storage. The API blends to $0.70 per million because $1,050 is spread over 1,500 million tokens. Now test the answer's sensitivity: if traffic grew to 4,800 million tokens a month (80% of the node), self-hosting would cost $9,810 / 4,800 = $2.04 per million against $0.70 on the API. Even a busy node loses here, because engineering time is a large fixed cost; the result flips only with far more traffic, cheaper GPUs, or engineers already paid for by other work.
Why does GPU utilisation decide the answer?
A rented GPU costs the same at 3 a.m. as at noon. If traffic follows the working day, average utilisation can be well under half of capacity even when the peak hour is full. Batch work that can run overnight, such as classification, embeddings or evaluations, is what usually fills the idle hours and makes self-hosting pay. Track idle share every month: one minus served tokens divided by what the deployment could have served. Where the GPUs run under Prometheus with NVIDIA DCGM, or under Kubecost or OpenCost, their measured busy share is a better input than a capacity guess, with one caveat: a DCGM busy reading means a kernel was running, not that the GPU was fully used.
Which self-hosting costs are easy to leave out?
- Peak headroom. Capacity kept for the busiest hour is paid for every hour.
- Redundancy. A second node or region so one failure does not take the feature down.
- Upgrades. Moving to a newer open model means new load tests, new quality checks and sometimes new hardware.
- Quality gap. If the open model is accepted less often, divide by accepted results, not requests. See whether a cheaper model is ready.
- Price changes on the API side. Hosted prices fall and introductory rates end. Re-run the comparison when they change, as described in forecasting LLM costs.
What are the common mistakes in a self-hosting cost comparison?
- Pricing the peak hour as the average. Throughput at full load says nothing about the idle hours you also pay for.
- Using vendor throughput figures. Load-test with your own prompt and output lengths at your latency target.
- Leaving out people. Serving, upgrades and incidents take engineering time every month.
- Comparing with list API prices only. Cached input and batch discounts can lower the API side a lot; price the API the way you would actually use it.
- Comparing cost per token at different quality. Divide by accepted results when the open model needs more retries or review.
When does self-hosting an LLM make sense?
- Traffic is large and steady, or there is batch work to fill idle hours.
- Data must stay inside your own infrastructure for contractual reasons.
- You need a fine-tuned model or a configuration no hosted service offers.
- You already have a team that runs GPU infrastructure for other reasons.
If none of these apply, do not self-host for cost alone: a per-token API or a serverless open-model host is usually cheaper and simpler, and the cheaper levers in reducing LLM costs, such as caching, batching and routing, come first.
Comparing on your own traffic in AI Spendbook
AI Spendbook's infrastructure page is built for this comparison. You describe each deployment (cloud GPU, dedicated endpoint or owned hardware) with its hourly rate or purchase price and useful life, and optionally power draw and capacity. Observed cost comes from GPU cloud connectors or from records you enter or upload; the hourly rate fills days with no record, and owned hardware is depreciated straight-line by day. Each figure is labelled observed or modelled.
- GPU cost connectors: RunPod daily bills, Crusoe spend by project, Baseten dedicated deployments, GPU lines from the AWS Cost and Usage Report and the Google Cloud Billing export. Lambda, CoreWeave and Modal have no billing API to read, so their cost is a daily CSV upload.
- Measured utilisation: connections to NVIDIA DCGM through Prometheus, Kubecost or OpenCost give the GPU busy share per label. Set the deployment's utilisation key and the idle share is measured instead of modelled.
- Tokens and comparison: tokens served come from your request telemetry, and the same tokens are priced on a hosted model you name, so the page shows cost per million tokens, idle share and the difference.
Each connector is built from the vendor's public documentation and tested with recorded responses; a provider's later correction to a day already written is not picked up. The hosted comparison ignores quality and latency, so pair it with an evaluation on your own examples.
Sources
- Amazon Bedrock pricing and Together AI pricing: where to find current per-token and dedicated rates for hosted open models.
- vLLM documentation: a widely used open-source engine for serving open-weight models.
Frequently asked questions
Is self-hosting an open LLM cheaper than paying per token?
Only when traffic is high and steady enough to keep the GPUs busy. At low utilisation the fixed hours and engineering time dominate, and a per-token API or serverless open-model host is usually several times cheaper per million tokens.
What costs do self-hosted LLM comparisons usually leave out?
Idle hours, capacity kept for the peak hour, a second node for redundancy, engineers' time on serving and upgrades, load tests for each new model, and any quality gap that causes retries or human review.
How do I measure GPU utilisation for an inference deployment?
Read the busy share from NVIDIA DCGM metrics in Prometheus, or GPU usage over requests from Kubecost or OpenCost, and compare tokens served with the tokens the deployment sustains at your latency target in a load test.