8 min read
Open Source AI Gateway Comparison: Routing, Guardrails, Token Control, and Ops
by Toni Pinel

An open source AI gateway is a software layer that manages application requests to AI models under an open source license.
A production gateway must combine routing, security, token controls, observability, and reliable deployment without hiding licensing or operational dependencies.
This open source AI gateway comparison examines four projects and shows how to verify each capability before choosing production infrastructure.
McKinsey’s 2026 State of AI survey found that 20% of respondents at organizations regularly using AI reported usage constraints from operating costs, including tokens.
That figure describes AI cost pressure, not the market share of open source AI gateways.
What Is an Open Source AI Gateway?
An AI gateway is an intermediary that routes AI traffic and applies shared access and operational policies.
An LLM proxy is a component focused on forwarding and, where supported, normalizing language-model API requests.
An inference gateway is a routing layer that may also select among servers running models.
Open Source, Self-Hosted, and Enterprise: Key Differences
An open source license is a license granting rights to use, modify, and redistribute software under its stated conditions.
Self-hosting is operating software on infrastructure controlled by the organization, regardless of whether its license is open source.
An Enterprise edition is a commercial distribution or feature set that can extend an open source foundation.
- License: inspect the repository’s actual license and the applicable release.
- Edition: distinguish open source functions from commercial features and hosted services.
- Dependencies: record databases, classifiers, caches, controllers, and external APIs.
Self-hosting a gateway does not guarantee local inference. Prompts may still travel to external model providers.
Which Open Source AI Gateways Should You Compare?
A release baseline is the exact version or commit used for a technical comparison.
A feature entitlement is permission to use a capability under the relevant license or commercial agreement.
Use one baseline per product. The following shortlist compares project scope, not verified superiority.
Projects, Licenses, and Production Boundaries
- LiteLLM: MIT-licensed proxy core for model access, routing, virtual keys, and usage tracking. Verify database dependencies and Enterprise-only identity features.
- Portkey Gateway: MIT-licensed gateway with routing, retry, fallback, and guardrail integrations. Treat Gateway 2.0 prerelease features separately from stable releases.
- Bifrost: Apache-2.0 gateway with model abstraction, virtual keys, and usage controls. Check which advanced governance and availability functions require Enterprise.
- Agent Router: Apache-2.0 Envoy-based project, formerly Envoy AI Gateway, for model routing and policy controls. Check standalone and Kubernetes deployment needs.
Provider abstraction is a common application interface for multiple model providers, subject to differences in supported operations.
For each candidate, document routing, guardrails, token enforcement, telemetry, GitOps, edition, and test evidence.
How Does Multi-Model Routing Work?
Multi-model routing is the selection of an authorized model or provider for an inference request.
Policy-based routing is model selection driven by verified identity, application rules, or validated request attributes.
A fallback route is the route used when earlier selection conditions do not match.
Failover is a recovery action attempted when a selected provider or classifier fails. Fallback and failover solve different problems.
Streaming is the incremental delivery of model output before generation has fully finished.
Routing and Reliability Acceptance Tests
- Authorization: reject attempts to select restricted models using untrusted headers.
- Compatibility: test chat, embeddings, tool calls, and streaming independently.
- Failures: simulate unavailable providers and unmatched routing conditions.
- Streaming recovery: inspect incomplete responses and risks from retrying operations.
KrakenD Enterprise documents AI Router with ordered routes, policy gates, classifiers, and configured failover.
The routing feature is an Enterprise AI Gateway capability, not a Community Edition AI module.
How Should You Evaluate AI Guardrails and Security?
An AI guardrail is a check that permits, blocks, or modifies AI traffic according to defined policies.
Prompt injection is an attempt to change an AI application’s behavior through instructions embedded in untrusted content.
Input inspection is the evaluation of an AI request before it reaches the model.
Output validation is the assessment of a generated response against format or security requirements.
Tenant isolation is the separation of permissions and data between organizations sharing infrastructure.
A false positive is a legitimate request incorrectly blocked by a security control.
- Identity: authenticate callers and restrict model and tool access by tenant.
- Coverage: test known attacks, legitimate prompts, and incorrectly blocked requests.
- External checks: document classifier latency, failures, and data exposure.
- Responses: verify masking or schema validation separately from input screening.
The OWASP LLM Top 10 2026 identifies prompt injection, sensitive information disclosure, and unbounded consumption among key risks.
KrakenD Enterprise Prompt Guard checks incoming requests using patterns, CEL policies, and optional external classifiers.
Additional AI governance controls can address response policies. Guardrails cannot guarantee complete protection.
What Are Token Quotas, Rate Limits, and AI Budgets?
A rate limit is a restriction on the number of requests allowed within a defined interval.
A token quota is an allowance for measured input, output, or total token consumption.
A spending budget is a monetary limit or target calculated using applicable model pricing.
Token accounting is the measurement and attribution of model consumption to users, applications, or tenants.
Post-response accounting is the recording of consumption after the model returns usage information.
- Accuracy: compare gateway usage records with provider-reported tokens.
- Attribution: verify model, user, and tenant identifiers.
- Concurrency: send simultaneous requests when little quota remains.
- Billing: distinguish estimated model costs from final invoices.
Post-response accounting can overshoot the remaining quota on the last permitted request. A quota is not necessarily a hard cost ceiling.
KrakenD Enterprise provides AI token cost control and usage governance with configurable limits.
What Does LLM Observability Need to Measure?
LLM observability is the measurement of AI request behavior, provider selection, reliability, and consumption.
Distributed tracing is the linking of request operations across services to reveal their execution path.
Time to first token is the interval between initiating a model request and receiving its first generated token.
Gateway overhead is the additional processing and network delay associated with the gateway, separate from model inference.
- Latency: measure p50, p95, and time to first token under equivalent conditions.
- Failures: track provider errors, timeouts, and failover outcomes.
- Policy: count guardrail decisions and quota rejections.
- Privacy: avoid recording sensitive prompts unless strictly required.
OpenTelemetry defines conventions for generative AI telemetry, but the available attributes depend on instrumented components.
KrakenD supports OpenTelemetry for API traffic and documents AI backend monitoring.
How Do GitOps and Deployment Affect AI Gateway Selection?
GitOps is a workflow that manages desired configuration through version control and automated deployment or reconciliation.
Declarative configuration is a description of the intended system state rather than a sequence of manual changes.
An immutable release is a deployment artifact whose contents are not changed after creation.
An air-gapped deployment is an environment isolated from external networks under a defined connectivity policy.
Production Deployment Checklist
- 1. Pin: record gateway version, dependencies, and configuration schema.
- 2. Validate: check configuration and policy rules before release.
- 3. Protect: inject secrets outside source-controlled manifests.
- 4. Test: exercise routing, guardrails, quotas, and provider outages.
- 5. Deploy: release a reproducible artifact and monitor errors.
- 6. Recover: test rollback to a known working configuration.
Air-gapped operation also requires locally reachable inference services and compatible supporting components.
KrakenD documents CI/CD validation and deployment for configuration-driven releases.
How Do You Benchmark AI Gateways Fairly?
A performance benchmark is a controlled measurement performed under disclosed workload and infrastructure conditions.
An acceptance test is a reproducible check that establishes whether a required behavior meets a defined threshold.
p95 latency is the response duration at or below which 95% of measured requests finish.
Five Tests for Production Readiness
- Performance: compare p95 latency, throughput, and resource consumption.
- Routing: verify authorization and model-selection accuracy.
- Safety: evaluate detection and false-positive rates on labeled prompts.
- Consumption: compare token accounting and concurrent quota behavior.
- Recovery: inject outages and verify failover and configuration rollback.
Use the same models, prompts, concurrency, network paths, and enabled controls. Proxy-only benchmarks do not establish guarded production performance.
Practical Example: Multi-Tenant Model Routing
A tenant is an organization or customer sharing a platform while retaining distinct permissions and usage policies.
Consider a support platform with two model providers and different allowances for each customer organization.
- Requirement: tenants access only approved models and tools.
- Route: verified identity determines the selected provider.
- Protect: prompt checks and downstream permissions enforce policy.
- Measure: traces associate latency and usage with each tenant.
- Test: deny restricted models, exhaust a quota, and simulate an outage.
Success means predictable behavior across normal traffic and failures. It does not mean every open source distribution includes every control.
When Is Open Source Enough, and Where Does KrakenD Fit?
An open source gateway may be sufficient when its verified capabilities, dependencies, and support model satisfy production requirements.
An Enterprise option becomes relevant when tested gaps justify additional licensing, support, or integration costs.
KrakenD Community Edition vs. Enterprise AI Gateway
KrakenD Community Edition is an open source API gateway with general routing, security components, and observability.
Its specialized AI Gateway functions are not part of Community Edition.
KrakenD Enterprise AI Gateway adds an LLM interface, AI Router, Prompt Guard, and token governance.
Access depends on the relevant Enterprise license entitlements.
KrakenD combines API and AI traffic controls within declaratively configured gateway infrastructure. Compare its behavior using the same acceptance tests.
Review the Enterprise AI Gateway documentation before evaluating an implementation.
Frequently Asked Questions About Open Source AI Gateways
Can an AI Gateway Work with RAG Applications?
Yes. An AI gateway can govern LLM requests from retrieval-augmented generation (RAG) applications. Retrieval, indexing, and source verification remain separate responsibilities.
Can You Migrate from Direct LLM APIs Without Rewriting an App?
Sometimes. Compatible endpoints may limit code changes, but model operations, authentication, streaming, and tool schemas still require testing.
Does an AI Gateway Replace Model Hosting?
No. An AI gateway governs access to inference services. Models still run through hosted providers or separately operated inference infrastructure.
Conclusion: Compare Verified Capabilities, Not Labels
Choose an AI gateway through a repeatable sequence: define requirements, verify license scope, test controls, measure behavior, and assess operations.
Routing, guardrails, token control, observability, and GitOps only deliver value when they operate reliably together.
KrakenD Enterprise is a self-hosted option for integrated API and AI governance, while KrakenD Community Edition remains a distinct open source API gateway.