Why run a separate Python proxy for AI models in Kubernetes when all your other traffic already flows through Gateway API and GitOps? Spinning up LiteLLM in five minutes for a couple of services works fine at first. Once dozens of pods and AI agents start calling models, you end up managing a parallel stack: its own database, separate secrets, a manual admin UI, and an extra hop on streaming responses.
agentgateway solves this—it's an Apache 2.0 Rust gateway that moves model access, token limits, and guardrails straight into Kubernetes manifests.
Why LiteLLM Feels Cramped in Kubernetes and Where agentgateway Fits
Teams like LiteLLM for its quick start: hundreds of providers out of the box and a ready-made key management UI. The friction shows up at cluster scale. You have to upgrade, monitor, and secure a standalone Python app and its database outside your normal network stack.
agentgateway (v1.8.1, 6,573 stars) takes a different route. Born out of kgateway (an Envoy-based gateway with 5.7K stars) in the Agentic AI Foundation and Solo.io ecosystem, it runs in Rust with minimal streaming overhead. You can run it standalone via YAML or as a controller on top of Kubernetes Gateway API (GatewayClass, Gateway, and HTTPRoute instead of Ingress).
Beyond LLM APIs (OpenAI, Anthropic, Gemini, Bedrock, Realtime, and local inference with KV-cache and GPU awareness), it natively understands MCP (stdio, HTTP, SSE, Streamable HTTP) and A2A. Paired with the kagent orchestrator (4.6K stars), it secures outbound traffic by validating OAuth and JWTs and enforcing CEL-based RBAC on MCP tools.
Model Access, Token Limits, and Guardrails in Manifests
Provider API keys stay in a standard Kubernetes Secret, while models are exposed via AgentgatewayModel (agentgateway.dev/v1alpha1). Agents send requests to one Gateway and never touch raw keys.
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayModel
metadata:
name: openai
namespace: agentgateway-system
spec:
# Bind the model to the Gateway API proxy
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: agentgateway-proxy
sectionName: http
match:
model: "openai/*"
provider: OpenAI
policies:
# Pull the API key from a Secret so it never enters app code
auth:
secretRef:
name: openai-secret
# Strip the routing prefix before forwarding to OpenAI
transformations:
- field: model
expression: 'llmRequest.model.stripPrefix("openai/")'
Swapping providers, P2C load balancing, and failover to a backup model happen via a Git commit with zero service code changes.
Plain HTTP request limits won't protect an LLM budget—one massive prompt can burn a daily allowance. That is why AgentgatewayPolicy rate-limits tokens directly.
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
name: llm-token-budget
namespace: agentgateway-system
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: HTTPRoute
name: openai
traffic:
rateLimit:
# Local in-memory token counter inside the proxy
local:
- tokens: 10000
unit: Minutes
For shared budgets by x-user-id or virtual keys, use traffic.rateLimit.global with a rate-limit-server. Cost control works in three layers: key attribution (forwarding into AWS/GCP billing), dollar tracking with a Cost Dashboard, and hard caps. Metrics, logs, and traces flow straight to OpenTelemetry out of the box.
promptGuard filters scrub prompts and responses using regex, PII/DLP, OpenAI Moderation, Bedrock Guardrails, Model Armor, or webhooks.
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
name: openai-prompt-guard
namespace: agentgateway-system
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: HTTPRoute
name: openai
backend:
ai:
promptGuard:
# Block attempts to override the system prompt
request:
- regex:
action: Reject
matches:
- "(?i)(ignore|forget|override)\\s+previous\\s+instructions"
response:
message: "Request blocked: prompt injection detected."
statusCode: 403
When a rule triggers, the gateway returns 403 immediately so suspicious requests never spend provider quota.
Where the Limits Are and When LiteLLM Is Simpler
Even at v1.8.1, the CRDs (AgentgatewayModel and AgentgatewayPolicy) are still v1alpha1, meaning field schemas can change across upgrades. The learning curve is steeper too: you need Gateway API familiarity plus a separate rate-limit-server for global budgets.
If you run on a single server without Kubernetes or rely heavily on a web admin UI for API keys, staying on LiteLLM is simpler. Switching to agentgateway pays off when Kubernetes and GitOps are already your foundation, agents (like kagent) run in production, and you want one unified perimeter for models, budgets, guardrails, and MCP.


