An LLM gateway is a service that sits between your application and the companies that run language models. Your code talks to the gateway in one familiar API format with one key, and the gateway forwards each request to a model provider, then returns the answer. The reason people use one is not the forwarding. It is what happens around it: one key for many models, spend limits, fallbacks when a provider fails, and a usage record for every call.
What does an LLM gateway do that a direct API call does not?
A direct call is simple: your code, one vendor, one key. That is exactly right for a prototype with one model. It starts to hurt the day you want a second model, because every vendor has its own SDK quirks, key, billing page, limits and error codes.
A gateway removes that spread. The LiteLLM proxy docs describe the idea well: one OpenAI-format endpoint for 100+ providers, with virtual keys that carry models, budgets and rate limits, spend tracking per key, team, user and tag, load balancing, fallbacks and retries. The hosted services describe the same idea in their own words: OpenRouter as one account for many models, Vercel’s AI Gateway as a unified API with budgets and fallbacks, Cloudflare’s AI Gateway as analytics, caching and rate limiting in front of your provider calls.
Seven things recur across all of them.
- One format. Calls look like the OpenAI API, whatever sits behind them. Many gateways also accept the Anthropic format, as ours does, see the compatibility guide.
- One key. You hold a single credential, not one per vendor. The vendor keys stay with the gateway.
- Routing. The model id selects the destination. Some gateways add rules, such as “try model A, then B”.
- Retries and fallbacks. A transient failure becomes a retry, and a persistent one becomes a switch to another model. On ours, the gateway retries the named model up to twice, and if the model is still failing, fallback rules, presets and automatic routing move the request to another similar model; only the attempt that answers is billed. See the uptime and fallback guide.
- Limits. Per-key spend caps, expiry, model allowlists and rate limits, which a vendor key alone rarely offers. Limits also produce errors you should read before you retry, and the 429 guide tells the kinds apart.
- Records. A line per request with model, tokens, cost and timing, so you can answer “what did this cost and who spent it”.
- Extras. Caching, guardrails, redaction and logging, which differ a lot by product.
How does the same call look with and without a gateway?
The change in code is deliberately tiny, which is the point. With the official OpenAI Python SDK, you change the base URL and the key. Everything else, including streaming and tool calls, works as before when the gateway is compatible.
from openai import OpenAI
# Direct to one provider: one vendor, one key, one model family
client = OpenAI(api_key="sk-vendor-key")
client.chat.completions.create(model="vendor-model", messages=[{"role": "user", "content": "Hi"}])import os
from openai import OpenAI
# Through a gateway: same SDK, same call. Only two lines change.
client = OpenAI(base_url="https://api.oneaiapikey.com/v1", api_key=os.environ["ONEAIAPIKEY_API_KEY"])
client.chat.completions.create(model="z-ai-glm-5.3:free", messages=[{"role": "user", "content": "Hi"}])curl https://api.oneaiapikey.com/v1/chat/completions \
-H "Authorization: Bearer $ONEAIAPIKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "z-ai-glm-5.3:free", "messages": [{"role": "user", "content": "Hi"}]}'The OpenAI Python SDK takes base_url as an ordinary argument, which is why a compatible gateway needs no special library. The switch guide shows the same change for Node and for environment-variable setups, and the quickstart has a full first call. For model ids, free ids on One AI API Key end in :free, listed on the free models page.
How does a request travel through a gateway?
The diagram follows one call. The steps are the same for any gateway, though a hosted one runs them on its servers and a self-hosted one runs them on yours.
What happens between your code and the model
Notice what the gateway cannot do. It cannot make the provider’s model better, and it cannot see inside the provider’s servers. If the provider swaps a model or quantizes it harder, the gateway may not know. That is why serious write-ups on this topic, like the model substitution audit by Cai and co-authors, treat any middleman as something to measure, and why we wrote a guide to verifying that an API serves the real model. The reseller risks guide covers the specific danger of very cheap endpoints.
What are the four kinds of LLM gateway?
The label “gateway” covers four different products. Who runs the software and who holds the account decide almost everything else: cost, privacy, effort and risk.
| Kind | Who runs it | Examples | You pay | You manage |
|---|---|---|---|---|
| Self-hosted proxy | You, on your servers | LiteLLM (needs a Postgres database; MIT licence apart from an enterprise directory), Portkey’s open-source gateway (MIT licence) | Servers and your time; provider bills direct | Updates, uptime, database, keys, on-call |
| Edge or platform gateway | A platform you already use | Cloudflare AI Gateway, Vercel AI Gateway | Provider cost; Cloudflare credits carry a 5% fee on cards; Vercel states no markup on tokens | Provider keys or platform credits |
| Marketplace | A vendor with many providers behind one account | OpenRouter | Provider price plus a credit-purchase fee (5.5%, $0.80 minimum, on 26 November 2026) | Almost nothing |
| Prepaid gateway | A small vendor with one balance and per-key limits | One AI API Key | Per-token rates from the models page; credit added by email today, no fee | Keys and limits |
Two of these deserve extra attention. The self-hosted proxy is the only kind where no gateway vendor ever sees your requests (the model provider still does), which is why privacy-sensitive teams choose it, and it is also the one with the most work. The LiteLLM versus hosted gateway comparison puts hours and dollars on that work. The marketplace kind is the one most people mean when they ask for “an alternative to OpenRouter”, and the list of OpenRouter alternatives compares seven options with dated facts.
Our own row is the least proven, and the table says it plainly. The about page says who runs One AI API Key, the transparency page says what we do and do not promise, and about 2,370 registered accounts on 26 November 2026 is a small base compared with the marketplaces. The rankings page shows the real traffic behind our models, counted from our own logs. If you need scale, a track record or an SLA, look at the other rows first.
What can go wrong when you add a gateway?
Adding a layer adds failure modes, and a fair explainer lists them. Knowing them is how you decide whether the benefits outweigh the cost for your project.
A new single point of failure. If every request goes through one gateway and it has a bad hour, all of your models have a bad hour at once. Direct calls to two vendors fail independently; two models behind one gateway share the gateway. The remedy is a second path for work you cannot pause: a second key on another provider, or a fallback you test. The uptime guide shows how to measure what an outage costs you, and the status page shows what we probe.
Different counting. A gateway reports token counts from the provider’s response. Two providers can tokenize the same text differently, so the same prompt may count differently across models. Compare usage with your own estimate once, using the glossary and the cost calculator, so a surprise does not arrive on the invoice.
Lost features. A gateway that normalizes many providers into one format can hide something a vendor offers natively, such as a provider-specific parameter. Check that the features you need, like tool calling, vision, structured output and reasoning, are documented: ours are in the tool calling, vision, structured output and reasoning references.
Streaming and timeouts. Long answers need streaming to stay alive through proxies, and a gateway adds one more proxy. Streaming is the default in coding tools for this reason, and the streaming guide explains the trade-off.
A weaker privacy position. One more party sees your requests. That is a real cost, and the only complete fix is self-hosting. For everyone else the question becomes what the gateway keeps, see the privacy guide, and what the upstream keeps, which the gateway does not control. On ours, by default what you send is not stored: prompts and answers pass through and are not kept, we keep counts and never content, and we do not train on your data.
Billing you cannot reconcile. If you cannot match the gateway’s usage log to the invoice, you are trusting a number you cannot check. A good gateway shows the request, the tokens and the cost per call. Ours does on the usage page, and the billing reference explains how a balance and a reservation interact.
How do you read a gateway’s documentation in ten minutes?
You can learn most of what matters about a gateway from five pages, and the order below goes from cheapest to most telling. Do it before you create an account.
- Pricing. Look for a fee on credits, a markup, a minimum purchase and a free tier. If any of these is missing or vague, note it. Ours is the pricing page.
- Limits. Find what stops a request: a daily cap, a rate limit, a balance. A page that explains where each limit comes from is a good sign, like our rate limits reference.
- Errors. A clear error list means someone has thought about failure. See the error reference for the format we use.
- Privacy and logging. Look for what is stored and for how long, whether prompts are logged, and whether you can opt out. Ours is in the routing and privacy reference.
- Terms and money back. Read what happens to credit you have added and what the service does not promise. See the terms and the contact page.
If a gateway makes any of those five hard to find, that is information. If it makes all five easy, you still test with a free tier and a throwaway project before you move real traffic, which is what the last section of this guide is for. For a longer evaluation framework, the 12-point provider checklist turns the five pages into twelve questions with a score.
What does a gateway cost on top of the models?
Four layers of cost can sit on top of the model price, and a good comparison names each. A fee when you add credit. A markup on tokens. A platform or seat charge. And your own time, which is the only cost a self-hosted gateway has. The chart shows the first layer for the hosted services, as published on their own pages.
Published fee on credit or usage, hosted gateways (26 November 2026)
- OpenRouter Business plan8%plan fee, per its pricing page
- OpenRouter, card credit purchase5.5%$0.80 minimum per purchase
- Cloudflare, Unified Billing5%credit card only
- Vercel AI Gateway, tokens0%no markup, no platform fee; processing fees apply
- One AI API Key0%credit added by email, amount added is amount received
On a $1,000 monthly spend, 5.5% is $55 a month before anything else, and 0% is $0. At $50 a month the same fee is $2.75, which most people will not feel. The model price itself usually matters more than the fee, and the cheap open model prices post lists per-million rates, while the guide to reducing LLM API costs covers ten ways to lower the token bill itself. That is why the LLM gateway fees comparison uses a calculator rather than a headline number, and why prepaid credits deserve their own look: the fee is visible once, at the moment you add credit, and not on every call.
When is a gateway worth it, and when is it not?
A gateway earns its place in a few situations, and is overhead in the rest. The picker below walks through the common ones. All answers are in the page without JavaScript, the buttons only show one at a time.
Which describes your project?
One model from one vendor, one app
You probably do not need one. A direct key is simpler, and a gateway adds a hop and another party. Revisit when you want a second model or a spend cap by project. The 12-point checklist covers what to check when you do.
Several models, one app, I want to compare them
A gateway helps. One key and one base URL let you swap model ids without new accounts. Try the 47 free ids on One AI API Key first, then add credit for the ones worth paying for. The free model guide sorts them by task.
A team with several projects and a budget to cap
This is the core case. Per-key spend limits, expiry and allowlists give each project its own ceiling. See cost control and the one key per project guide.
Coding agents that run for hours
Worth it, mostly for the cap. Give each agent its own key with a spend limit so a loop cannot drain the balance. The coding agent guide has the setup for Cline, Cursor, Codex CLI, Aider and others.
No third party may see my data
Self-host, if that includes the gateway. A hosted gateway forwards your requests, so it sees them, and the model provider does too. LiteLLM or Portkey's open-source gateway on your own servers keeps the first hop in your hands. The comparison shows the effort involved, and the privacy guide lists what to ask any host.
I am moving off another gateway
Check model ids, fallback behaviour and the base URL first. The migration guide covers the common traps, and the migrate reference has the short version.
What should you check before you trust one?
Four questions cover most of the risk, and each has a place to look. Who sees my data, and what do they keep? Check the privacy policy and the docs for the records the gateway stores, ours are in the routing and privacy reference. What happens when I want my money back? Read the terms before adding credit, and the guide to money-back policies for what to compare. Ours is plain: once a key is created and usage is consumed we do not give money back, since it is an online product; the exception is a key that does not work or a technical problem on our side, reported to support at somdutt777@gmail.com with a genuine concern. What is promised about uptime? On ours, nothing is guaranteed, see the terms, and the uptime guide shows how to design around it. Is the model what I pay for? The verification guide gives six tests.
A fifth question is practical: how do I leave? A gateway that speaks a standard format is easy to leave, because your code only knows a base URL and a key. If a gateway needs its own SDK, or its own model naming, switching costs rise. Ours uses standard OpenAI and Anthropic formats, so leaving means changing two settings back, and we would rather you know that before you start. The config generator shows the same settings for several tools in one place.
What is the free way to try one?
You can test a gateway for nothing, and you should. On One AI API Key, sign-in is a Google login, there is no card field, and the account gets $10 of sign-up credit for priced models. 47 free models work with a $0 balance, with no top-up, and keep working after the sign-up credit is spent; the only limit is the shared 100 requests and 3,000,000 tokens a day, refilled at 00:00 UTC. That is enough to run your real prompts against several models and read the usage record each call produces. (As of 26 November 2026 every priced id is marked unavailable on the models page, so the free lane is what answers today.)
Try the same two-line change from the code above against a free id, then open Usage and check three things: the token counts match what you sent, the model id is the one you asked for, and the time to first token is acceptable for your use. If you prefer not to write code first, the browser chat runs on the same allowance, and the chat guide explains how. The free tier comparison shows how our limits stack up against OpenRouter, Groq and Google.
If the test goes well, the next step is deciding how much to trust a gateway for production. That is a bigger question than any single feature, and the provider checklist turns it into twelve points. The honest review of One AI API Key applies the same checks to us, including where we are weaker than the alternatives.
See what one key for many models feels like
$10 sign-up credit, 47 free models sharing 100 requests and 3,000,000 tokens a day, no card.
To see how specific gateways differ, the comparison pages cover OpenRouter, Portkey, Requesty, LiteLLM, Vercel AI Gateway and Cloudflare AI Gateway, each with sources and a check date.
Frequently asked questions
What is an LLM gateway in one sentence?
Is a gateway the same as a proxy, a router or an aggregator?
Do I need a gateway if I only use one provider?
Does a gateway make requests slower?
Can a gateway see my prompts?
X-No-Log: true opts one call out, content is captured only if you ask us to troubleshoot a request or we investigate abuse, and the upstream provider that runs a model processes the request under its own terms. The privacy guide covers the questions to ask any gateway, and self-hosting is the answer when no gateway vendor may see the data.