On-premises AI
Building an Enterprise AI Gateway for On-Premises Model Orchestration
How to design a central AI gateway for on-premises models: one API, identity, quotas, routing, guardrails and audit logging in front of every model you run.
In short
An enterprise AI gateway is the single entry point between applications and every model an organisation runs. It authenticates callers, applies quotas and token rate limits, routes each request to the right model with fallbacks, runs input and output guardrails, and records usage and audit logs, so models and engines can change without changing the applications.
Key takeaways
- Applications call one OpenAI-compatible endpoint; the gateway decides which model and engine serve each request.
- Identity, quotas, token rate limits, routing, fallbacks, guardrails and audit logging belong in the gateway, not in every application.
- An open-source AI proxy such as LiteLLM, an API gateway with AI features such as Kong AI Gateway, or a custom build can all work; choose by policy needs and the skills of the team that will run it.
- Guardrails reduce prompt-injection risk but cannot remove it. OWASP notes it is unclear whether fool-proof prevention exists, so also limit what models and tools are allowed to do.
- Treat routing rules, quotas and guardrail settings as versioned configuration with review and rollback.
Why do on-premises AI platforms need a gateway?
Without a gateway, every team that deploys a model also builds its own endpoint, authentication, logging and limits. Within months, an organisation can have a dozen model endpoints that nobody governs as a whole.
That sprawl causes problems at every level. Security teams cannot review model access consistently. Platform engineers cannot share GPUs across workloads or see who uses what. Developers integrate with several APIs that authenticate, fail and log differently. And when a model has to be retired or replaced, there is no single place to redirect traffic.
An AI gateway solves this by becoming the single entry point between applications and model serving. It handles the concerns that every model call shares, such as identity, limits, routing, guardrails and logging, so that applications and inference engines do not each implement them. In our on-premises AI reference architecture, applications call the gateway and never an inference engine directly.
What does an AI gateway do?
A gateway gives applications one stable API and applies the organisation’s rules to every request on its way to and from a model.
- One API for every model. The gateway exposes an OpenAI-compatible API, so the same application code can call a different model, engine or location tomorrow. LiteLLM, for example, offers one OpenAI-compatible endpoint for many providers and can route to a self-hosted vLLM server as an OpenAI-compatible backend.
- Identity and access. It validates the caller’s single sign-on token or key and checks which models that user, team or service may use. In LiteLLM, each virtual key carries its own allowed models, budgets and rate limits.
- Quotas and rate limits. It caps tokens per minute, requests per minute and parallel requests per key, user or team, and enforces spending budgets, so that one consumer cannot take over shared GPUs.
- Routing and fallbacks. It sends each request to the right model and replica, retries or falls back when a deployment has a problem, and can send part of the traffic to a new model version as a canary.
- Guardrails. It runs checks on inputs before they reach a model and on outputs before they reach the user.
- Metering and audit. It records usage per request and team, and exports logs and metrics to the observability stack.
Our private LLM page describes the gateway as part of a private model service for employees.
Which policies should the gateway enforce from day one?
Five policies pay off immediately: identity on every request, routing by data class, quotas, guardrails and audit logging.
Identity and model access. Tie every request to a user, service account or agent identity from your identity provider. Not every team needs every model: a customer-facing assistant should not be able to reach an unrestricted base model meant for internal experiments.
Routing by data class. In a hybrid setup, the gateway is where you enforce that requests containing personal or confidential data go only to models running on infrastructure you control, while low-sensitivity requests may use an external API.
Quotas and limits. Set token rate limits and budgets per team from your capacity plan. The gateway should queue or reject requests above quota rather than overload the inference engines. Our post on rate limiting and backpressure covers the queueing design, and GPU chargeback and quotas covers allocating costs.
Guardrails. Check inputs for prompt-injection patterns, secrets and personal data, and check outputs before they are shown or passed to tools. OWASP’s guidance on prompt injection recommends layered controls: constrained instructions, validated output formats, input and output filtering, least privilege for connected tools, human approval for high-risk actions and clear separation of untrusted content. It also notes that it is unclear whether fool-proof prevention exists. Gateways help here: LiteLLM and Kong AI Gateway, for example, both offer content filtering and personal-data masking, and dedicated guardrail toolkits can add checks for retrieval and tool calls. Before adopting any open-source toolkit, check that it is still actively maintained. Our AI security work covers the controls beyond the gateway.
Audit logging. Record who called which model and version, when, with which routing and guardrail decisions. Store prompt and response content only where policy allows, with restricted access and a retention period. If a system is high-risk under the EU AI Act, its deployer must keep the logs it generates automatically for at least six months, unless other law provides otherwise.
How do you choose between gateway options?
There are three workable routes. The right one depends on how much AI-specific functionality you need ready-made and on what your team already operates.
| Option | Fits when | Watch for |
|---|---|---|
| Open-source AI proxy, such as LiteLLM | You want an OpenAI-compatible API, per-key budgets and limits, fallbacks and logging without building them | Which features are in the open-source edition; how you run it with high availability; its release pace |
| API gateway with AI features, such as Kong AI Gateway | You already operate the gateway and want one control plane for APIs and models; Kong supports self-hosted deployment | Licensing of the AI features you need; how token accounting and streaming behave |
| Custom-built gateway | Routing, integration or performance needs that existing options cannot meet | The engineering and maintenance effort, and a security review of every feature you build |
Whichever you choose, check that every policy above can be expressed in configuration you can version and review.
How should the gateway handle AI traffic?
Model traffic behaves differently from ordinary API traffic, and the gateway’s defaults need to reflect that.
- Variable request cost. A request that generates 10 tokens costs far less than one that generates 2,000. Route on current load, such as active requests per replica, rather than round-robin.
- Streaming. Token streaming keeps connections open for the whole answer. Set timeouts for streaming routes separately from those for short API calls, and make sure connection pools are sized for long-lived connections.
- Batching. Leave batching to the inference engine, which batches requests itself; holding requests in the gateway only adds latency. Our explainer on LLM inference serving explains why.
- Caching. Kong AI Gateway, for example, can serve repeated or near-duplicate prompts from a semantic cache. Use such caches carefully: scope them by tenant and data source, so that one user never receives an answer built from documents they may not see, and invalidate them when the source documents change.
- Degradation. Decide per consumer what happens when a model is unavailable: fall back to a smaller model, queue the request or fail clearly. Some applications should fail rather than return a weaker answer. Our post on intelligent model routing covers routing logic in more depth.
How do you run the gateway reliably?
Once all model traffic flows through it, the gateway is on the critical path, so run it like one.
- Run at least two stateless replicas behind a load balancer, and test what happens when one fails.
- Keep routing rules, quotas, model lists and guardrail settings in version control. Review, stage and roll back changes like code, because a misconfiguration can silently send traffic to the wrong model or switch off a guardrail.
- Protect the gateway’s credentials for the inference engines and any external providers in a secrets vault, and restrict its administrative interface.
- Monitor the gateway separately from the models: the latency it adds, errors, rejections by quota or guardrail, configuration reloads and usage per team.
The usage data the gateway records also answers the cost question. Token volumes per use case are the inputs the on-prem vs cloud AI cost calculator needs to compare running models yourself with paying an API per token.
Featured image by Albert Stoynov on Unsplash.
Frequently asked questions
What is an AI gateway?
An AI gateway is a service that sits between applications and language models. Applications send every model request to it, usually through an OpenAI-compatible API. The gateway checks who is calling, applies quotas and policies, chooses a model, falls back when that model is unavailable, runs guardrails and records usage. It lets an organisation change models without changing the applications.
Is an AI gateway the same as an API gateway?
Not quite. An API gateway handles general HTTP concerns such as routing, authentication and rate limits. An AI gateway adds model-specific functions: token-based limits and budgets, routing between models with fallbacks, prompt and output guardrails, and metering per token. Some API gateways add these through AI features; Kong AI Gateway, for example, supports self-hosted deployment.
Can LiteLLM run as an on-premises AI gateway?
Yes. LiteLLM describes its AI Gateway as a self-hosted server that gives one OpenAI-compatible endpoint for many model providers, and it can route to a self-hosted vLLM server. It offers virtual keys with their own models, budgets and rate limits, records the cost of each request, supports load balancing, fallbacks and retries, and sends logs and metrics to tools such as OpenTelemetry and Prometheus.
Do gateway guardrails stop prompt injection?
They reduce the risk but cannot eliminate it. OWASP's guidance on prompt injection says it is unclear whether fool-proof prevention exists, and recommends layered controls: constrained instructions, validated output formats, input and output filtering, least privilege for any connected tools, human approval for high-risk actions and clear separation of untrusted content. Guardrails are one layer among several.
What should an AI gateway log?
Log structured metadata for every request: caller, team, model and version, timings, token counts, routing and guardrail decisions, and errors. Store prompt and response content only where policy allows, with restricted access and a retention period. Deployers of high-risk AI systems must keep the system's automatically generated logs for at least six months, and the usage data also supports chargeback.
Sources
- LiteLLM documentation: AI Gateway (proxy server) · checked 27 October 2026
- LiteLLM documentation: budgets and rate limits per key, user and team · checked 27 October 2026
- Kong: AI Gateway documentation · checked 27 October 2026
- OWASP GenAI Security Project: LLM01:2025 Prompt Injection · checked 27 October 2026
- LiteLLM documentation: vLLM provider (OpenAI-compatible server) · checked 27 October 2026
- AI Act Service Desk: Article 26, obligations of deployers of high-risk AI systems · checked 27 October 2026