Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 93/ 160
05. AI System Design

GPU vs API Cost

Break-even analysis for self-hosting GPUs versus paying per-token APIs.

IntermediateBreak-even · Utilization3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

Paying per use costs less when you use the AI a little, and owning your own computers costs less when you use it a lot, so you work out where the two lines cross.

Think of it like…

Taxi versus owning a car: a taxi is cheaper if you ride rarely, a car is cheaper if you drive daily, but only if you count parking, insurance, maintenance and the time you spend on all of it.

Where you’ve seen it

A feature handles 50,000 requests a day with 3,100 input and 420 output tokens each: 155M input and 21M output tokens daily. A comparable hosted open-model API charges an illustrative $0.90 per million tokens in and out, so $158.40 a day. Self-hosting that model on GPUs that prefill at 8,000 tokens per second and decode 914 tokens per second at the latency target needs 155M ÷ 8,000 = 19,375 s plus 21M ÷ 914 = 22,976 s, or 11.76 GPU-hours of pure compute a day. At a realistic 60% average utilisation that is 19.6 GPU-hours, 0.82 of a GPU, but redundancy requires at least 2 GPUs running 24 hours: 2 × 24 × $3 = $144 a day, plus 0.25 of an engineer at $180,000 a year ($123 a day), so $267 versus $158: the API wins. At 250,000 requests a day the API costs $792 while self-hosting needs 98 GPU-hours (5 GPUs, $360) plus the same $123, so $483: self-hosting wins by $309 a day. The break-even is about 84,000 requests a day, and it moves with utilisation, GPU price and the quality gap to a frontier API (which at $2.50 and $10 per million would cost $597.50 a day at 50,000 requests).

Words you’ll hear

Break-even volume
The usage level at which self-hosting and API total costs are equal.
Utilisation
The share of paid GPU time actually used for useful work.
Redundancy floor
The minimum number of GPUs needed for availability regardless of load.
Ops overhead
Engineering time for deployment, scaling, upgrades, monitoring and on-call.

Visual diagram

Loading interactive diagram

Theory & deep dive

Building the cost model

API side: daily cost = input tokens × input price + output tokens × output price, with discounts from caching or batch tiers. Self-hosted side: measure real per-GPU throughput for your model, precision and latency SLO (prefill tokens per second and decode tokens per second at the chosen batch size; see the throughput lesson), convert daily tokens to GPU-seconds, divide by an achievable utilisation (traffic is diurnal and bursty, so 40% to 70% is typical for interactive services), then round up to whole GPUs and apply a redundancy floor (two replicas so one failure or deploy doesn't take you down). Add GPU price per hour (on-demand, reserved or committed discounts), networking and storage, monitoring, and the people cost of running a serving stack.

Make the comparison at equal quality: an open 70B model hosted yourself should be compared with an API for that model class, or your eval set must show it meets the product's quality bar. If you need frontier capability, no self-hosted option may qualify, and the question becomes API pricing tiers and caching instead. Self-hosting can also be driven by non-cost reasons: data residency or privacy, latency control, customisation (fine-tuned or LoRA models) and avoiding rate limits or vendor dependence; price these in, but keep them separate from the dollar break-even.

GPU-hours from tokens

Prefill: 155,000,000 ÷ 8,000 tokens/s = 19,375 s. Decode: 21,000,000 ÷ 914 tokens/s = 22,976 s. Total 42,351 s = 11.76 GPU-hours. At 60% utilisation: 19.6 GPU-hours, about 0.82 GPU on average, but with two replicas minimum you pay for 48 GPU-hours a day.

Key takeaway: Convert tokens to GPU-seconds, divide by realistic utilisation, round up with a redundancy floor and add ops cost.

Break-even, sensitivity and decisions

With the numbers above, self-hosting costs = $72 × N GPUs (N = max(2, ⌈volume × 0.82⌉)) + $123 ops, against an API cost of $158.40 × volume (in units of 50,000 requests a day). At 1×: $267 versus $158. At 1.5×: N = 2, $267 versus $238. At 2×: N = 2, $267 versus $317 (self-hosting is already cheaper). The crossover is $267 ÷ $158.40 = 1.69×, about 84,000 requests a day. At 5× it's $483 versus $792. Note the step shape: self-hosting cost is flat until you need another GPU, so under-utilised fixed capacity makes small workloads expensive.

Run a sensitivity analysis: at 30% utilisation, GPU needs double and break-even rises; with reserved GPUs at $2 an hour, break-even falls; if ops need a full engineer ($493 a day), break-even moves far higher; if API prices drop 50% (which has happened repeatedly), the case weakens. Consider hybrids: serve the stable high-volume base load on owned GPUs and burst or long-tail requests to an API; use APIs for prototyping and switch when volume and requirements stabilise; and revisit the decision regularly. Include risk: capacity shortages and GPU lead times, upgrade effort when better open models appear and the cost of an outage on a single-vendor API versus your own stack.

Sensitivity

Base: break-even ≈ 84,000 requests/day. With reserved GPUs at $2/h the fixed cost falls to $96 + $123 = $219, so break-even ≈ 69,000/day. With a full-time engineer on the stack (+$370/day), self-hosting at the 2-GPU floor costs $637, and break-even moves to about 270,000 requests a day (5 GPUs at $360 plus $493 = $853 against an API cost of $158.40 per 50,000 requests).

Key takeaway: Break-even is a range driven by utilisation, GPU price, ops load and API price changes; hybrids can capture both.

How it works, step by step

Step 1 of 4
Analyst

1. Fix the workload and quality bar

Estimate daily input and output tokens at peak and average, and choose the model that meets the quality bar.

155M in + 21M out per day
Key numbers at this step
Compare
at equal quality

When to use it & trade-offs

What it is

GPU versus API cost analysis compares paying a provider per token against running your own GPUs. The API cost is simple (tokens × price). The self-hosted cost has to include GPU-hours for the capacity you actually need (peak load, redundancy and utilisation, not average load), engineering and operations time, storage, networking and the cost of being slower to adopt new models. The comparison must be made at equal quality (the open model you can host versus the API model you'd otherwise use) and produces a break-even volume below which the API is cheaper and above which self-hosting wins.

Why it matters: Per-token prices look cheap until volume grows, and GPU prices look cheap until you count idle time, redundancy and engineers. Teams often self-host too early (paying for idle GPUs and operations) or too late (paying a large API bill for a stable, high-volume workload). A break-even model with explicit utilisation and ops assumptions turns an emotional debate into a decision with sensitivity ranges.

When to reach for it

  • Deciding whether to adopt open models in-house
  • Budgeting for scale-up of a successful AI feature
  • Evaluating reserved GPU commitments

When to avoid or be careful

  • Comparing GPU price per hour with API price per token without utilisation
  • Ignoring redundancy and on-call costs
  • Comparing a weaker self-hosted model with a frontier API

Hosting options

Pay-per-token API
Best for: Low or variable volume and frontier models

Strengths: No fixed cost; elastic; no ops.

Watch out: Cost scales linearly; rate limits and data sharing.

Self-hosted GPUs
Best for: Stable high volume, data control and customisation

Strengths: Lower unit cost at scale; control.

Watch out: Fixed cost, utilisation risk and operations burden.

Hybrid (base load on GPUs, burst to API)
Best for: Spiky traffic with a steady core

Strengths: Good utilisation and resilience.

Watch out: Two stacks to maintain and keep consistent.

Interview signals & numbers to know

When this topic comes up

  • “Should we host our own model?”
  • “Our API bill is growing fast”
  • Break-even analysis
  • GPU utilisation
  • Reserved capacity

Benchmarks & rules of thumb

$267 vs $158 -
self-host vs API per day at 50,000 requests
$483 vs $792 -
self-host vs API per day at 250,000 requests
~84,000/day -
break-even requests per day in the example

Common mistakes & follow-ups

Common interview mistakes

  • Assuming 100% GPU utilisation.
  • Forgetting that you need at least two replicas for availability.
  • Treating engineers' time as free.

Likely interviewer follow-ups

  • How would you decide between an API and self-hosting?
  • What affects the break-even volume most?
  • When does a hybrid approach make sense?
Interview tip: Show the step function (GPUs are bought whole) and the redundancy floor. They explain why small workloads rarely favour self-hosting.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply GPU vs API Cost with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
Speculative Decoding
Next topic
Batch Inference