← Blog

Self-Hosted LLM API Gateway Options: A Practical Guide

2026-11-12 · 5 min read · SubToAPI Team

What "self-hosted LLM API gateway" actually means

A self-hosted LLM API gateway is a server you deploy and operate yourself that sits between your application and one or more LLM providers (Claude, OpenAI, local models, etc.). It typically handles authentication, request routing, rate limiting, logging, and sometimes response caching or streaming normalization. You run it on your own infrastructure — a VM, a Kubernetes cluster, or a container platform — rather than calling a third-party gateway endpoint.

If you're searching for options, you're probably trying to decide between three paths: build a thin proxy yourself, deploy one of the existing open-source gateways, or skip self-hosting entirely and use a managed service. This article covers the real options in each category, what they cost in engineering time, and the situations where each makes sense.

Option 1: Build a minimal proxy yourself

For a single provider and a small team, a self-hosted gateway can be 150 lines of code: an Express or FastAPI server that accepts requests, attaches your provider API key, forwards the call, and logs usage to a database.

app.post('/v1/messages', async (req, res) => {
  const upstream = await fetch('https://api.anthropic.com/v1/messages', {
    method: 'POST',
    headers: {
      'x-api-key': process.env.ANTHROPIC_KEY,
      'anthropic-version': '2023-06-01',
      'content-type': 'application/json',
    },
    body: JSON.stringify(req.body),
  });
  const data = await upstream.json();
  logUsage(req.user, data.usage);
  res.json(data);
});

This works until you need streaming passthrough, per-key rate limits, retries with backoff, multi-provider routing, or team billing. Each of those adds real engineering surface: SSE handling, a token bucket implementation, a provider abstraction layer, and a seat-based billing system. Most teams underestimate this by a lot — the proxy itself is easy, the operational features around it are not.

Option 2: Deploy an existing open-source gateway

Several open-source projects exist specifically to be self-hosted in front of LLM providers. Typical capabilities across them include:

Deploying one of these means running a container, configuring a database for logs and keys, setting up TLS termination, and maintaining the deployment as the project updates. This is a legitimate path if you have the infrastructure team to own it — but it moves the operational burden from "calling an API" to "running a stateful service with a database, uptime requirements, and version upgrades."

Before choosing this route, check:

Option 3: Kubernetes-native API gateways with LLM plugins

If you're already running Kong, Envoy, or a service mesh, you can add LLM-specific plugins or filters for rate limiting and key injection. This fits well if LLM traffic is a small slice of a much larger API surface you already gateway through Kubernetes. The downside is that LLM-specific concerns — streaming semantics, token-based rate limits instead of request-based ones, usage metering per model — are often secondary features bolted onto a general-purpose gateway, not first-class citizens.

When self-hosting is the right call

Self-hosting makes sense when:

When it isn't worth it

For most teams below enterprise scale, the honest trade-off looks like this: self-hosting a gateway buys you infrastructure control in exchange for ongoing engineering time spent on TLS certs, database backups, dependency upgrades, incident response, and feature parity with whatever the provider ships next. If your actual goal is "turn my Claude access into a clean HTTPS API with keys, streaming, and usage tracking," a managed service gets you there without the operational tail.

This is the gap SubToAPI fills. It gives you application API keys (sub_live_...), streaming, tool use, and per-key usage metadata through a hosted dashboard — no server to patch, no database to back up. Pricing is per-seat (Solo €9, Team €19/seat, Scale €49/seat) with a free trial at /signup, so you can compare the actual cost against the engineering hours a self-hosted option would consume. If you're prototyping, start with the quickstart and the Messages and streaming docs to see how much is already handled.

A practical decision checklist

  1. Count the engineering hours a self-hosted gateway needs for setup, monitoring, and upgrades over 12 months.
  2. List the specific provider features you need (tool use, streaming, long context) and confirm your chosen gateway supports all of them, not a subset.
  3. Decide who's on-call when the gateway goes down — because now it's your outage, not the provider's.
  4. Compare against managed pricing per seat or per request, including the hidden cost of your own time.

If the checklist points toward "we have the team and the reason," pick an open-source gateway and own it properly. If it points toward "we just need reliable API access without running infrastructure," a managed gateway is the faster and often cheaper path.

questions

Is a self-hosted LLM gateway more secure than a managed one? Not inherently. Security depends on patching speed, access controls, and key handling — a well-maintained managed service can be more secure than a self-hosted gateway nobody has time to update.

Can I switch from a self-hosted gateway to a managed one later? Yes, if your application code talks to a gateway through a stable interface (REST endpoints, standard headers), swapping the backend is mostly a configuration change, not a rewrite.

Do self-hosted gateways support streaming responses well? It varies by project — SSE proxying under concurrent load is harder to get right than basic request forwarding, so test streaming behavior under realistic traffic before committing.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →