AI Engineering
/
Model Serving & Inference
/

Choose a hosted API or a self-hosted model

Model Serving & Inference · 2 to 3 hours

Choose a hosted API or a self-hosted model

Compare a hosted model API with a self-hosted open-weight model for a live tutor and a nightly scoring job: apply a quality gate, compute monthly cost at real utilization and the breakeven volume, check a data-location rule, and say what would reverse the choice.

Medium
Conceptual

Conceptual comparison

3 h

Overview

Learn to compare a hosted model API with an open-weight model you run yourself, one workload at a time and on the same dimensions. You practice on a fictional language-learning app with a live tutor, nightly essay scoring, and a district's data rule.

Study time: 2 to 3 hours

Interview format: Technical screen comparison with a cost, capacity, and data-rule table

By the end you can

  • Frame a hosted-versus-self-hosted decision per workload, stating the goal, constraints, and quality gate before cost
  • Compute monthly cost from token prices and from node-hours, including spare capacity and people time, and explain how utilization changes the cost per request
  • Derive a breakeven utilization for an interactive pool and a breakeven volume for a batch job
  • Check hosted and self-hosted configurations against a data-location and retention rule, including your own logs and fallback routes
  • Compare both options on the same dimensions and name the evidence that would settle the choice and the change that would reverse it

Prerequisites

Helpful background: Comfort with per-million-token prices, percentages, and percentiles helps. No GPU or KV memory math is needed: throughput is given as measured data.

This topic covers runtime scheduling, memory, and hardware. AI Application Integration covers streaming state in the client and server.

Frame the decision per workload

A hosted API runs the model and the hardware and charges per token. Self-hosting runs open weights on nodes you rent or own, paid per node-hour, busy or not. Managed open-weight endpoints sit in between.

Decide per workload: a live feature and an overnight job can land on different sides. First write down each workload's goal, traffic shape, latency target or deadline, data rules, and quality bar. When the options use different models, the choice bundles which model and who runs it, so settle quality before cost.

Quality on your own tasks is a gate

Run both models on your own suite with the same prompts and grading, and report every slice (a group of cases that matters on its own, such as a language family) as well as the overall rate. An option that fails the gate for a workload is out for it, whatever it saves. A gap of a few cases on a slice of a few hundred can be noise: confirm a narrow pass with a larger paired evaluation or a shadow run, while a large gap on a small slice is still evidence.

Tokens versus node-hours

Hosted cost follows use: requests x tokens x price. Self-hosted cost follows provisioned time: node-hours x price, busy or not, plus people. Utilization is average load over the measured capacity you pay for: a $3.60-per-hour node serving 3,600 requests per hour costs $0.001 per request fully busy, $0.002 half busy.

Cost formulas
fully busy cost per request = node price per hour / requests per node-hour
cost per request = fully busy cost per request / utilization
breakeven utilization = fully busy cost per request / hosted cost per request
breakeven volume = fixed monthly cost / (hosted cost per request - self-hosted variable cost per request)

An interactive pool is sized for its peak plus headroom and a spare and runs all day, so the average-to-peak ratio caps its utilization. A batch job that can wait runs nodes only while there is work: its cost tracks the work, and the deadline sets how many nodes run at once.

Latency and capacity control

Hosted, the provider's shared capacity shapes your tail latency and rate limits cap your peak; you can ask for a higher limit or buy reserved or priority capacity at a price, but you do not control the provider's shared pool.

Self-hosted, you own the queue and admission, so you can protect a latency target, but only with capacity already running: a node takes minutes to start, more quota can take weeks. Take throughput per node from a pilot on your own prompts and runtime.

Data location and retention

A data rule asks two separate questions: where processing happens, and who keeps copies of inputs and outputs, for how long. Providers often keep API traffic for a limited time for abuse monitoring, grant zero retention only on approval, and process in-region in some regions only (as of November 2026, OpenAI's data controls page describes all three), so check your exact endpoint and model.

Self-hosting is not compliant by itself: logs, traces, caches, backups, and evaluation copies must follow the same rule, and the open-weight license must allow your use.

Lifecycle, customization, and exit

Hosted models retire on the provider's schedule (as of November 2026, Anthropic's deprecations page, for example, gives at least 60 days' notice for publicly released models). Each retirement is a migration: rerun your suite on the successor, recheck price, latency, and limits, then roll out. Self-hosted weights stay pinned, but runtime, driver, and security updates are yours.

Customization (adapters, quantization, hosted fine-tuning) is a lever, not a verdict. For exit, keep prompts, output contracts, and the suite provider-neutral; OpenAI-compatible servers such as vLLM narrow interface changes, not behavior differences.

Operations and people

Self-hosting adds upgrades, patches, capacity planning, monitoring, incidents, and on-call. Google's SRE book calls manual, repetitive work that grows with the service "toil" and aims to keep it below 50% of each engineer's time. Count people time as a fixed monthly line, often shared by every self-hosted workload.

A rotation needs several trained people with runbooks (the book's minimum single-site on-call team is eight), so one experienced person is a single point of failure. Hosted APIs need less operations work.

Hybrids and fallback

Workloads with different traffic shapes, quality results, or data rules can land on different options; each extra path adds a suite, monitoring, and a runbook. A fallback in either direction may take only traffic it is allowed and able to take: same quality gate, same data rule, capacity running when needed. Route by data class before falling back.

Compare on the same dimensions

Put both options for one workload in one table with a row per dimension: quality gate by slice, cost at real utilization and the breakeven, latency and capacity, data handling for every copy, lifecycle and operations, and exit and fallback. Fill each row with the scenario's figures, then give a recommendation per workload, the evidence that would settle what is uncertain, and the change that would reverse it.

Scenario: a live tutor and nightly essay scoring

Worked example

All figures are synthetic; the provider, models, and prices are fictional. Months have 30 days (720 hours).

Suppose a language-learning app runs two AI workloads on a hosted model API, and a school district's contract starts in 10 weeks. Should each stay hosted or move to an open-weight model on the company's own GPU nodes?

Conversation tutor (live chat)Essay scoring (nightly batch)
Volume432,000 turns a day (5 per second on average)100,000 essays a night
Traffic shape15 per second for about 3 hours on school-day afternoons; about 1 per second 22:00 to 06:00Submitted by 22:00, due by 06:00 (8 hours)
Tokens per request1,200 input, 100 output2,500 input, 500 output
TargetDaily p95 time to first token (TTFT) at most 800 msEvery score delivered by 06:00

District rule. 40% of the essays come from the district. They must be processed in its region, no model provider may keep an essay or its output after the request, and the company's own copies (logs, traces, backups) must stay in that region. The tutor is not covered.

Option H: hosted API, pinned model version H-M

  • $0.20 per million input tokens, $2.60 per million output tokens.
  • Account limit for H-M: 1,500,000 tokens per minute (input plus output), shared by both workloads; higher limits on request, no committed date.
  • Standard endpoint: any of the provider's regions. Regional endpoint: the chosen region only, at 15% more per token.
  • Both endpoints keep inputs and outputs up to 30 days for abuse monitoring. Zero retention needs the provider's approval; the team applied two weeks ago and has no decision date.
  • Versions retire with notice and a named successor.
  • Tutor, last 30 days: daily p95 TTFT 500 to 650 ms. On 3 days the busiest hour's p95 reached 1.2 s, with all the extra time before the provider's first byte.

Option S: self-hosted open-weight model O

  • O's license allows commercial use. Nodes in the district's region: $7.20 per node-hour, billed per minute while running; about 20 minutes to start one and load O; quota 6 nodes, about two weeks to raise.
  • Two-week pilot on the company's prompts, per node: 10 tutor turns per second with p95 TTFT at or below 800 ms (450 ms at 7.5 per second); 5 essays per second with large batches.
  • Tutor pool rule: the fewest nodes that keep the peak at or below 75% of their combined measured rate, plus one spare, running around the clock (a burst starts faster than a node can be added).
  • Essay batch rule: plan at 80% of the measured rate (this covers start-up, retries, and uneven essay lengths); nodes run only during the batch, enough to finish within 6 of the 8 hours.
  • People: any self-hosting takes about 0.4 of an engineer ($6,500 a month, one workload or both). One platform engineer has run GPU serving; the six-person on-call rotation would take serving pages after training.

Quality (the company's suites; same prompts and grading for both models)

Suite and sliceCasesH-M passO pass
Tutor: high-resource languages400372368
Tutor: low-resource languages1008470
Tutor: grammar correction1008484
Tutor overall600540522
Essays: argument250232231
Essays: narrative250228224
Essays overall500460455

Tutor pass: teachers rate the conversation 4 or 5 of 5. Essay pass: within one point of the teachers' score (6-point scale).

Quality gate. A model may replace H-M for a workload only if its pass rate is at most 2.0 percentage points below H-M's overall and at most 5.0 points below on every slice of that workload's suite.

Work the cost, capacity, and quality figures

Work every figure before you compare.

Predict the outcome

Work the cost, capacity, and quality figures

Using the hosting scenario, work out each figure from the inputs listed, then reveal the values and the working. Use 30-day months (720 hours) and the planning rules exactly as stated.

FigureInputs from the scenarioValueWorking
Tutor, hosted: cost per turn and per month432,000 turns a day; 1,200 input and 100 output tokens; $0.20 and $2.60 per million??
Tutor, self-hosted: nodes and monthly GPU costPeak 15 turns per second; 10 per node at the TTFT target; the 75% rule plus one spare; $7.20 per node-hour around the clock??
Tutor: pool utilization and breakeven utilizationAverage 5 turns per second; the pool from the row above; the hosted cost per turn??
Tutor, hosted: peak load against the account limitPeak 15 turns per second; 1,300 tokens per turn; 1,500,000 tokens per minute??
Essays, hosted: cost per essay and per month, and the window100,000 a night; 2,500 input and 500 output tokens; 8-hour window??
Essays, self-hosted: node-hours, nodes, monthly cost5 essays per second per node, planned at 80%; finish within 6 hours; $7.20 per node-hour; $6,500 people??
Essays: breakeven monthly volumeHosted and self-hosted cost per essay; people cost??
Quality gate for O, per workloadSuite table; at most 2.0 points below overall and 5.0 below on any slice??
Essays: monthly cost of each way to meet the district rule40% district share; regional endpoint 15% more; the costs above??

Check configurations against the district rule

Use the district rule and Option H's terms.

Predict the outcome

Check configurations against the district rule

For each configuration, decide whether the district's essays may use it today and why, then reveal the answers.

ConfigurationMeets the rule today?Why
H-M on the standard endpoint??
H-M on the regional endpoint??
H-M on the regional endpoint, zero retention requested, no decision yet??
H-M on the regional endpoint, zero retention approved in writing for H-M??
O on in-region nodes; the gateway logs full prompts and outputs to a log store in another region for 14 days??
O on in-region nodes; in-region logs keep request IDs, token counts, timings, and scores, no essay text??
O on in-region nodes; when a node fails, essays fail over to H-M on the standard endpoint??

Change one constraint at a time

Start from your own recommendation per workload.

Predict the outcome

Change one constraint at a time

Start from your recommendation for each workload. For each change below, taken one at a time, say whether the recommendation changes and which figures or checks you would redo, then reveal the answers.

ChangeTutorEssay scoring
Volume grows four times for both workloads, with the same daily shape??
The provider announces that H-M retires in 90 days and names a successor, H-N??
A new release of O matches H-M's pass count on every tutor slice, with the same pilot throughput??
The only engineer who has run GPU serving leaves, 8 weeks before the district contract starts??
The region and retention rule now applies to every customer and to both workloads??

Completion checklist

  • I can say why a workload's quality gate comes before its cost comparison.
  • I can turn token prices and node-hours into monthly cost and cost per request at a stated utilization.
  • I can derive a breakeven utilization and a breakeven volume, and say which fixed costs move them.
  • I can check a configuration against a region and retention rule, including logs, backups, and fallback routes.
  • I can name the change in the inputs that would reverse a hosted or self-hosted choice.

Sources

  • Efficient Memory Management for Large Language Model Serving with PagedAttention (Kwon et al., 2023) Reports 2 to 4 times higher throughput than earlier serving systems at the same latency on the same models: throughput per node depends on the runtime, so measure it on your own stack and prompts.
  • vLLM: OpenAI-Compatible Server An open-source runtime that implements OpenAI's Completions and Chat APIs and works with the official OpenAI client; some parameters are not supported, so a switch still needs testing.
  • OpenAI API: Data controls in the OpenAI platform As of November 2026, describes default retention of API data for abuse monitoring, zero data retention subject to prior approval, and data residency set per project with in-region processing in some regions only. Cited for the general pattern; Option H's terms are fictional.
  • Claude API: Model deprecations As of November 2026, defines lifecycle stages from active to retired, gives at least 60 days' notice before retiring a publicly released model, names a recommended replacement, and advises testing replacements before the retirement date.
  • Google SRE book: Eliminating Toil Defines toil as manual, repetitive, automatable operational work that scales linearly as a service grows, with a goal of keeping it below 50% of each SRE's time.
  • Google SRE book: Being On-Call Puts the minimum on-call team at eight engineers for a single site and six per site for two sites.

The app, workloads, district rule, provider H, models H-M and O, prices, throughputs, pilot and suite results, planning rules, and rubric are original synthetic teaching material about a fictional application. Option H's data terms follow a pattern common among providers and are not any one provider's terms. No real provider's prices, limits, or benchmarks are claimed, and the figures are not performance claims about any model, runtime, or GPU. Study times and readiness thresholds are editorial estimates. Product, protocol, and model details are as of November 2026.

Practice the interview question

Answer it in your own words before you look at the reference answer.