What Is an LLM Router? AI API Gateways Explained

An LLM router puts one API in front of many model providers. Here is what it does, what it costs you, and how to tell whether you need one.

By the Deftrouter team 5 min read

  • LLM routing
  • AI API gateway
  • OpenAI compatibility

An LLM router is a service that sits between your application and the companies that run large language models. Your code sends every request to one API. The router checks who is asking, decides which provider and model should handle the request, forwards it, and records what it cost.

You will also see the same idea called an AI gateway, an LLM gateway, a model aggregator or a unified AI API. The names differ more than the products do.

The problem it solves

Using one model from one provider is simple: one key, one SDK, one invoice.

It rarely stays that way. A team adds a cheaper model for bulk work, a stronger one for hard cases, and a third for images or speech. Each provider brings its own:

  • API key and account to manage
  • request format, SDK and error codes
  • rate limits and quotas
  • dashboard for usage and a separate bill

None of this is difficult on its own. Together it becomes a layer of glue code and spreadsheet work that has nothing to do with your product. A router moves that layer out of your codebase.

What an LLM router actually does

Most routers do four jobs.

1. One API in front of many. The router exposes a single request format and translates it into whatever each provider expects. The most common choice is to mirror OpenAI’s Chat Completions API, because so many tools already speak it.

2. Keys and access. You hold the provider credentials in one place and hand out your own keys to apps and teammates. Each key can have a spending limit or be switched off without affecting the rest.

3. Routing. At its simplest, routing means the model name in the request decides where it goes. Some routers go further: retrying on another provider when one fails, spreading load across several accounts, or picking a model by cost or speed.

4. Metering and logs. Every request is counted: which key, which model, how many tokens, how much money. That gives you one place to answer “what did this feature cost last week?”

What “OpenAI-compatible” means

A router is OpenAI-compatible when it accepts requests shaped like OpenAI’s API. In practice that means you can keep using the OpenAI SDK and change two settings:

from openai import OpenAI

client = OpenAI(
    base_url="https://router.example.com/v1",  # the router, not the provider
    api_key="YOUR_ROUTER_KEY",
)

reply = client.chat.completions.create(
    model="provider/model-name",
    messages=[{"role": "user", "content": "Summarize this in one line."}],
)

Compatibility is never total. Features that only one provider offers, or that were released last week, may be missing or work differently through a router. If your product depends on a specific feature, test that exact feature through the router before you commit to it.

Hosted or self-hosted

There are two ways to get a router.

Hosted router Self-hosted router
Who runs it The vendor You
Provider accounts Usually the vendor’s Usually your own
Billing One bill from the vendor Separate bills from each provider
Setup An API key A server, a database and upkeep
Who sees your prompts You, the vendor and the provider You and the provider

A hosted router is the fastest way to start, since there is one account to open and one bill to pay. A self-hosted one keeps another company out of the request path, at the price of running the software yourself.

The trade-offs

A router is another moving part, and it is worth being clear about what you take on.

  • An extra hop. Each request passes through one more service. The added delay is usually small compared with model generation time, but measure it if latency matters to you.
  • Another party handling your data. With a hosted router, prompts and responses pass through the vendor’s systems. Read what they log and for how long, and what their terms say about using your data.
  • Another dependency. If the router is down, every model behind it is unreachable from your app. Ask how it handles outages and whether you can fall back to calling a provider directly.
  • Feature lag. New provider features take time to appear behind a common interface, and some never fit it well.
  • Pricing in the middle. A hosted router sets its own prices. They can be higher or lower than the provider’s list prices, so compare the rate for the models you actually use.

Do you need one?

A router earns its place when several of these are true:

  • You use models from more than one provider, or expect to soon.
  • Several apps or people need access, and you want a limit on each.
  • You want one view of usage and spend across models.
  • You want to change models without rewriting integration code.

You can skip it when you use one model from one provider, depend on features specific to that provider, or have compliance rules that limit which companies may process your data.

Questions to ask before choosing one

  1. Which models does it support, and how quickly are new ones added?
  2. Which API features pass through unchanged: streaming, tool calling, structured output, images, caching?
  3. What is logged, where is it stored, and how long is it kept?
  4. What happens to in-flight requests when an upstream provider fails?
  5. How is usage priced, and can you set hard spending limits per key?
  6. How hard is it to leave? If the API is OpenAI-compatible, moving away should mostly mean changing a base URL.

Where Deftrouter fits

Deftrouter is a hosted, OpenAI-compatible router: one endpoint, one key, and usage tracked per key. Access is by request for now. Request early access and tell us which models you need.

Frequently asked questions

Is an LLM router the same as an AI gateway?

In practice the terms overlap. "Router" stresses choosing which model or provider handles a request. "Gateway" stresses the shared controls in front of the models: keys, limits, logging and billing. Most products do some of both.

Does an LLM router make requests slower?

It adds one network hop and a little processing. That is usually small next to the time a model spends generating a response, but it is not zero, so measure it for latency-sensitive features.

Can I use the OpenAI SDK with an LLM router?

With most of them, yes. A router that exposes an OpenAI-compatible API lets you keep the OpenAI SDK and change only the base URL, the API key and the model name.

When should I not use an LLM router?

If you use a single model from a single provider and rely on features specific to that provider, calling it directly is simpler and keeps one fewer company in the path of your data.

Request early access

Access is by request for now. Leave your email and the models you need, and we will email you when your key is ready.

Model names, or the kind of work: coding, reasoning, long documents.

We use these details only to set up your access and to contact you about it. See the privacy page.