GuideInference engineering

LLM API vs. self-hosted inference: how to decide

Use a provider API by default, and move a workload to self-hosted open-weight models when volume is steady enough to keep GPUs busy, when data must stay in your environment, or when you need latency or customization an API cannot offer.

By , founder of RXY Studio · Updated

What is the difference between API and self-hosted inference?

Provider APISelf-hosted
PricingPer tokenPer GPU-hour
ModelsFrontier proprietary models and hosted open modelsOpen-weight models you deploy
CapacityThe provider’s problem, within rate limitsYours to plan and scale
DataLeaves your environment under the provider’s termsStays in your environment
OperationsNoneServing stack, upgrades, on call

How do the costs compare?

An API charges for tokens used. A GPU charges for time, used or not. The cost per token of a self-hosted model is the GPU price per hour divided by the tokens it actually serves in that hour, so utilization decides everything.

cost per 1M tokens = GPU cost per hour ÷ (tokens per second × 3,600 × utilization) × 1,000,000

Run the formula with your measured throughput and a realistic utilization, not a peak benchmark, and compare the result with the API price of a model of similar quality.

When is a provider API the better choice?

  • Traffic is spiky or still small.
  • The task needs frontier model quality.
  • The team has no capacity to operate GPUs.
  • You are still finding out which model the task needs.

When does self-hosting make sense?

  • Steady, high token volume on a task that a smaller open-weight model handles well.
  • Data residency or contractual rules that keep data in your environment.
  • Latency targets that need dedicated capacity close to users.
  • A fine-tuned or specialised model.

Can you combine both?

Most production systems do. A gateway routes each request: a frontier model through an API for hard steps, a self-hosted model for high-volume, well-understood steps, and the API as fallback when self-hosted capacity is full.

What should you measure before deciding?

  1. Tokens per day per feature, input and output separately.
  2. Concurrency at peak and off-peak.
  3. Latency targets: time to first token and end to end.
  4. Quality: eval results of candidate open-weight models on your task.
  5. Operating cost: who is on call and what an hour of downtime costs.

Frequently asked questions

Is self-hosting always cheaper at scale?

No. It is cheaper only when GPUs stay busy and an open-weight model meets the quality bar. Low utilization, or a quality gap that forces a larger model, can erase the saving.

What is GPU utilization?

Utilization is the share of time a GPU spends serving requests. Because a GPU costs the same idle or busy, low utilization raises the cost of every token it produces.

Which inference server should we use?

Common choices are vLLM, Hugging Face TGI and NVIDIA Triton with TensorRT-LLM. The right one depends on the model, the hardware and features such as structured output or multi-model serving.

Sources

  1. vLLM — Documentation
  2. Hugging Face — Text Generation Inference
  3. Kwon et al. — Efficient Memory Management for LLM Serving with PagedAttention (vLLM, 2023)
  4. NVIDIA — LLM inference benchmarking: fundamental concepts