Servingcore
Hosted APIs vs self-hosting
Pay per token with zero ops, or pay per GPU-hour and run the stack yourself.
What it is and why it exists
Hosted APIs scale to zero, need no GPUs and get the best closed models. Self-hosting open-weight models (vLLM, SGLang, TensorRT-LLM) gives control over data, latency and customisation, and wins on cost only at high, steady utilisation — an idle GPU costs the same as a busy one.
Quick prototype
Hosted API.
In production, at scale
Compute break-even: monthly tokens × API price vs GPUs needed for peak × hourly price ÷ utilisation, plus engineering time. Hybrid is common: hosted frontier models for hard tasks, self-hosted small models for high-volume narrow ones.
Vendors and tools
| vLLM / SGLang / TensorRT-LLM / TGI | Serving engines |
|---|---|
| Together / Fireworks / Baseten / Modal | Managed open-model hosting |
| OpenAI / Anthropic / Google | Hosted frontier models |
On AWS: Bedrock (serverless, on-demand or provisioned throughput) vs SageMaker endpoints or EC2 GPU instances (p5 H100, p4d A100, g6e L40S, g6 L4) with vLLM.
How it fails
- GPUs at 10% utilisation “saving money”
- Forgetting the on-call cost of running inference
What the interviewer asks next
When does self-hosting pay off?
When volume is high and steady enough to keep GPUs busy, the model is small enough to serve efficiently, and you need control (data, latency, fine-tunes). Show the break-even numbers.