Skip to content
AnyRouter
All posts

What is an LLM gateway?

An LLM gateway sits between your app and many model providers. This guide explains what it does, how a request travels through it, when you need one, and when you do not.

What is an LLM gateway?

An LLM gateway is a proxy between your app and many model providers. You call one base URL with one API key. The gateway routes the request, retries it on another provider when the first one fails, and logs it in one place.

Your code talks to a single, familiar API. The gateway handles the providers behind it.

What does a gateway do for you?

A gateway takes on the jobs you would otherwise write into every app that calls a model.

JobWhat it means
One APIOne base URL and one key for every model, in the formats your client already speaks.
RoutingThe model id you send decides which upstream serves the call.
FailoverA 401, 429 or 5xx from one upstream retries on the next, so the caller sees the answer and not the error.
One logEvery call records its model, tokens, cost, latency and errors in one place.
Your own keysRoute through provider keys you already pay for, with no markup on top.

Here is the path of one request.

One request through a gateway

Active stage: Send

One request to the gateway base URL, with a model id written provider/model.

The retry rules are in the model fallbacks guide. The log is described in request logs.

Do you need an LLM gateway?

It depends on how many models and providers you call, and what happens when one of them fails.

Your situationWhat fits
One model, one provider, no failover needA direct call is enough.
More than one model or providerA gateway gives you one key and one API for all of them.
You want a retry on another provider when one failsA gateway does it for you.
You want one log and one billA gateway keeps them in one place.

A gateway adds one hop. If you only ever call one model from one provider, that hop buys you little. Direct provider vs gateway walks through the trade-off, and LLM gateway latency and failover covers the cost of the extra hop.

How does AnyRouter fit?

AnyRouter is an OpenAI- and Anthropic-compatible LLM gateway. One API key reaches hundreds of models, with automatic failover, free models, bring-your-own-key at $0 markup, and a shared key Pool. The LLM gateway page sums it up.

OpenAI Chat Completions, Responses, Embeddings and Anthropic Messages sit behind one base URL. Here is a request from the quickstart.

One call to the gateway. anyrouter/free picks a free model for you
export ANYROUTER_API_KEY="sk-ar-v1-your-key"

curl https://anyrouter.dev/api/v1/chat/completions \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anyrouter/free",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
  • Model ids are written provider/model, for example moonshotai/kimi-k3.1-pro. Browse them on the models page.
  • Free models cost $0 per token on Go and up, with no daily cap and no credit deduction. See free models.
  • Your own provider keys route at a $0 markup. See bring your own key.
  • Inference keys start with sk-ar-v1-. Management keys start with ak_.

Where to go next

To make a first request, follow the quickstart.

Official site

The official AnyRouter domain is https://anyrouter.dev, shortened as https://anyr.dev. It is the only valid domain for the API, docs, models, pricing and terms.

Sites on other domains that use the AnyRouter name are clones and are not affiliated with AnyRouter. Check the domain before you send API keys, credentials or payments.

FAQ

What is an LLM gateway?

An LLM gateway sits between your app and many model providers. You send one request to one base URL with one API key, and the gateway routes it, retries it on another provider when the first fails, and records it in one log.

Is an AI gateway the same as an LLM gateway?

People use the two names for the same idea: one entry point in front of many models. An AI router is the part that picks which model or provider serves a request.

Do I need an LLM gateway?

You need one when you use more than one model or provider, want a retry on another provider when one fails, or want one log and one bill. If you call a single model from a single provider, a direct call is enough.

Can I use my own provider keys with a gateway?

On AnyRouter, yes. Bring-your-own-key routes through the keys you already pay for at a $0 markup, so the provider bills you exactly what it charges.

Related posts