Skip to content
Solutions · Self-Hosted LLM Gateway

Self-Hosted LLM Gateway for Model Routing and Cost Control

LLM gateway deployment for companies running AI on several models. One OpenAI-compatible endpoint in your own cloud account or data center routes each request to a self-hosted model on vLLM or Ollama, or to an API model such as OpenAI or Anthropic under your own keys, with per-team budgets, rate limits, PII redaction and logs on every call.

Book an LLM Gateway Strategy Session Free strategy session · mutual NDA included
100+LLM providers behind LiteLLM's one OpenAI-compatible endpoint (LiteLLM docs).
MITLicence on LiteLLM's code outside its enterprise directory and on Portkey's gateway (project repositories).
3Gateways with open-source code we deploy: LiteLLM, Portkey and Kong (project repositories).
What It Does

What an LLM Gateway Does for Your AI Traffic

An LLM gateway sits between your applications and the AI models they call. Apps, agents and internal tools send every request to one address.

One OpenAI-compatible endpoint

Apps call one URL in the OpenAI format, so adding or swapping a model is a gateway setting.

Model routing

The model router picks a model for each request by name, team or rule, such as a self-hosted model for internal documents.

Fallback and retries

When a model errors or reaches its rate limit, the gateway retries, then moves to the next model on your fallback list.

Keys per team

Each team, app or project gets its own virtual key, and provider keys stay inside the gateway.

Budgets and rate limits

Spend caps and token or request limits per key and per team, with the cost of each request recorded.

Request logs

Every call is logged with its key, team, model and cost, and exported to your observability tools.

What Runs Where

What Runs Where in a Self-Hosted AI Gateway

The gateway, your self-hosted models and the logs run in your environment. Only requests you route to an external model API leave your network, after redaction, and their responses come back.

ComponentWhere it runsWhat crosses your network boundary
LLM gateway (LiteLLM, Portkey or Kong)Containers in your cloud account or on your own serversReceives requests from your apps on the internal network
Self-hosted modelsvLLM or Ollama on GPU servers in the same networkPrompts and responses stay inside your network
API models (OpenAI, Anthropic, Gemini and others)The provider's cloud, under your own API keys and contractThe redacted prompt goes out, and the response comes back
Provider API keysHeld by the gateway, while apps use virtual keysEach key goes only to its own provider
Presidio redaction, logs and tracesNext to the gateway and in your observability stackStay inside your network

vLLM ships an OpenAI-compatible API server and Ollama supports a subset of the OpenAI API, per each project's docs, so the gateway calls your own models the way it calls OpenAI. We set them up through our vLLM deployment or Ollama deployment services, inside a self-hosted AI deployment.

Routing and Fallback

Model Routing and Fallback Across Self-Hosted and API Models

The LLM router decides which AI model answers each request and what happens when it is busy or errors. These settings follow LiteLLM's routing and reliability docs.

1

Model groups under one name

Several deployments of one model, such as two vLLM servers, sit behind one name. LiteLLM's default simple-shuffle strategy spreads requests across them.

2

Routing by team, task or data class

Internal documents go to a self-hosted model on vLLM or Ollama, and general drafting can go to an API model. Each team's key lists the models it may call.

3

Latency- and cost-based routing

The router can pick the deployment with the lowest recent latency or the lowest configured cost.

4

Retries, then fallback in order

After its retries, LiteLLM moves down your fallback list in order: a second self-hosted model first, then an API model where your AI policy allows it. Separate lists cover context-window and content-policy errors.

5

Cooldowns for failing deployments

A deployment that keeps failing rests in cooldown for the period you set while traffic moves to healthy ones.

Keys, Budgets and Limits

Per-Team Keys, Budgets and Rate Limits for AI Spend

AI cost control starts with knowing who sent each request, so every team, app and agent gets its own virtual key.

Virtual keys per team

Each user, team or project gets a key that names the models it can call. Calls to vLLM and Ollama models use the same keys as API calls.

Team, member and key budgets

A shared spend cap per team, with optional caps per member and per key, reset on your schedule. LiteLLM records each request's cost in its spend logs.

Rate limits

Token, request and parallel-request limits per key or team keep capacity available for every team.

PII Redaction

PII Redaction Before a Prompt Reaches an External AI Model

When a request is routed to an API model, the gateway runs your redaction rules first. LiteLLM's Presidio guardrail, in pre_call mode, masks or blocks personal data before the model call, and Presidio runs in containers inside your network:

1 Names, email addresses, phone numbers and card numbers, replaced with placeholders.
2 Requests containing a data class you block, stopped before any API call.
3 Personal data masked in the request logs too, through the logging_only mode.
On the Way Out

Redaction runs in your network, before the API call.

The external AI model receives the masked prompt, and the original values stay in your systems. Portkey and Kong offer PII redaction in their enterprise editions.

Mask or block per data class
Presidio runs next to the gateway
Masked values in logs as well
Logs and Observability

AI Request Logs and Observability Export

Every model call leaves a record your platform and security teams can query.

1

One record per request

Each call is stored with its key, team, model and cost, feeding spend views and budget checks.

2

OpenTelemetry traces

LiteLLM exports OpenTelemetry traces with W3C traceparent propagation to your collector. Kong's open-source repository includes an OpenTelemetry plugin.

3

Langfuse for prompt-level traces

LiteLLM sends prompts, responses and metadata to Langfuse, which is MIT-licensed and can be self-hosted beside the gateway, per its repository.

4

Metrics, storage and SIEM

Request rates, errors and spend go to Prometheus or Datadog, and logs go to S3 or a SIEM such as Azure Sentinel under your retention policy.

5

Redacted logging

Personal data is masked before it reaches any log, using the same Presidio rules as live traffic.

Gateways We Deploy

Open-Source AI Gateways We Deploy and Configure

We deploy the enterprise AI gateway that fits your stack, and you own it. Each row comes from the project's own repository and docs.

GatewayLicence, as the project states itRouting and fallbackKeys, budgets and limitsPII redactionLogs and export
LiteLLM proxyMIT outside the enterprise/ directory, which has its own licenceWeighted, latency and cost routing; ordered fallbacks, retries and cooldownsVirtual keys; budgets per user, team and key; token, request and parallel limitsPresidio guardrail that masks or blocks before the model callLangfuse, OpenTelemetry, Prometheus, Datadog, S3
Portkey AI GatewayMITFallbacks on chosen errors, up to 5 retries, weighted load balancing, conditional routingSecure key management in the enterprise version40+ guardrails; PII redaction in Portkey's enterprise versionLocal logs in the Gateway Console; full tracing on Portkey's hosted app
Kong GatewayApache-2.0AI Proxy plugin for OpenAI, Anthropic, Gemini, Bedrock, Ollama, vLLM and moreKey authentication and rate-limiting pluginsAI Sanitizer, in Kong's AI Gateway Enterprise offeringOpenTelemetry and Prometheus plugins; AI Proxy adds model usage to logs

Teams looking for a LiteLLM alternative can compare Portkey, for config-driven routing in a lightweight Node.js service, and Kong, for companies already running Kong Gateway for their APIs.

Model Traffic and Tool Traffic

How the LLM Gateway Pairs With an MCP Gateway

AI agents send two kinds of traffic. Model calls go through the LLM gateway and tool calls go through the MCP gateway, each with its own keys, rules and logs.

What Shapes the Engagement

What Shapes an LLM Gateway Engagement

The scope follows your models, teams and data rules. Bring your model list and AI use policy, and we will map the deployment that fits.

Book a Strategy Session →
What shapes the scope
How many self-hosted and API models sit behind the gateway
The teams, apps and agents that need their own keys and budgets
Redaction rules for your sensitive data classes
Your cloud account, own servers or Kubernetes setup
Where logs and traces go, and how long you keep them
Features from a commercial edition, such as SSO for the admin UI
Questions

Frequently Asked Questions on LLM Gateways

An LLM gateway, also called an AI gateway, is one OpenAI-compatible endpoint between your applications and the AI models they call. It routes each request, falls back when a model errors, holds provider keys, enforces per-team budgets and rate limits, and logs every call.

The best fit follows your stack. LiteLLM's docs list virtual keys, budgets, rate limits, fallbacks and Presidio redaction without an enterprise label, with admin UI SSO and audit logs under its commercial licence. Portkey's MIT-licensed gateway covers fallbacks, retries, load balancing and guardrails. Kong suits companies already running Kong Gateway.

Portkey's gateway and LiteLLM's code outside its enterprise directory are MIT-licensed and Kong Gateway is Apache-2.0, so the open-source editions carry no licence fee. Running cost is compute for the gateway, GPUs for any self-hosted models, and the API usage you pay each provider under your own keys. Our scope depends on your models, teams and redaction rules, and the strategy session gives you a scoped figure.

OpenRouter's documentation says it gives you access to hundreds of AI models through a single API endpoint, served from its hosted service. Teams searching for OpenRouter enterprise or OpenRouter self-hosted options often want that endpoint inside their own network. A self-hosted LLM gateway provides it, with your own keys, budgets, redaction and logs, and your vLLM or Ollama models behind it.

Ready to Put One Gateway in Front of Your AI Models?

A strategy session to map your models, teams and data rules to a self-hosted LLM gateway.

Discuss Your Project