By API7.ai Team
Last updated: August 2026
Every team that ships LLM features ends up building the same middle layer: something that holds the provider API keys, hands out per-team credentials, enforces limits, retries failed calls, and logs token usage. You can get that layer as a SaaS, or you can run it yourself. This guide is for the second option: what an LLM gateway actually does, why platform teams self-host one, what to evaluate, and an honest survey of six self-hostable open-source options — AISIX, LiteLLM, Bifrost, Portkey Gateway, TensorZero (now archived), and Higress.
Self-host an LLM gateway when provider keys, prompts, and completions must stay inside your network, when you can’t accept a per-request third-party dependency, or for compliance and latency. Six open-source projects cover the space — AISIX, LiteLLM, Bifrost, Portkey Gateway, TensorZero (archived June 2026), and Higress — and they genuinely optimize for different constraints. The honest trade-off: you now operate it.
An LLM gateway (also called an AI gateway or LLM proxy) sits between your applications and model providers. In practice, the layer covers six jobs: credential separation, rate and token limits, routing and failover, caching, observability, and guardrails.
Increasingly there is a seventh job: agent traffic. Agents call tools over MCP (Model Context Protocol) and other agents over A2A, and that traffic needs the same keys, limits, and logs as chat completions. Some gateways now govern all three through one control point.
Four reasons come up consistently with platform teams: credentials stay in your infrastructure, no per-request third-party dependency, compliance, and latency.
The honest trade-off: you now operate it. Upgrades, TLS, and high availability are your problem — the FAQ below covers the standard patterns, and they are well-trodden.
Six dimensions separate the options in practice: deployment weight, wire compatibility, governance depth in the open-source tier, agent-protocol support, observability exports, and license stability.
| Dimension | What to check | Why it matters |
|---|---|---|
| Deployment weight | What must run around the gateway: a single container with a config file, a database for key management, a cache for shared state, or a full Kubernetes control plane | None of these shapes is wrong — a database-backed gateway buys you a management UI and API-driven config — but the weight should match your team. Patching a five-service stack is a different commitment than redeploying one container. |
| Wire compatibility | The OpenAI chat-completions API is table stakes. Does it also accept the Anthropic Messages API (/v1/messages) natively, and can it translate either wire format to any backend? | Claude-based agent tooling speaks Anthropic’s format, and a gateway that translates both directions lets you point any SDK at any provider without code changes. |
| Governance depth in the OSS tier | Read the feature list twice: once for what the product does, once for which tier does it. Common lines: caller/virtual keys and rate limits in open source, with guardrails or clustering in an enterprise edition | There is nothing wrong with a commercial line — most projects here have one somewhere — but you want to know where it is before you standardize. |
| Agent-protocol support | An MCP gateway (registering upstream MCP servers behind one governed endpoint, with per-caller tool access) and A2A support — and whether they sit behind the same keys, limits, and logs as LLM traffic or form a separate system | If agents are on your roadmap, agent traffic needs the same governance as chat completions. |
| Observability exports | What the open-source tier exports, and whether cost/usage data is included | Prometheus metrics and OTLP trace export are the portability baseline — they feed Grafana, Langfuse, Honeycomb, Datadog, or anything else without lock-in. |
| License stability | The actual LICENSE file, not the marketing page | All six projects below carry OSI-approved licenses today (Apache-2.0 or MIT), but the structures differ: some repos are uniformly licensed, one carves an enterprise/ directory under a separate commercial license inside the same repo, and one is currently merging its enterprise gateway into open source. |
Disclosure: this guide is published by API7.ai, the company behind AISIX; facts about the other five projects are drawn from their official READMEs, docs, and LICENSE files. Star counts were fetched from the GitHub API on 2026-08-21 — treat them as order-of-magnitude.
| Dimension | Language | License | Minimal self-hosted shape |
|---|---|---|---|
| AISIX | Rust | Apache-2.0 | One container; one declarative resources.yaml for all dynamic resources; no database or control plane |
| LiteLLM | Python | MIT (separate license for enterprise/) | pip or Docker; Postgres required for virtual keys |
| Bifrost | Go | Apache-2.0 | npx or Docker, built-in web UI |
| Portkey Gateway | TypeScript | MIT | npx / Node.js / Docker / Cloudflare Workers |
| TensorZero | Rust | Apache-2.0 | One container; ClickHouse optional, for observability |
| Higress | Go (Envoy/Istio) | Apache-2.0 | Docker all-in-one locally; Helm on Kubernetes |
AISIX is a Rust gateway from API7.ai, built by the original creators of Apache APISIX and shipped as a single static binary under Apache-2.0. It accepts both the OpenAI wire format and the Anthropic Messages API (POST /v1/messages) as first-class routes and translates either — streaming included — to five native adapter families: OpenAI (which covers any OpenAI-compatible endpoint such as vLLM, Ollama, or DeepSeek), Anthropic, AWS Bedrock, Google Vertex (Gemini), and Azure OpenAI.
Language
Rust
License
Apache-2.0
Minimal shape
One container; one declarative resources.yaml for all dynamic resources; no database or control plane
LiteLLM is the project with the largest GitHub-star count among those surveyed and its ecosystem breadth is a genuine strength. It provides one OpenAI-format interface to 100+ LLM providers, usable as a Python SDK or as a proxy server, and per its README the proxy ships virtual keys, spend tracking, guardrails, load balancing, and an admin dashboard out of the box — a notably generous open-source tier.
Language
Python
License
MIT (separate license for enterprise/)
Minimal shape
pip or Docker; Postgres required for virtual keys
GitHub stars
Roughly 56.9k as of August 2026
Bifrost, from Maxim AI, is a Go gateway under Apache-2.0 that unifies 23+ providers behind an OpenAI-compatible API. Its developer experience is a strength: it starts with a single npx command or Docker container, includes a built-in web UI for configuration and monitoring, and offers drop-in base_url replacement for the OpenAI, Anthropic, and Google GenAI SDKs.
Language
Go
License
Apache-2.0
Minimal shape
npx or Docker, built-in web UI
GitHub stars
Roughly 7.5k as of August 2026
Portkey’s open-source gateway is a TypeScript project under MIT, positioned as a lightweight router to 250+ LLMs. It runs via npx, Node.js, Docker, or Cloudflare Workers, giving it a documented edge-runtime deployment path.
Language
TypeScript
License
MIT
Minimal shape
npx / Node.js / Docker / Cloudflare Workers
GitHub stars
Roughly 12.8k as of August 2026
github.com/tensorzero/tensorzero
TensorZero is a Rust, Apache-2.0 project with a deliberately different scope: it is an LLMOps platform that unifies a gateway with observability, evaluation, optimization, and experimentation. The gateway itself deploys as a single Docker container and works with any OpenAI SDK. Note: the tensorzero/tensorzero repository was archived on GitHub in June 2026 and is read-only — the project is no longer maintained.
Language
Rust
License
Apache-2.0
Minimal shape
One container; ClickHouse optional, for observability
GitHub stars
Roughly 11.7k as of August 2026
github.com/higress-group/higress
Higress is a different animal: a cloud-native API gateway built on Istio and Envoy, originated at Alibaba and now a CNCF sandbox project under Apache-2.0. Its AI gateway capabilities arrive as Wasm plugins on top of a full Kubernetes ingress controller with a console UI.
Language
Go (Envoy/Istio)
License
Apache-2.0
Minimal shape
Docker all-in-one locally; Helm on Kubernetes
GitHub stars
Roughly 9.2k as of August 2026
Deployment weight is easiest to judge with a concrete example. This is AISIX’s quickstart, verbatim from its README: “One container. No control plane, no database, no configuration store — the gateway reads every dynamic resource from one declarative resources.yaml.”
config.yaml — static gateway settings
# config.yaml
resources_file: /etc/aisix/resources.yaml
proxy:
addr: "0.0.0.0:3000"
admin:
enabled: false # a declarative gateway needs no admin listener
observability:
metrics:
prometheus:
enabled: true
addr: "0.0.0.0:9090"resources.yaml — every dynamic resource, declaratively
# resources.yaml
_format_version: "1"
provider_keys:
- display_name: openai-main
provider: openai
api_key: ${OPENAI_API_KEY} # interpolated from the environment
models:
- display_name: my-model
provider: openai
model_name: gpt-4o-mini
provider_key: openai-main
api_keys:
- display_name: local-dev
key_env: CALLER_API_KEY # hashed at load; the plaintext is never stored
allowed_models: ["my-model"]Run it — one container
export OPENAI_API_KEY="YOUR_PROVIDER_KEY"
export CALLER_API_KEY="YOUR_CALLER_KEY"
docker run -d --name aisix \
--platform linux/amd64 \
-v "$(pwd)/config.yaml:/etc/aisix/config.yaml:ro" \
-v "$(pwd)/resources.yaml:/etc/aisix/resources.yaml:ro" \
-e OPENAI_API_KEY -e CALLER_API_KEY \
-p 3000:3000 -p 127.0.0.1:9090:9090 \
ghcr.io/api7/aisix:latest # proxy → :3000, metrics + status → :9090
# ^ the metrics/status listener is unauthenticated;
# keep it on loopback or a private networkThen call the gateway exactly like OpenAI
curl http://localhost:3000/v1/chat/completions \
-H "Authorization: Bearer $CALLER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"my-model","messages":[{"role":"user","content":"hello"}]}'Edit resources.yaml and send SIGHUP (docker kill -s HUP aisix) to apply changes with no restart — an invalid file is rejected whole and the last good configuration keeps serving. For a multi-replica cluster, the same binary points at etcd instead of a file. Full walkthrough in the gateway quickstart.
There is no single winner here — the projects genuinely optimize for different constraints. A reasonable evaluation is an afternoon each with your two shortlisted options: deploy the minimal shape, point one real service at it, kill a provider key mid-stream, and read the logs it produced.
Self-hosting the LLM middle layer keeps credentials, prompts, and availability under your control; the cost is operating one more service, and the patterns for TLS, HA, and upgrades are well-trodden.
AISIX brings dual OpenAI/Anthropic protocols, semantic and ensemble routing, the full OSS guardrail set, and LLM, MCP, and A2A gateway endpoints into one Apache-2.0 static binary — github.com/api7/aisix — and the documentation walks from the quickstart above through guardrails, MCP, and observability setup. For the product overview, see AISIX AI Gateway.
AISIX vs LiteLLM · LiteLLM alternatives · All AI gateway comparisons
Ready to get started?
For more information about full API lifecycle management, please contact us to Meet with our API Experts.

