Infrastructure

Self-Hosted LLM Gateway vs Managed: The Honest Cost Model (2026)

Start with the conflict of interest: we sell a managed LLM gateway. If you self-host, we do not get paid. That is a real bias and you should read every number below through it. So here is the arrangement — every figure on this page is either a first-party measurement you can check against our published benchmark, or a modelled assumption we name explicitly so you can swap in your own. The conclusion is not a recommendation. It is a break-even formula: self-hosting wins when your monthly infrastructure plus engineer-time costs less than the margin a managed gateway takes on your provider spend. At a 5% margin and a modelled $10,000/month of running it yourself, that break-even sits near $200,000/month of provider spend. Below that, buying is cheaper on pure cost. Above it, building is. And cost is not the only axis — two of the four cases where self-hosting genuinely wins have nothing to do with money at all.

Break-even provider spend for a self-hosted LLM gateway at four different managed-gateway margins

If you have already read what an LLM gateway is and how routing and failover work, you know what the layer does. This page answers the question those two skip: should you run it yourself, and at what point does that stop being a hobby and start being cheaper?

Our conflict of interest, in full

DataLLM Lab sells a managed gateway. Every reader who decides to self-host is a customer we do not get. That is the plainest possible statement of the bias in this article, and putting it in the first screen is the only reason the rest of it is worth reading.

Two things follow from that. First, we are not going to tell you self-hosting is hard and leave it there — the cases where it is correct are listed below in more detail than the cases where it is not. Second, where we do use our own data, it comes from a benchmark that deliberately does not run on our infrastructure. All of our published model numbers are produced by calling OpenRouter's OpenAI-compatible endpoint, not the DataLLM Lab gateway, precisely so that nothing in them depends on our product working well. You can reproduce them without being our customer. On a page where we are otherwise selling something, that distinction is worth stating twice.

What we cannot remove is the framing bias — which questions we chose to ask, which costs we chose to model. So every assumption in the cost model has a name and a number you can overwrite.

Where self-hosting genuinely wins

Four cases. In the first two, cost does not enter the argument at all; the third changes what the cost is, and only the fourth is a pure spreadsheet question.

1. A rule forbids a third party in the path. This is the strongest case and it is not negotiable by spreadsheet. If your contracts, your regulator, or your customers' data-processing agreements say that prompt content cannot transit a vendor you have not individually vetted and named, a managed gateway is a new sub-processor and the answer is no. Health records, legal discovery, defence work, and a lot of EU public-sector procurement land here. Some of it can be solved with a signed DPA and a residency commitment; some of it genuinely cannot, and no discount rate changes that.

2. Air-gapped or VPC-only deployment. If the system runs inside a network with no egress to the public internet — or egress only to a specific allowlisted set of provider endpoints through a controlled NAT — then a gateway that lives outside that boundary is architecturally impossible, not merely undesirable. The same applies when you are serving open-weight models on your own hardware and the "providers" you are routing between are your own inference clusters. At that point the router has to live where the models live.

3. You already have a platform team who will own it anyway. This is the case people undercount, and it flips the arithmetic hardest. If you already run Kubernetes, already have on-call, already have secret management, already have a metrics pipeline and log retention, then a gateway is one more small stateless service in an existing chassis. The marginal cost is not "build and operate a gateway" — it is a few hours a month on top of infrastructure that exists regardless. We model that case separately below, because it is the one where self-hosting starts winning at realistic volumes.

4. Very high volume, where a percentage margin compounds. A managed gateway that takes a percentage of provider spend costs you nothing meaningful at $1,000/month and real money at $300,000/month, while the engineering effort to run one yourself is roughly flat across that range. This is the pure cost case, and it is the one the model below is built to size.

A fifth case that is not really about the gateway. If your motivation is running open-weight models locally rather than calling hosted APIs, the gateway question is downstream of a bigger decision. Start with the open-weight model field and local serving options instead — we have not benchmarked any locally-run model, so we have no first-party numbers to offer you there.

What you take on when you self-host

An open-source LLM gateway is not a library you import. It is a service that sits on the critical path of every request your product makes, which means it inherits every operational obligation of a service on the critical path. The list below is what changes hands.

ResponsibilityWhat it actually costs youFrequency
Compute and HAAt least two instances behind a load balancer, because a single-instance gateway is a single point of failure for your whole productContinuous
Provider key managementStoring keys, scoping them, rotating them on a schedule, revoking on staff change, keeping them out of logsOngoing + incident-driven
Failover logicDeciding which errors mean retry, which mean switch provider, and which mean fail fast — and keeping that current as providers change behaviourOngoing
Usage accountingPer-key, per-model token counting that survives restarts, reconciles against provider invoices, and can be queried for chargebackContinuous
Rate limitingShared counters across instances, which means a stateful store and a decision about what happens when that store is unavailableContinuous
Provider API driftA new parameter, a renamed field, a deprecated endpoint, a model id that stops resolving — each one is an unplanned patchSeveral times a year, unscheduled
UpgradesTracking upstream releases of whatever open-source gateway you picked, testing them, rolling them out without dropping trafficMonthly-ish
ObservabilityLatency, error rate and token spend per model and per key, or you cannot answer why the bill movedBuild once, maintain always
On-callSomebody's phone rings at 03:00 when the gateway is down, because when the gateway is down, everything is downContinuous

None of these is hard in isolation. That is exactly why the cost is easy to underestimate: the build is three weeks and the operation is forever. The item that surprises teams most often is provider API drift, because it arrives unscheduled and it arrives as an outage. The item that costs most in aggregate is on-call, because it is a tax on a person rather than a line on an invoice.

Two of these have their own write-ups worth reading before you commit: rate limiting and 429 handling, which is harder than a token bucket in one process, and LLM observability, which is the part teams postpone and then need urgently the first time a bill triples.

The cost model, with assumptions named

Everything in this section is modelled, not measured. We have not run a survey of what it costs teams to operate a self-hosted gateway, and we are not going to pretend a plausible number is an observed one. What follows is arithmetic on six assumptions. They are all listed, all overwritable, and the formula at the end works with whatever you substitute.

Requests / monthProvider token spend (A4)Infrastructure (A6)Ops hours (A2+A3)Engineer-time at $96/hSelf-hosted totalManaged at 5% (A5)
100,000$167$1209 h$864$984$8.35
1,000,000$1,670$26013 h$1,248$1,508$83.50
10,000,000$16,700$90021 h$2,016$2,916$835
100,000,000$167,000$4,20060 h$5,760$9,960$8,350

Read the last two columns only — both exclude the provider token spend in column two, because you pay that either way. What is being compared is the cost of the layer, not the cost of the tokens. At every one of these four volumes, under these assumptions, buying is cheaper: 118x cheaper at 100,000 requests/month, 18x at 1M, 3.5x at 10M, and 1.2x at 100M. The ratio collapses steadily, which is the real signal — the gap is closing fast by the fourth row and it closes entirely just above it.

We wrote that paragraph knowing exactly how it reads coming from us. So here is the counterweight, and it is the more interesting result.

The platform-team case, modelled separately. If you already run on-call, secret management and a metrics pipeline, drop A2 entirely (there is no new chassis to build) and cut A3 to a flat 4 hours/month of marginal attention. Engineer-time becomes $384/month at any volume. At 10M requests that puts self-hosting at $1,284 against $835 managed — still behind, but by 1.5x rather than 3.5x. At 100M requests it puts self-hosting at $4,584 against $8,350 managed, and self-hosting wins by 1.8x. The existing-team assumption is worth more than any other single input in this model.

Where the crossover actually sits

The four-row table is a snapshot. The formula behind it is the part you should keep:

Self-hosting is cheaper when (monthly infrastructure + monthly engineer-time) is less than (margin × monthly provider spend).

Rearranged, the break-even provider spend is your monthly cost to run it yourself divided by the margin. Two variables, and the margin dominates. Using the $9,960/month self-hosted figure from the 100M-request row, rounded to $10,000 so the arithmetic stays legible:

The managed margin sets the break-even, not your request countMonthly provider spend at which self-hosting turns cheaper, if running it yourself costs $10,000/monthManaged margin 2%$500,000Managed margin 5%$200,000Managed margin 10%$100,000Managed margin 20%$50,000One scale throughout: 1 px per $1,250 of monthly provider spend. All four values are modelled, not measured.
Chart: DataLLM Lab. Modelled, not measured. Break-even = monthly self-hosted cost ÷ margin. The $10,000/month self-hosted figure comes from assumptions A1 through A6 above; substitute your own and the bars move proportionally. Method: our methodology.

The chart is the argument. At a 2% margin you need half a million dollars a month of provider spend before self-hosting pays for itself, which is a small number of companies. At 20% you need $50,000/month, which is a great many companies. Before you model anything else, find out what margin you are actually paying. If a vendor will not tell you, that is information too.

Three things move the break-even that are easy to miss:

Why you want a router either way

This part is measured, and it is the same regardless of who operates the gateway.

We ran 13 models through an executed coding benchmark in a single sitting: nine Python tasks, temperature 0, a 4,000-token ceiling, and every answer scored by running the returned code against assertions the model never sees. No partial credit, no human grader, one scored attempt per task. 10 of those 13 models scored a perfect 9/9. Among the models that scored perfectly, measured cost per 1,000 tasks ran from $0.10 to $8.83 — an 88x spread across models that were indistinguishable on correctness for this workload.

Model (all scored 9/9)Measured cost / 1k tasksAvg latencyReasoning tokens / task
Qwen3 Coder Next$0.107.0 s0
DeepSeek V4-Flash$0.1314.5 s568
Mistral Medium 3.5$0.872.9 s0
Claude Sonnet 5$1.677.2 s0
GLM 5.2$1.9912.3 s559
GPT-5.5$8.8310.5 s176

That 88x is the value a routing layer exists to capture. It does not care who owns the layer. If you route the routine half of your traffic from the $8.83 model to the $0.10 model and your quality bar holds, you have cut your provider spend far more than any gateway margin could ever have cost you — which also means you have moved the break-even in the chart above, because the margin now applies to a smaller number.

The practical order of operations follows from that: get the routing right first, then decide who operates it. Teams that do it the other way round spend three weeks building a gateway and then send every request to the same expensive default model, which is the worst of both outcomes. The mechanics of picking the routes are in the routing and failover guide, and the full 13-model field is in the coding cost benchmark.

One honest limit on that 88x: our nine tasks are short, self-contained Python problems. They are a fair test of whether cost separates models that correctness does not, and a poor test of long-horizon agentic work, where the models plainly do still separate. The usual right answer is a mix, not a single cheap default.

What is measured and what is modelled

Splitting these apart is the point of publishing numbers at all.

Measured. The benchmark figures only. Nine executed Python tasks — two_sum, valid_parentheses, merge_intervals, roman_to_int, lcs_len, flatten, top_k_words, token_bucket, parse_csv_line — at temperature 0 with a 4,000-token ceiling, scored by executing the returned code against hidden asserts in an isolated subprocess with a 12-second timeout. Retries happen up to three times on an API error and never on a wrong answer. Cost is computed: reported token counts multiplied by that model's list price. It is a measured cost, not a vendor invoice.

Modelled. Every number in the cost model and the chart. A1 through A6 are assumptions we chose. We did not survey teams, did not time a real build, and did not observe anyone's on-call load. The arithmetic on top of those assumptions is correct; the assumptions themselves are judgement. Change any one of them and the conclusion can flip — which is why they are enumerated rather than buried.

Not measured at all. Our harness is single-turn. It says nothing about long-context reasoning, multi-file refactoring, agentic or multi-turn tool use, non-Python work, or vision. The 4,000-token ceiling can truncate a verbose model and score it as a miss. And the calls go through OpenRouter's OpenAI-compatible endpoint, deliberately not through the DataLLM Lab gateway, so none of the numbers depend on our infrastructure.

Never claimed as ours. Any Gemini other than 3.6 Flash, GPT-5-mini and nano, Ollama or any locally-run model, Grok 3, Grok 4, Grok 4.5, Claude Haiku 4.5, Claude Opus 4.7, Claude Sonnet 4.6. If a number for any of those appears on this site attributed to our benchmark, it is an error and we want to hear about it.

A decision checklist

No recommendation. Work through these in order and the answer usually falls out on its own.

Try the managed side before you build the other one

One OpenAI-compatible endpoint, 300+ models, one key. If it does not fit your compliance posture or your volume, you will find out in an afternoon rather than after three weeks of building.

FAQ

What is the cheapest open-source LLM gateway to self-host?

The software is free in every case that matters, so the question does not have a useful answer. The cost of a self-hosted gateway is almost entirely engineer-time and infrastructure, not licensing. Under our modelled assumptions, engineer-time is $864 to $5,760 per month against $120 to $4,200 of infrastructure — and the software line is $0 throughout. Pick on operational fit and upstream release cadence, not on price.

At what volume does self-hosting become cheaper?

It is a spend threshold, not a volume threshold. Self-hosting wins when your monthly infrastructure plus engineer-time is less than the margin times your provider spend. At a 5% margin and a modelled $10,000/month to operate it, that is roughly $200,000/month of provider spend. At a 20% margin it is $50,000/month. If you already have a platform team, the operating cost drops to around $4,584/month at high volume and the threshold falls with it.

Did you measure any of the cost figures on this page?

One input, and only one: A4's $0.00167 per request is our measured $1.67 per 1,000 tasks for Claude Sonnet 5, and applying it to your traffic is still an assumption. Everything else that is measured on this page is benchmark output — the 88x spread, the $0.10 and $8.83 figures, the latencies and the 9/9 scores, all from 13 models run through nine executed Python tasks in one sitting. Every remaining cost figure is arithmetic on assumptions A1 through A6, which we named for exactly this reason. We did not survey teams or time a real build.

Does self-hosting a gateway mean I have to self-host the models too?

No, and conflating the two is the most common mistake in this decision. A self-hosted gateway can call the same hosted provider APIs a managed one does — you are running the routing, key management and accounting layer, not the inference. Self-hosting the models is a separate and much larger commitment involving GPUs and capacity planning, and we have no first-party numbers on locally-run models to offer.

Why should I trust a cost comparison written by a company that sells one side of it?

Partly you should not, which is why the assumptions are enumerated rather than buried — you can rebuild the whole model with your own numbers in a spreadsheet in ten minutes. The parts you can independently check are the benchmark figures, and those come from calls made through OpenRouter rather than our own gateway, precisely so they do not depend on our product. If you find an error in either the arithmetic or the assumptions, that is worth telling us.

What breaks most often on a self-hosted gateway?

Provider API drift, in our reading of the failure list: a renamed field, a deprecated endpoint, a model id that stops resolving. It arrives unscheduled and it arrives as an outage rather than as a ticket. The second is shared rate-limit state — counters that work in one process and quietly stop being correct once you run two instances for HA.

Written by

Founder of DataLLM Lab, the unified LLM gateway. Kevin tests models the boring way — same prompts, real costs, unedited outputs — and writes up what the runs actually show. Articles are drafted with AI assistance and published under his name; every first-party number comes from an executed run.

One API for every model

One API, every model.

Get a single API key for Claude Opus 4.7, GPT-5.4, and 300+ more — with automatic price comparison and routing to the best model for every request.