Routers, aggregators and wrappers versus going straight to the source

A wave of services now offers one OpenAI-compatible endpoint that reaches many models: frontier, fast, cheap, vision and code models from different providers behind a single key and credit balance. Others are simpler wrappers that let you use two big providers through one URL, often pitched to people using coding agents. Some builders write their own small wrapper for personal projects.
The alternative is to connect directly to each provider with its own key and SDK. This comparison helps you choose. It covers what gateways actually do, where they help, where they add risk, and how to keep your options open whichever way you go.
This site is not affiliated with OpenAI or any gateway mentioned in general terms here. It does offer a keyless endpoint for the free-ai model, which we use in examples as one more route a router can include.
Frequently asked questions
What is an LLM gateway?
It is a service or self-hosted proxy that sits between your application and one or more model providers. It accepts requests in one format, usually OpenAI-compatible, forwards them to the selected model and returns the response, often adding logging, caching, fallback and billing.
How does a gateway differ from a reseller?
A transparent gateway tells you which provider and model handle each request, publishes its pricing and terms, and often lets you bring your own provider keys. A dubious reseller hides the source. See discounted API credits for the warning signs.
Which is cheaper, a gateway or direct access?
Direct access avoids a middle margin. Gateways may add a markup or a fee, but can save money through caching, automatic routing to cheaper models and consolidated billing. Compare actual totals for your traffic rather than list prices.
Does a gateway see my prompts?
Yes. Every request passes through it. A hosted gateway can log content, so read its privacy policy and data retention terms. A self-hosted gateway keeps that traffic inside your own infrastructure.
Which is more reliable?
A gateway with fallback across providers can survive a single provider outage, which direct access cannot without your own logic. But the gateway itself becomes a single point of failure. Some teams keep a direct route as a backup for the gateway.
Do gateways support every provider feature?
Not always. New or provider-specific features may arrive late or behave differently through a gateway that normalizes everything into one format. If you rely on a cutting-edge feature, direct access is safer.
Can I build my own simple router?
Yes. A small function that picks a base URL, key and model per request, with fallback on errors, covers many personal needs. Open-source proxy projects offer more features if you outgrow it.
Can a router include the free endpoint?
Yes. Add it as a route with base URL https://api.apifreekeyopenai.com/v1 and model free-ai. It suits low-stakes traffic and overflow, keeping in mind its per-IP limits and lack of SLA.
What a gateway actually does
At its core a gateway is a translator and a switchboard. It accepts one request format, maps the model name you send to a provider and its native model, forwards the call, and translates the response back. Most gateways add features on top: usage logs, cost tracking, response caching, retries, fallback to a second model, and a single bill.
The value grows with the number of providers you use. With one provider, a gateway is mostly an extra hop. With five, it can save a lot of integration work and give you one place to watch costs.
Unified billing
One credit balance for many models is convenient, especially for small teams that do not want separate accounts and invoices at every provider.
Normalization
Gateways smooth over differences between providers' APIs. That convenience can hide details, such as a parameter that is silently ignored for one model.
Where direct access wins
Going straight to the provider gives you the full feature set as soon as it ships, the provider's own documentation and support, and no extra party in the data path. Errors arrive unfiltered, which makes debugging easier, as explored in errors from compatible endpoints.
Direct access also matters for compliance. Data processing agreements, regional data handling and enterprise terms are negotiated with the provider. Adding a gateway means adding another processor to that paperwork.
Rate limits grow with you
Providers typically raise limits as your account builds history with them. Traffic through a gateway may count against the gateway's own arrangements instead, which you do not control.
Fewer moving parts
Each component in the request path is one more thing that can be slow, misconfigured or down. With direct access, a failed request has two suspects: your code and the provider. With a gateway, there is a third, and its status page becomes one more thing you have to watch during an incident. For small teams without dedicated operations staff, that simplicity has real value.
- Earliest access to new features and models.
- No extra margin on tokens.
- Clean error messages and provider support.
- Simpler compliance story.

Where a gateway wins
If your product uses several models, a gateway removes a lot of glue code. Swapping a model becomes a configuration change in one place. Fallback across providers turns an outage at one into a slight quality change instead of downtime.
Gateways are also handy for experimentation. Comparing several models on the same prompt is easy when they all sit behind one endpoint. Coding agents and IDE extensions that accept one base URL benefit in the same way.
Cost-aware routing
Some gateways route simple requests to cheap models and hard ones to strong models automatically. Measure the results; automatic routing can surprise you on edge cases.
Caching and logs
Built-in response caching and searchable logs save real effort. Check where logs are stored and for how long before turning them on for sensitive traffic.
Consistent observability
A gateway that logs every request in one format gives you a single view of latency, token usage and errors across providers. Without it, you assemble that view from several dashboards with different units and time zones. If you rely on many models, that consolidated picture is often the feature teams end up valuing most, more than the routing itself.
Risks to weigh before choosing a gateway
The gateway sees every prompt and response. If it is a hosted service, its security becomes part of yours. If it shuts down or changes terms, every route behind it changes at once.
Model naming is another subtle risk. Gateways use their own model identifiers, and the mapping to provider models can change. Record the actual upstream model reported in responses so you can detect substitutions.
Wrapper projects
Small wrappers built by individuals for their own projects are useful learning tools. Think twice before routing production traffic or other people's data through one you do not control.
- Who operates it and under which terms?
- Does it state the upstream model for every request?
- Can you bring your own provider keys?
- What is logged, and can logging be disabled?
- What happens to your balance if it closes?

A minimal router you control
For many builders the best answer is a small router in their own code: a list of routes, each with base URL, key and model, and a function that tries them in order. It gives you fallback and portability with no third party in the middle.
The example tries a primary paid route first and falls back to the keyless endpoint on rate limits or server errors. It deliberately does not fall back on quota or authentication errors, which a different route cannot fix.
Label the route
Return or log which route answered. When quality changes, you need to know whether the fallback was involved.
Retry budgets per route
Give each route its own small retry budget and a short timeout so that a slow primary does not delay the fallback for too long. Users notice a ten-second wait far more than they notice a slightly different wording from a backup model. Tune the timeouts with real latency data from your logs rather than guessing, and revisit them when you add or change providers.
import os
import openai
from openai import OpenAI
ROUTES = [
{"name": "primary", "base_url": os.getenv("PRIMARY_URL", "https://api.openai.com/v1"),
"key": os.getenv("PRIMARY_KEY", ""), "model": os.getenv("PRIMARY_MODEL", "")},
{"name": "free", "base_url": "https://api.apifreekeyopenai.com/v1",
"key": "not-needed", "model": "free-ai"},
]
clients = {r["name"]: OpenAI(base_url=r["base_url"], api_key=r["key"] or "missing", max_retries=1)
for r in ROUTES}
def chat(messages, **kw):
last_err = None
for r in ROUTES:
if not r["model"]:
continue
try:
resp = clients[r["name"]].chat.completions.create(model=r["model"], messages=messages, **kw)
return r["name"], resp.choices[0].message.content
except (openai.RateLimitError, openai.InternalServerError, openai.APIConnectionError) as e:
last_err = e
continue
raise RuntimeError(f"all routes failed: {last_err}")
print(chat([{"role": "user", "content": "Say hello in French."}], max_tokens=20))Self-hosted proxies
Between a hosted gateway and a hand-written router sit open-source proxy servers you run yourself. They offer many gateway features, such as provider mapping, keys per team, budgets and logs, without sending traffic through a third party.
The cost is operations: another service to deploy, secure and update. For a team with several applications sharing provider access, it is often worth it. For a single side project, a few lines of routing code are usually enough.
Per-team budgets
A proxy can issue internal keys with spending caps per team or project, which helps prevent one runaway job from consuming everyone's budget.

Where the free endpoint fits in a routing setup
The keyless endpoint here is a natural extra route for development, testing and non-critical overflow. It speaks the same chat and text completion format, needs no key, and serves one model, free-ai, an independent open-weight model of roughly 35B parameters. It is not a GPT model and quality will differ, especially on complex reasoning.
Respect its limits in your router: about one request per second per IP with bursts of three, two concurrent requests, 10,000 requests or 10 million tokens a day, a 32,000-token context window and no SLA. Busy moments return 503; wait two to five seconds before retrying.
Do not hide the swap
If users might receive answers from a different model, tell them, or limit the fallback to internal and low-stakes features.
Text only
Routes for vision, audio or image generation need other providers. Keep the free route to text tasks.
Choosing in practice
Start from your needs rather than the feature lists. If you use one provider and care about compliance, go direct and keep a simple fallback in code. If you use several providers and value convenience, a reputable gateway or a self-hosted proxy earns its place. If you are unsure, begin direct with a small router; it is easy to add a gateway later and hard to remove one.
Whatever you choose, keep base URLs and model names in configuration and test every route regularly. A fallback that has never been exercised is not really a fallback. For deciding between hosted and local models as routes, read hosted API vs self-hosted model.
Check the provider's terms
Some providers have rules about proxies, resale and how their models may be exposed. Read the current terms on the provider's official site if you plan to offer access to others.
Start small and measure
Whichever path you choose, collect a few weeks of data before optimizing: request counts per model, error rates, latency and cost. Those numbers turn a debate about architecture into a simple comparison. They also reveal whether you actually use as many models as you thought, which is often the deciding question for whether a gateway is worth it.

Send a prompt to the keyless free-ai endpoint from the home page and see a reply in seconds, no sign-up needed.
Read also
- Hosted LLM API vs self-hosted open-weight model: which fits you?
- Navigating the Retirement of Your Favorite AI Model
- How do you stop an autonomous agent loop from burning your API budget?
- How do you keep API keys and secrets out of prompts you send to AI?
- How to get reliable JSON output from a chat completions API