Skip to content
Inference Academy

Self-hosting an LLM vs using an API: when does it actually pay off?

A worked break-even analysis of self-hosting an open model on your own GPUs against paying an API per token: the formula, two examples at very different volumes, the utilisation threshold that decides it, the costs people forget, and the non-cost reasons (privacy, latency, control) that sometimes matter more.

Key takeaways

  • API cost grows smoothly with tokens; self-hosting costs the same whether GPUs are busy or idle.
  • At low volume, APIs win by a wide margin: a small workload can cost under 10% of the cheapest suitable GPU setup.
  • At high, steady volume, self-hosting can cost less than half as much per token.
  • In the worked example, self-hosting breaks even at about 40% average utilisation of the planned capacity, or about 50% once engineering time is included.
  • Privacy, data residency, latency control and custom models are often better reasons to self-host than cost.

By

7 min read

Share
On this page

"Should we just run it ourselves?" comes up as soon as an API bill gets large. Open models are now good enough for many tasks, and GPU prices per hour look small next to a monthly invoice. Sometimes self-hosting is a big saving. Often it's more expensive. The difference comes down to one number most teams don't measure: how busy your GPUs would really be.

#Two different cost shapes

  • API: you pay per token. Double the traffic, double the bill. No traffic, no bill.
  • Self-hosting: you pay per GPU-hour. The bill is the same whether the GPUs serve 10 requests or 10 million, up to their capacity.

So the API is cheaper below some volume and self-hosting is cheaper above it. Where the crossover sits depends on the model, the latency target and, above all, how evenly your traffic is spread over the day.

#Example 1: a small workload

A team runs a 70B-class open model for an internal tool: 100,000 requests a month, 2,000 input tokens and 500 output tokens each. That's 200 million input and 50 million output tokens a month.

Assume, for illustration, an API price of $0.60 per million input tokens and $1.80 per million output tokens for a comparable model (check real prices; they vary a lot by provider and model).

Monthly cost
API: 200M input × $0.60 + 50M output × $1.80 about $210
Self-hosted: 2 H100s (a 70B model in FP8 needs two), 24/7, at $2.50 per GPU-hour about $3,650

The API is about 17 times cheaper. The GPUs would sit idle almost all the time. This is the most common situation, and the answer is clear: use the API, or a serverless GPU platform that bills per second (serverless GPU platforms).

#Example 2: a large, steady workload

Now the workload from how many GPUs do you need to serve an LLM: 1,000 requests a minute around the clock, 8K-token prompts, 1K-token answers. That plan needs 8 nodes of H100s (64 GPUs) to meet strict latency targets.

Per hour at full load, it serves about 491 million input tokens and 61.6 million output tokens.

Cost per hour Cost per month (730 hours)
API at the same illustrative prices about $406 about $296,000
Self-hosted: 64 H100s at $2.50 $160 about $117,000

At full, steady load, self-hosting costs about 40% of the API. That's the case people quote when they say self-hosting is cheaper.

#The break-even utilisation

The catch is "full, steady load". Self-hosted GPUs cost $160 an hour whether busy or not, while the API cost falls with traffic. Self-hosting only wins while:

average utilisation>self-hosting cost per hourAPI cost per hour at full load=160406≈39%\text{average utilisation} > \frac{\text{self-hosting cost per hour}}{\text{API cost per hour at full load}} = \frac{160}{406} \approx 39\%

Add engineering time to run the platform, say $30,000 a month for on-call, upgrades and incidents (use your own figure), and the threshold rises:

117,000+30,000296,000≈50%\frac{117{,}000 + 30{,}000}{296{,}000} \approx 50\%

So in this example, self-hosting pays off only if the GPUs you buy or rent are, on average, more than half busy. Traffic that peaks at midday and drops at night can easily average 30 to 40% of peak. Autoscaling, filling troughs with batch jobs and sharing GPUs across models are how teams push utilisation up (cost per million tokens shows the effect).

#How sensitive is the break-even?

Both prices move, so test the answer against them. Break-even utilisation for Example 2 (GPU cost only, no engineering):

GPU price per hour API at the illustrative prices API prices halved
$2.00 about 32% about 63%
$2.50 about 39% about 79%
$3.50 about 55% over 100%: self-hosting never wins

If API prices fall by half (which has happened repeatedly for comparable models), the case for self-hosting on cost alone weakens sharply. Re-run the sums whenever prices change.

#The middle options

It's not a binary choice. Between "call a frontier API" and "run your own GPU fleet" there are options that often beat both:

  • Hosted open models. Many providers serve popular open models per token, often well below frontier-model prices. You keep the option to self-host the same model later.
  • Dedicated endpoints. A provider runs a model on GPUs reserved for you, billed per hour, without you operating the stack.
  • Serverless GPUs. You bring the model and engine; the platform scales GPUs to zero when idle and bills per second. Good for spiky or low traffic, at the cost of cold starts (serverless GPU platforms).
  • Batch APIs. Many providers discount requests that can wait hours, which suits offline jobs.

#A sensible path

  1. Start with an API and log token volumes per feature, by hour.
  2. Find the one high-volume, well-defined task (classification, extraction, a narrow assistant) where an open model is good enough.
  3. Try it on a hosted open model or serverless GPUs first, to prove quality without operating anything.
  4. Self-host that task only when its volume makes the break-even comfortable and you have the people to run it.
  5. Keep frontier APIs for the hard, low-volume, quality-critical work.

#Costs people forget when self-hosting

  • Headroom and failover capacity (one of the 8 nodes above).
  • Warm spare replicas to avoid cold starts.
  • Staging and evaluation GPUs for testing new models and engine versions.
  • Engineering and on-call, which dominates at small scale.
  • Quality work: evaluating open models and quantised versions against your tasks.

#Costs people forget when using an API

  • Prompt growth. Agents and RAG grow prompts steadily; per-token bills grow with them. Check whether the provider discounts cached input tokens.
  • Rate limits at peak, which may force a more expensive tier.
  • Price changes and model retirement, which you don't control.

#Reasons that aren't about cost

Often the decision isn't made on price at all:

Reason to self-host Why
Data privacy or residency Data never leaves your network or region
Latency control You choose the batch size, hardware and location
Custom models Your fine-tunes, or many LoRA adapters on one base (serving LoRA adapters)
Predictable behaviour The model version changes only when you change it
Very high, steady volume The cost case from Example 2
Reason to use an API Why
Low or spiky volume You pay only for what you use
Frontier models The best closed models are only available by API
Small team No GPU platform to run
Speed to launch Working in an afternoon

Many teams end up hybrid: an API for frontier-quality tasks and spiky traffic, self-hosted open models for high-volume, well-defined tasks.

#How to decide for your workload

  1. Measure real token volumes by hour of day for a few weeks.
  2. Size a self-hosted deployment for the peak at your latency target (capacity planning and cost).
  3. Compute the break-even utilisation with your real GPU and API prices, including engineering time.
  4. Compare it with your real average utilisation, after any autoscaling you'd actually run.
  5. Weigh the non-cost reasons separately; they can justify self-hosting at a loss, or rule it out at a saving.

The self-host vs API calculator runs steps 2 to 4 with your numbers.

#Common mistakes

  • Comparing API cost with GPU cost at 100% utilisation.
  • Leaving engineering time out of the self-hosting side.
  • Comparing models of different quality. A cheaper open model that fails 10% more often may cost more in retries, escalations and support.
  • Forgetting cached-input discounts on the API side, which can cut input costs a lot for repetitive prompts.
  • Deciding once. Prices, models and traffic all change; revisit the decision every few months.

#FAQ

At what monthly API bill should I consider self-hosting? There's no fixed number; it depends on how steady the traffic is and what an equivalent open model costs to run. Steady volume that would keep a few GPUs more than half busy is the usual starting point for a serious look.

Is self-hosting more private? It keeps data on infrastructure you control, which helps with privacy and residency requirements. Many API providers also offer data-retention and regional options, so check both.

Can I use my own fine-tuned model through an API? Some providers host fine-tunes of open models, which can be a good middle step before self-hosting.

#Go deeper

Laptop to production and choosing GPUs and deployment cover the path from API to self-hosted, in the Serving AI in Production course.

costself-hostingapicapacity-planninginference-engineering

Found this useful?

Send it to someone who is learning the same thing.

Share this article

Next: learn it step by step, free

Capacity planning and cost

Turn traffic and latency targets into a GPU count and a monthly bill. A free lesson with step-through diagrams and a quiz.

Get new articles by email

One short email when a new guide is out. Unsubscribe any time.