TL;DR
Self-hosting an open-weights model beats a commercial API only past a measurable threshold. The real cost crossover, the privacy and latency axes, and a decision matrix by use case.

Here is the decision in one table. Most teams should read down the "Commercial API" column, confirm nothing in the other two columns applies to them yet, and move on.
| Commercial API | Managed open-weights | Fully self-hosted | |
|---|---|---|---|
| What it is | Closed models (GPT-5.2, Claude, Gemini) over an API | Open models (Llama, Mistral, Qwen) on someone else's GPUs | Open models on GPUs you rent or own |
| Cost shape | Pure per-token, zero fixed | Per-token, usually cheaper than frontier closed | High fixed GPU cost, near-zero marginal |
| Ops burden | None | Almost none | You own inference, scaling, uptime |
| Best at | Frontier capability, fast start, spiky volume | Portability without ops, cost-sensitive scale | Privacy, control, very high steady volume |
| Switching cost | Highest (closed, provider-shaped) | Low (weights are portable) | Lowest (you hold everything) |
If you are early, cost-sensitive, or unsure of your volume, you start at the left and you do not agonize over it. The interesting decisions happen when one of the other two columns starts to earn its place.
The debate usually gets framed as a binary, run your own model or call OpenAI. In practice there are three options, and the middle one is the one teams forget exists.
Closed commercial API. You send tokens to OpenAI, Anthropic, or Google and pay per token. You get frontier capability, a clean SDK, and zero infrastructure. You also get the highest switching cost, because your prompts and tuning are shaped to one provider's quirks.
Managed open-weights inference. Providers like Together, Fireworks, Groq, and Baseten host open-weights models (Llama, Mistral, Qwen, DeepSeek) and expose them over an API. You get the convenience of an API and the portability of open weights, usually at a lower per-token price than frontier closed models. If the provider disappoints, the same model runs elsewhere, including on your own hardware.
Fully self-hosted. You run an open-weights model on GPUs you rent (RunPod, io.net, a hyperscaler) or own. You get maximum control, data that never leaves your boundary, and a fixed cost that does not scale with each request. You also inherit inference serving, autoscaling, uptime, and the model-update treadmill.
Most "should we self-host" conversations are really "have we outgrown the closed API," and the honest first answer is usually "move to managed open-weights and see," not "go buy GPUs."
Cost is where this gets concrete, so let us do the math with real 2026 prices.
On the API side, output tokens are what hurt. Cheap small models like Google's Gemini Flash-Lite run around $0.40 per million output tokens, while capable frontier models run far higher: Claude Sonnet 5 is about $10 per million output, and Claude Opus 5 about $25, per published 2026 API pricing. That is a 60x spread, and it is the single biggest input to this decision.
On the self-hosting side, cost is fixed. An H100 rents for roughly $3 an hour on-demand, about $2,900 a month running 24/7, and an A100 80GB runs closer to $1,600 a month, per 2026 GPU rental surveys. Whether you push a thousand requests through that GPU or a billion, the bill barely moves. Your marginal cost per token is close to zero once the hardware is paid for.
So the crossover is simple in shape. The API is a straight line from zero that climbs with every token. Self-hosting is a flat, high line. They cross at the volume where a busy GPU gets cheaper than per-token billing.
Here is an illustrative version, and the numbers are made up to show the mechanic, not a quote:
Below that line, the API is cheaper and you carry no ops. Above it, self-hosting pulls ahead, but only if you keep the GPUs busy. That last clause is where most self-hosting cost cases quietly fall apart, which is the next section.
If your volume is nowhere near a billion tokens a month, self-hosting will not save you money, full stop. Chase token-cost discipline on the API first: caps, caching, and cascading easy calls to cheaper models usually beat a hardware migration.
The crossover math assumes your GPU runs flat out. It never does.
A self-hosted GPU costs the same at 3 a.m. with no traffic as it does at peak. If your workload is spiky, a customer-facing feature that is busy for eight hours and idle for sixteen, your effective cost per token can be three times the headline number, because you are paying for a full day of GPU to serve a third of a day of requests.
APIs do not have this problem. You pay for the tokens you use and nothing for the silence in between. That elasticity is worth real money for any workload that is not steady, and it is why spiky or seasonal products should stay on an API well past the point where the raw crossover math says otherwise.
The teams that win at self-hosting are the ones with steady, predictable, high-volume inference: batch pipelines, always-on internal tooling, a core product feature with constant traffic. If that is not you, the API elasticity is a feature, not a compromise.
Cost is the loudest input, but it is rarely the only one. Here is how the three options compare on the axes that decide real deployments.

| Axis | Commercial API | Managed open-weights | Fully self-hosted |
|---|---|---|---|
| Capability | Frontier, first to new features | Close behind, gap narrowing | Depends on the model you run |
| Latency control | Provider-owned, variable | Provider-owned, often faster | Fully yours, tunable |
| Data privacy | Data crosses the vendor boundary | Crosses a boundary you can pick | Never leaves your infrastructure |
| Ops burden | None | Minimal | You own all of it |
| Switching cost | Highest | Low, portable weights | Lowest |
Two of these override cost entirely. If you have a hard data-residency or sovereignty requirement, healthcare, finance, or a regulator that says the data cannot leave a jurisdiction, self-hosting or a region-locked managed endpoint can be the only legal option, and the cost conversation is over. Same for latency: if you need tight, predictable response times and cannot accept a provider's variable tail latencies, control of the stack is worth paying for.
For everything else, the axes reinforce the cost story. Frontier capability lives on the closed APIs. Portability and cost live in open weights. The ops you can stomach decides whether you rent the open-weights inference or run it yourself.
Self-hosting only makes sense if the open model is good enough for your task. In 2026 that bar is much easier to clear than it was two years ago. Open-weights families like Llama, Mistral, Qwen, and DeepSeek now cover most production workloads, summarization, extraction, classification, retrieval-augmented answering, and routine generation, at quality that is close enough to frontier closed models that users do not notice the difference.
Where the closed frontier still leads is the hard stuff: the most demanding reasoning, agentic tool use over long horizons, and the newest multimodal features. If your differentiator depends on being the best at those this quarter, that is exactly the workload to keep on a closed API, and it maps to the same rule from our piece on pricing vendor optionality: keep the expensive, locked-in option only where its capability is genuinely your edge.
For picking the specific model, whether closed or open, our OpenAI vs Anthropic vs Google comparison breaks down the closed frontier, and the same per-task judgment applies when you shortlist an open-weights model to self-host.
Put it together and the call is usually clear once you know which scenario you are in.
| Your situation | Start here | Why |
|---|---|---|
| Early product, unproven volume | Commercial API | Zero fixed cost, frontier quality, ship and learn |
| High steady volume, cost-sensitive | Managed open-weights, then self-host | Per-token savings first, own the GPUs once utilization is high |
| Regulated or data-residency bound | Self-hosted or region-locked managed | Compliance overrides cost |
| Spiky or seasonal demand | Commercial API | Elasticity beats fixed GPU cost |
| Frontier-capability feature | Commercial API | Being best this quarter is the differentiator |
| Want portability, hate lock-in | Managed open-weights | Open weights move; you keep the exit cheap |
Notice how rarely "buy GPUs on day one" is the answer. Self-hosting is an earned move, not a starting position. You get there by outgrowing the API on volume, or by hitting a compliance or latency wall that the API cannot clear.
The GPU bill is the visible cost. These are the ones that do not show up until you own the stack.
None of this makes self-hosting wrong. It makes it a real engineering commitment that should be justified by volume, compliance, or control, not by a napkin cost estimate that assumes perfect utilization.
There is a strategic reason to keep self-hosting on the table even before the cost math flips: it is the cheapest exit you will ever have.
When you run open weights, whether on a managed endpoint or your own GPUs, moving providers is close to free, because you hold the model. That is the strongest version of the vendor optionality we argue for: the option to switch, exit, or repatriate a workload without a rewrite. Even teams that stay on a closed API for capability reasons benefit from keeping a self-hostable open-weights fallback proven out for the workloads that do not need the frontier. It caps your downside if a provider raises prices, changes terms, or has an outage.
Build the abstraction layer that lets you route a request to a closed API, a managed open-weights endpoint, or your own GPU with a config change, and you have bought yourself all three options at once. That is the same discipline behind adding AI to an existing architecture without wiring yourself to a single provider.
We build AI products for founders and enterprises, and we make this call on every one of them. The default is a commercial API, because shipping and learning beats optimizing a cost you cannot yet measure. Then we instrument token spend from day one, so the decision to move to managed open-weights or self-hosting is made on real numbers, not a hunch. And we build the provider abstraction in early, so none of it is a rewrite later.
Self-hosting is a great answer to the right question. The right question is almost never "can we run our own model," it is "does our volume, our compliance, or our latency actually require it yet." Usually the honest answer is not yet, and knowing that saves you a GPU bill you did not need to pay.
Deciding between an API and self-hosting for your AI product? Talk to our engineering team. We have shipped 80+ products across 12 countries, and we design the stack so this stays a config change, not a rebuild.
For most teams, the API is cheaper. Self-hosting has a high fixed GPU cost (an H100 is roughly $2,900 a month running 24/7 in 2026) and near-zero marginal cost, so it only beats per-token API pricing at very high, steady volume. In an illustrative model with a capable model at a blended $8 per million tokens and an $8,000 a month self-hosting setup, the crossover is around a billion tokens a month. Below that, the API wins on cost and carries no ops.
Three cases. First, sustained high volume where a busy GPU is cheaper than per-token billing. Second, hard data-residency or privacy rules where data cannot leave your infrastructure or jurisdiction. Third, when you need full control of latency and the serving stack. Outside those, a commercial API or a managed open-weights endpoint is usually the better call.
It is the middle option between a closed API and full self-hosting. Providers like Together, Fireworks, Groq, and Baseten run open-weights models (Llama, Mistral, Qwen, DeepSeek) on their GPUs and expose them over an API. You get API convenience and open-model portability, usually at a lower per-token price than frontier closed models, without running any GPUs yourself. It is often the right first step before committing to self-hosting.
For most production workloads in 2026, yes. Open-weights families like Llama, Mistral, Qwen, and DeepSeek handle summarization, extraction, classification, and retrieval-augmented answering at quality close enough to frontier closed models that users rarely notice. Closed frontier models still lead on the hardest reasoning, long-horizon agentic tool use, and the newest multimodal features, so keep those workloads on a closed API.
Beyond the GPU bill: inference engineering (serving, batching, autoscaling, latency tuning), the model-update treadmill (re-testing and redeploying as open weights improve), security patching of the serving stack, GPU scarcity and reserved-capacity commitments, and utilization risk, since every idle GPU-hour is money already spent. These make self-hosting a real engineering commitment, not just a line-item swap.
Run open weights where you can, since portable weights make switching close to free, and build a provider abstraction layer so a request can route to a closed API, a managed open-weights endpoint, or your own GPU with a config change. Even if you stay on a closed API for capability, keep a self-hostable open-weights fallback proven out. That caps your downside if a provider changes prices, terms, or has an outage.

Co-Founder, MarsDevs
Vishvajit started MarsDevs in 2019 to help founders turn ideas into production-grade software. With deep expertise in AI, cloud architecture, and product engineering, he has led the delivery of 80+ software products for clients in 12+ countries.
Get more comparisons like this
Join founders, CTOs, and engineering leaders who receive our engineering insights weekly. No spam, just actionable technical content.
Partner with our team to design, build, and scale your next product.
Let’s Talk