Skip to content

OpenRouter or LiteLLM: a gateway in front of your AI models, for security and costs

An LLM gateway is the only door between your applications and AI models: it keeps the keys, enforces budgets, fails over during an outage and traces every call. OpenRouter, hosted, or LiteLLM, installed on your side: the comparison, the other gateways, a starting configuration to copy, and the security of the gateway itself.

By Published on 26 November 2026

One gateway between your applications and the modelsThe gateway keeps the keys, enforces budgets, fails over during an outage and traces every call.
  1. Your applications

    One key per team, one address

  2. The gateway

    Keys kept, budgets, quotas, fallback

  3. The online model

    At the chosen provider

  4. The fallback model

    An open model hosted on your side

Every call traced with its cost, without the text of the messages

An LLM gateway (or AI gateway) is a single entry point between your applications and AI models: it keeps the providers’ keys, gives each team its own key with its budget, fails over to another model during an outage, and traces every call. OpenRouter is a hosted gateway, giving access to hundreds of models with one account; LiteLLM is an open-source gateway installed on your side, in front of online models as well as the ones you host.

This article explains what a gateway is for, compares OpenRouter and LiteLLM, names the others, gives a starting configuration to copy, and says how to secure the gateway itself.

Why put a gateway in front of your models

Without a gateway, each team has its keys, its provider and its bill, and nobody knows which data goes where. Companies already use several model families: according to a16z’s January 2026 survey of 100 executives of large companies, 81% used at least three, in testing or production. A gateway gives:

  • one address for your applications, whatever the model behind it;
  • the providers’ keys kept in one place, never in the teams’ code;
  • one key per team or application, with its allowed models, its budget and its quotas;
  • a fallback model when a provider goes down, or a cheaper model for simple tasks;
  • the trace of every call and its cost, in one place;
  • a point where guardrails apply, such as masking personal data.

OpenRouter or LiteLLM: the comparison

Criterion

OpenRouter

LiteLLM

Where it runs

A service hosted by OpenRouter

On your side: a server, a container, your cloud

What you pay

The models’ price without markup, plus 5.5% on credits bought (8% on the Business plan)

Nothing for the open-source software (MIT licence); you pay the providers directly; an enterprise plan on quote

Your data

Prompts and responses not logged by default; a filter to use only zero-retention providers; routing through the European Union on the Business and Enterprise plans

They go through your infrastructure; message logging can be turned off

Keys and budgets

Your own provider keys possible; account and access management on Enterprise

Virtual keys per team, user or application, with budgets and quotas

Fallback and balancing

Choice and order of providers for each model

Fallback models, retries, balancing across several deployments

Your hosted models

No: only its providers’ models

Yes: a model served by vLLM or Ollama is added like the others

What remains yours to do

Accepting one more third party on your data’s path

Running, updating and securing the server

The rule we draw from it: OpenRouter to try many models quickly on data that may leave the company; LiteLLM as soon as the gateway must hold your rules, your per-team budgets and the models you host.

The other gateways

  • Portkey. An open-source gateway (MIT) and a hosted service; an American cybersecurity vendor acquired it in May 2026 for its AI security offering.
  • Kong AI Gateway, Cloudflare AI Gateway. The AI gateway features of two products many teams already run: quotas, caching, fallbacks, logs.
  • agentgateway. An open-source gateway (Apache 2.0) for model calls and the agent protocols MCP and A2A, hosted by the Agentic AI Foundation since June 2026.

A LiteLLM starting configuration, to copy

One online model, one open model served in-house by vLLM, the second as the first one’s fallback, and traces sent to Langfuse without the text of the messages:

YAML
model_list:
  - model_name: writing
    litellm_params:
      model: azure/<your-deployment>
      api_base: https://<your-resource>.openai.azure.com
      api_key: os.environ/AZURE_API_KEY
  - model_name: internal
    litellm_params:
      model: openai/<open-model>
      api_base: http://vllm.internal:8000/v1
      api_key: os.environ/VLLM_API_KEY

litellm_settings:
  num_retries: 2
  fallbacks: [{"writing": ["internal"]}]
  success_callback: ["langfuse"]
  turn_off_message_logging: true

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: os.environ/DATABASE_URL

Setting

What it does

model_list

The names your applications see, and the real model behind each: changing provider changes nothing on the application side

api_key: os.environ/…

Keys read from the server’s environment, never written in the file

num_retries, fallbacks

Two retries, then the fallback model

success_callback, turn_off_message_logging

The trace and cost of every call sent to Langfuse, without the content of prompts and responses

master_key, database_url

The admin key, and the PostgreSQL database that keeps virtual keys and spend

Then one key per team, limited to its models, with a 30-day budget; beyond it, the gateway refuses calls:

Shell
curl -X POST http://localhost:4000/key/generate \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"models": ["writing"], "team_id": "purchasing", "max_budget": 200, "budget_duration": "30d"}'

Securing the gateway itself

A gateway holds all your keys: it is a target. On 24 March 2026, two versions of LiteLLM’s Python package (1.82.7 and 1.82.8) published on PyPI contained a program that stole credentials, after a tool in their release pipeline was compromised; the official Docker image was not affected. Several flaws were also fixed in 2026, including an authentication bypass that the US cybersecurity agency (CISA) added to its list of exploited vulnerabilities.

  1. A pinned version, updated after reading the security advisories.
  2. The official image rather than an install from the package manager.
  3. The admin routes never exposed to the internet.
  4. Provider keys in a secrets manager, and a rotation after every alert.
  5. Virtual keys limited to what each team needs.

How we did it: a single gateway to the models

The starting point: AI trials in every team, never reaching production, data sent nobody knows where, and a model bill nobody can explain. We build a shared agent platform, with a single gateway to the models; each team deploys its agents there on a secure foundation, its usage is tracked and capped, personal data is masked, and a person approves sensitive actions. What it changes: AI moves from trial to production, and each team pays for what it uses.

The details are in the case of a retail company “Every team runs its AI trials in its corner, and costs drift” on our case studies page. Our approach Pilot to Platform sets this platform up for you. For the models hosted behind the gateway, see our article on Ollama and vLLM, and for what to do with the traces, our article on evaluating agents.

Our work on agents is presented on the page Agentic AI.

Frequently asked questions

What is an LLM gateway?

A service placed between your applications and AI models, giving them one address and handling keys, budgets, fallbacks and traces for them. It is also called an AI gateway.

Is OpenRouter free?

There is a free plan limited to 50 requests a day. Otherwise, you pay the models’ price, without markup, plus a 5.5% fee on credits bought.

Is LiteLLM free?

Its core is open source under the MIT licence: virtual keys, budgets, spend tracking, fallbacks, admin interface. A few features (single sign-on beyond five users, audit logs, roles) need the enterprise licence.

Does OpenRouter keep my data?

By default, it does not log the text of prompts and responses, only metadata. The providers it calls have their own rules: a filter lets you use only those that keep nothing.

Sources

Written with an AI assistant from the sources cited, facts checked and reviewed by Mehdi Chafik on 25 November 2026.