API vs self-hosting
Start with a managed API for speed and frontier quality; self-host open weights only when data control, custom weights or steady high utilization justify owning GPUs and on-call.
Analogy: Taking taxis vs buying a fleet: taxis win until you drive the same routes all day, every day, and a fleet means mechanics, parking and insurance even on quiet nights.
How it works
- APIs charge per token, so idle costs nothing; you accept rate limits, deprecations and data leaving your network.
- Self-hosting bills GPUs ~730 hours a month, busy or idle, plus people for upgrades and on-call.
- Cost per token = GPU $/hour ÷ tokens actually served: halve utilization and unit cost doubles.
- The middle ground usually wins first: open models on Bedrock or Vertex, reserved throughput, or batch APIs (~50% off).
- Decide by evals, then compliance, then cost at real utilization, then team; keep it reversible behind a gateway.
Check yourself
Answer to mark it learned; your answers aren't scored.
A new customer contract requires that its data be processed only on infrastructure you control. Your volume is ~1B tokens/month, served today by a hosted API. An open model passes your evals. What do you do?
Go deeper
Full explanation
It's a build-vs-buy decision about who runs the model.
Managed API (OpenAI, Anthropic, Google): fastest time-to-value, frontier quality, zero GPU ops, and pay per token, so idle costs nothing. You accept rate limits (tokens and requests per minute), the provider's deprecations and outages, and data leaving your network, mitigated by zero-data-retention (ZDR) agreements, regional endpoints and private connectivity.
Self-hosting open weights (Llama, Qwen, Mistral, DeepSeek, gpt-oss on Self-hosted serving stack): full control of data residency, latency, versions and fine-tuned weights. You pay for GPUs by the hour whether busy or not, plus people: upgrades, autoscaling, evals, on-call. It is cheaper only at high, steady utilization, and only against an API of comparable quality.
The middle ground usually wins first:
- Open models as a managed service: Amazon Bedrock, Google Vertex AI, Azure, or inference providers (Together, Fireworks, Baseten).
- Dedicated or provisioned throughput: reserved capacity without running the stack.
- Batch APIs (~50% off) for work that can wait.
Decide in this order: quality on your evals → data and compliance constraints → cost at your real utilization → team capacity. Put the choice behind an LLM gateway so it stays reversible.
Code Break-even: rent GPUs vs pay per token, same model
# Break-even for ONE open 70B model: rent GPUs vs pay per token for the same weights.
# Every constant is an ASSUMPTION: replace with your quotes and your own benchmark.
GPU_HOUR = 2.00 # $/H100-hour, committed or neocloud pricing
GPUS_PER_REPLICA = 4 # 70B in BF16 plus KV-cache headroom
TOKENS_PER_SEC = 6_000 # blended in+out per replica at your p95 SLO: measure it!
UTILIZATION = 0.60 # real traffic has peaks, nights and weekends
OPS_MONTHLY = 10_000 # ~0.5 engineer: upgrades, autoscaling, evals, on-call
API_PER_M = 0.80 # $/1M blended tokens at a hosted provider, same model
HOURS = 730 # per month: GPUs bill whether busy or idle
replica_cost = GPU_HOUR * GPUS_PER_REPLICA * HOURS # $5,840/month
replica_m_tokens = TOKENS_PER_SEC * 3600 * HOURS * UTILIZATION / 1e6 # ~9,461M/month
def monthly(m_tokens: float) -> tuple[float, float]:
replicas = max(2, -(-m_tokens // replica_m_tokens)) # ceil; min 2 for availability
return m_tokens * API_PER_M, replicas * replica_cost + OPS_MONTHLY
for billions in (1, 10, 50, 100):
api, own = monthly(billions * 1_000)
print(f"{billions:>4}B tokens/mo API ${api:>8,.0f} self-host ${own:>8,.0f}")
# 1B API $ 800 self-host $ 21,680
# 10B API $ 8,000 self-host $ 21,680
# 50B API $ 40,000 self-host $ 45,040
# 100B API $ 80,000 self-host $ 74,240 -> crossover ~60-90B tokens/monthReal example
A team spends ~$8k/month on a hosted Llama 3.3 70B (10B tokens/month) and asks whether to self-host. Under the code's assumptions, self-hosting costs ~$21.7k: two replicas for availability plus half an engineer, mostly idle at that volume. At 50B tokens it's still $45k vs $40k; the crossover lands around 60–90B tokens/month (~23–34k tokens/s averaged around the clock). What finally moves them is not cost: a customer contract requiring processing on infrastructure they control. That's a constraint, not a price argument, and it's the more common real reason.
Trade-offs +3 · −3
+ You gain
- Self-hosted data never leaves infrastructure you control: residency, air-gapped and sovereign setups.
- Any open or fine-tuned weights, pinned versions, no forced deprecations or per-minute rate limits.
- Lowest cost per token, but only at high and steady utilization.
− You pay
- You pay for idle GPUs: 730 hours a month, busy or not.
- Needs GPU, Kubernetes and inference expertise, plus someone on call.
- Open models may trail the frontier on your hardest tasks; only your evals can tell.
Use it when
Self-host when data must stay on infrastructure you control, you need weights no provider serves, or volume is high and steady enough that GPUs beat per-token prices after ops cost.
Avoid it when
Prototypes, low or spiky traffic, tasks where only a frontier model passes your evals, or a team with no one to own GPUs at 3 a.m.
Numbers to know 4
- A month is ~730 hours: a rented GPU bills all of them, busy or idle.
- Self-host cost per token = GPU $/hour ÷ tokens per hour actually served: halve utilization, double the unit cost.
- Batch APIs cut prices ~50% for results within 24 h (OpenAI, Anthropic, Gemini).
- Worked example (assumptions in the code): ~$0.62/M at 60% utilization vs $0.80/M via API → crossover ~60–90B tokens/month once ops is counted.
Common pitfalls 4
- Pricing GPUs at 100% utilization against API list price: real fleets average far less.
- Forgetting people: at small scale, on-call, upgrades and evals cost more than the GPUs.
- Comparing a self-hosted 70B to a frontier API on price alone: compare at equal quality on your evals.
- Assuming an API means your data is retained or trained on: check ZDR, retention and regional options first.
Interview questions 2
Answer out loud first, then reveal.
The API bill is $60k/month and the CFO asks why we don't self-host. What do you answer?Show answer
First, self-host what? An open model has to match quality on our evals, or it's a product downgrade, not a saving. If one does, I compare at real utilization: GPUs bill 730 hours a month, we need at least two replicas for availability, and someone owns on-call. Often the cheaper wins are elsewhere: routing easy traffic to a small model, prompt caching, batch APIs at ~50% off. If an open model qualifies, a managed endpoint captures most of the saving without the ops. I'd come back with a break-even sheet, not an opinion.
When is self-hosting clearly the right call?Show answer
Three cases. Hard data constraints: air-gapped, sovereign or a contract saying it runs on our infrastructure, where no ZDR or regional endpoint satisfies legal. Custom weights: a fine-tuned or distilled model no provider serves with the latency or control we need. Sustained high volume, where benchmarked tokens per GPU-hour at realistic utilization beat the per-token price after ops cost. Even then I keep an API path behind the gateway as a fallback and a quality baseline, so the decision stays reversible.