What is an LLM gateway, and when are direct provider APIs enough?
Contents
- What does an LLM gateway do?
- What is the difference between a gateway and a router?
- Where do your data, logs and credentials go?
- What does a minimal gateway client look like?
- When are direct provider APIs enough?
- What does Adapt's model gateway support today?
- Which checklist should you use before adopting a gateway?
An LLM gateway is a service that sits between your application and one or more model providers. Your code sends requests to one endpoint, and the gateway handles provider keys, translation between APIs, usage tracking, budgets and policies on the way through. If you use one model from one provider and have no plans to change, direct provider APIs are usually enough.
The harder question is what happens when that stops being true: a second provider, a second team, a budget someone has to answer for. This guide covers what a gateway does, where your data and credentials go, a minimal client, and a checklist for deciding. It also separates what gateways commonly offer from what Adapt's model gateway supports today.
What does an LLM gateway do?
Reputable explainers agree on the core jobs. Langfuse's overview lists a unified API, routing and failover, cost controls, central key management and policy enforcement. OpenRouter's guide frames the same list around why teams adopt one: more than one provider, uptime when a provider has an outage, spend accountability across a team, and the ability to change models without rewriting integrations.
| Job | What it means | Without a gateway, you build... |
|---|---|---|
| One API | One request format, translated to each provider's API | An adapter per provider, kept up to date |
| Key custody | Provider credentials stored centrally; apps hold one token | Keys in every service, rotated by hand |
| Billing and budgets | Usage attributed to a team, key or app, with limits | A spreadsheet of provider invoices |
| Policies | Approved models, rate limits, guardrails in one place | The same checks repeated in every service |
| Logging | A central record of requests and cost | Instrumentation in every client |
| Fallbacks | Retry on another target after an eligible failure | Retry and failover code in the app |
Not every gateway offers every row, and depth varies widely. A fallback, for one, only exists if someone configured a target for it. Key custody is also separate from who owns the provider account: a gateway can bill you at your own provider's prices and still be the system that stores the key.
What is the difference between a gateway and a router?
The words get mixed up, so keep them apart. A gateway is the layer your traffic passes through: it authenticates, applies policy, records usage and forwards the request. Routing is one decision a gateway can make: which model or provider should serve this request. You can have a gateway with a single fixed route, and you can route inside your own code without a gateway at all.
Routing also needs its own evaluation. A gateway can send a task to a cheaper model, but it can't tell you whether the cheaper model's output is good enough for that task. That is a measurement you make on your own workload; our post on model routing results shows one team's experiment and its limits.
Where do your data, logs and credentials go?
Adding a gateway adds a party that sees your requests. Before you add one, draw the path.
your app
│ one token, one request format
▼
┌──────────── gateway ────────────┐
│ authenticates the caller │
│ checks budget and model policy │ logs: who, which model, tokens, cost
│ stores provider keys (yours or │ (decide whether prompts are stored)
│ the gateway's own) │
└───────┬─────────────────┬───────┘
▼ ▼
provider A provider B
runs the model; its terms govern
retention, training and regions
Three questions follow from the diagram:
- Who owns the provider account, and who stores the key? These are separate questions. In a bring-your-own-key setup you own the provider account and pay the provider directly, but the gateway often still stores your key so it can call the provider for you. Ask where the key is kept, how it is encrypted, who can use it and how you revoke it. If the gateway supplies its own keys instead, you rely on its custody and billing as well.
- What is logged, and where? Usage metadata is one thing. Stored prompts and responses are another, and they may contain customer data.
- Whose terms apply to the prompt? The model provider still runs the request, so its retention and training terms still govern what happens to the content. A gateway doesn't change that, and it adds its own terms on top.
What does a minimal gateway client look like?
Most gateways expose an OpenAI-compatible API, so adopting one is often a change of base URL and key. Here is a minimal TypeScript client; the gateway URL and token are placeholders for whichever gateway you use.
import OpenAI from "openai";
// Fail closed: check both values before building a client.
function requireEnv(name: string): string {
const value = process.env[name]?.trim();
if (!value) {
throw new Error(`${name} is not set; refusing to create a gateway client.`);
}
return value;
}
const client = new OpenAI({
apiKey: requireEnv("GATEWAY_TOKEN"),
baseURL: requireEnv("GATEWAY_BASE_URL"), // e.g. https://gateway.example.com/v1
});
const reply = await client.chat.completions.create({
model: "provider/model-name", // many gateways prefix the provider
messages: [{ role: "user", content: "Summarize this ticket in one line." }],
});
console.log(reply.choices[0].message.content);
The validation matters. The OpenAI SDK falls back to OPENAI_API_KEY when no apiKey is passed, and to OpenAI's own endpoint when no baseURL is set. If GATEWAY_TOKEN were missing, your OpenAI key could be sent to the gateway. If GATEWAY_BASE_URL were missing, your gateway token could be sent to OpenAI. Checking both values first turns either mistake into an error at startup.
Going direct is the same client without a gateway: pass your provider key and leave baseURL alone. Keep that as a separate configuration rather than building both clients in one file.
The code barely changes, which is the appeal. "Compatible" is not the same as "identical", though. Streaming, tool calls, structured output and error codes can differ between providers behind the same endpoint, so run your own requests through before you switch.
When are direct provider APIs enough?
Go direct when most of these are true:
- You call one provider, and one model does most of the work.
- One team owns the integration and its provider account.
- You can tolerate writing retry or fallback logic yourself later.
- You want to debug against the provider with nothing in between.
- You rely on provider-specific features such as fine-tuned models or particular cache behavior that a unified API may not expose.
Kong's architecture guide puts direct integration at early-stage prototypes, single-developer projects and single-provider setups with no plans to scale. Langfuse says the same from the other side: a gateway is one more hop and one more system to operate.
A gateway starts to pay for itself when you see a pattern like this:
- You use more than one provider or model in production.
- Several teams or customers call models, and someone needs per-team limits and attribution.
- A provider outage would page someone, and failover is a requirement.
- The same retry and policy code is copied into two or more services.
A middle path works too: keep provider-specific code behind a thin interface of your own, track usage by workflow, and adopt a gateway when those needs recur rather than when they are hypothetical.
A gateway also has a cost. It adds a network hop, a dependency and sometimes a fee. If you adopt one, measure time to first token and total request time both ways, with the same models and region, and plan for what happens when the gateway itself is down.
What does Adapt's model gateway support today?
Adapt's model gateway is one of its three infrastructure components, alongside sandboxes and storage, and the same gateway sits under the company agent. Here is what the Model providers docs say, as of November 18, 2026. We read the docs and have not run these endpoints ourselves.
- Billing and key ownership. Your own provider keys are billed at 0% markup, so you pay the provider directly. If Adapt supplies the keys, the rate is the provider's list price plus 5.5%. See pricing. The 0% rate is about who owns the account and the bill, not about where the key lives.
- Providers and keys. You can save API keys for OpenAI, Anthropic, Google and TypeSafe (one key per provider per organization) in your Adapt organization. Saved keys are encrypted and never displayed again, new keys are validated before saving, and deleting a key removes it from Adapt without revoking it at the provider, so revoke it in your provider account too. Individual models can be enabled or disabled. Owners and admins manage keys, and members never see them.
- Model listing.
GET /v1/modelsreturns the organization's available models in an OpenAI-compatible list, and requires themodelGateway.usepermission. - Inference: OpenAI. An OpenAI connection can make requests through the gateway. The docs list
POST /v1/chat/completions,/v1/responsesand/v1/decisionsas supported. - Inference: TypeSafe. A TypeSafe connection supports native JSON
POST /v1/systemonerequests withstate,modelandquestions. It accepts native model names or matchingtypesafe/prefixes, and its SDK base URL should be the Platform origin, because the SDK appends/v1/systemone. - Authentication and limits. Call these endpoints with a Platform bearer key that has model access. Provider keys stay on the server. Multipart uploads are unsupported, and the JSON request limit is 1 MiB.
- Anthropic and Google. The docs cover saving their keys, managing their models and listing them, but they don't document inference endpoints for them. Confirm with the team before you plan around inference for either provider.
- Product page snippet. The SDK snippet on the model gateway page is labeled illustrative, and the final SDK may differ. Build against the documented endpoints above, not the snippet.
- Access. The gateway is available by request. The developer guide lists the options, and the open-source company agent opens in developer preview on January 12, 2027, with a waitlist until then.
We don't describe routing policies, fallbacks or caching for the Adapt gateway here, because those aren't documented as available. If you need them, ask before you plan around them.
Which checklist should you use before adopting a gateway?
- Count your providers and models. One of each? Stay direct for now.
- List who calls models. More than one team or customer? You need attribution and limits.
- Decide who owns the account and who stores the key. Bring your own keys to keep the provider account and its prices, then check whether the gateway stores the key, who can use it and how you revoke it.
- Decide what is logged. Metadata only, or prompts and responses, and for how long.
- Check what your requests need. Streaming, tools, structured output, provider-specific parameters. Test each through the gateway.
- Configure and test fallbacks. A fallback that has never been triggered is a guess.
- Measure the cost of the hop. Latency, fees and the extra failure mode.
- Plan the exit. Keep your own interface so you can go direct again.
If you're building a company agent or adding components to one you have, the developer guide is the next stop, and talking to the team is the way to confirm gateway access.
The company agent goes open source on January 12.
Join the waitlist