What is an LLM gateway?
Published
Published
Reading time
Reading time
8 minutes
8 minutes
An LLM gateway is a single API endpoint that sits between your application and the model providers it calls. Your code talks to the gateway; the gateway then talks to OpenAI, Anthropic, Google, Bedrock, or a self-hosted open-weight model. It handles routing, failover, authentication, rate limiting, spend tracking, and logging on the way through.

A gateway turns "which provider am I calling and how do I authenticate to it" into a configuration problem instead of a code problem. Adoption usually costs you a base URL and an API key, because most gateways expose an OpenAI-compatible interface. OpenRouter documents the OpenAI SDK pointed at its endpoint as "a drop-in replacement," and LiteLLM documents the same two-field change against a self-hosted proxy.
Plenty of teams don’t need a gateway. If you call a single model from a single provider and no regulated data is involved, a gateway is a dependency and a network hop that buys you very little. The rest of this post covers what a gateway gets you when you do need it, what it quietly costs you in provider-specific features, and misconceptions about it that gets teams in regulated industries into trouble.
The TL;DR
An LLM gateway is a proxy for model traffic. One endpoint, one credential, many providers behind it.
It solves provider abstraction, failover, centralized spend and rate limits, and request logging.
Adoption is usually a base URL and key change, since most gateways speak an OpenAI-compatible dialect.
The abstraction is lossy. Prompt caching, extended thinking controls, structured outputs, and native tool-calling schemas often do not survive normalization intact.
It is not an API gateway. API gateways route HTTP by path and method. LLM gateways understand tokens, models, streaming responses, and cost.
It does not make you HIPAA compliant (and self-hosting it doesn’t reduce your obligations either). Prompts still reach hosted providers, and every provider that receives PHI needs a business associate agreement (BAA) with you.
What a gateway can do is carry specific compliance work for you: BAA scope, audit logging, retention, access control, model access policy, and region enforcement. Whether or not yours does depends on the vendor.
What an LLM gateway actually does
Below are four main functions, roughly in the same order that teams discover they need them.
One API format across providers
Every provider has its own request shape, its own authentication, its own streaming format, and its own idea of what an error looks like. Writing against three of them directly means three integrations and three sets of edge cases.
A gateway normalizes that. Most of them expose an OpenAI-compatible interface, so switching from one model to another is a string change instead of a rewrite. This is the function that gets teams in the door, but it’s the least interesting one.
It’s also lossy, with tool definitions being the clearest case: OpenAI takes a tool's JSON Schema in a parameters field, and Anthropic takes the same schema in input_schema. A normalized layer either translates between shapes like that or hands them through untouched. LiteLLM documents the handing-through approach plainly: it "treats any non-openai param, as a provider-specific param, and passes it to the provider in the request body, as a kwarg," while noting that providers offer params OpenAI does not have. Prompt caching, extended thinking controls, structured output modes, and provider-specific sampling parameters all live in that category. Anthropic's prompt caching, for one, is requested with a cache_control block that has no OpenAI equivalent.
Check how your gateway handles the specific features your prompts depend on before you assume a model swap is a one-line change.
In practice. A pharmacy-operations company standardized on one hosted provider years ago because it was the only one that would sign a BAA at their size. They pay for that now in integration friction: the SDK provider package lags the API, and provider-side changes break their calls until the library catches up. Fine-tuning costs them a dedicated instance with a five-figure monthly floor. Behind a gateway, their existing client library works against the provider they already pay for, because the gateway speaks the dialect the ecosystem targets, and the next provider they add is a model string rather than a second integration.
Routing and failover
Providers have outages, rate limits, and capacity ceilings. When a request fails, something has to decide whether to retry, wait, or send it somewhere else.
Doing that in application code means every service that calls a model needs its own retry logic and its own fallback list. A gateway centralizes the policy: primary model, fallback model, retry budget, timeout. One place to change it when a provider degrades.
There are two downsides to failover, though. A request that fails over to a different provider hands your data to that provider, which matters a great deal if you have a BAA with one and not the other. And your prompts were tuned against a specific model, so silent failover changes output quality in ways your evals may not catch and your error rates will not show. Decide which is worse for your product (between a degraded answer or a failed request), because a default fallback chain makes that choice for you.
In practice. A medication-adherence company parses inbound patient texts with an LLM, replacing a rule-based system. When the provider degrades, patient messages stop getting parsed, so they added a fallback to a second provider they already had coverage for. That coverage came from a workspace agreement in place for office software, which extended to the vendor's model. An inventory of their AI vendors would not have turned it up. A gateway collapses both halves of that into one place: the fallback policy becomes configuration instead of retry logic in every service, and if the gateway's own BAA covers the providers behind it, the fallback target is in scope by default rather than by contract archaeology.
Centralized spend and rate limits
Model spend is easy to lose track of because it accrues per token across teams, environments, and features, and nobody notices until the invoice arrives.
A gateway is the natural place to attribute cost, because every request passes through it. That gives you per-key, per-team, or per-feature spend tracking, plus rate limits and budget controls that can actually reject a request rather than just reporting on it after the fact.
In practice. A telehealth company running several internal agents sits between $6,000 and $10,000 a month on model spend, and the number moves as they find out which workflows are expensive. One of those agents batch-reschedules two to three hundred patients at a time across hundreds of parallel instances. They moved it from the premium model to the cheaper one in the same family after measuring that it held roughly 95% of the quality for that task. A second team, on a single provider, built their own service to track who was using what and what each call cost. Give each agent its own gateway key and that build goes away: cost per workload becomes a dashboard read, and a per-key limit that rejects requests bounds what a misbehaving agent can spend before anyone notices it.
Request and response logging
The gateway sees every prompt and every response. That makes it the only place in the stack where you can get complete observability over model behavior without instrumenting every caller: latency, token counts, error rates, which prompts produce which outputs.
It also makes gateway logs the highest-sensitivity data store in your AI architecture, which almost nobody plans for on day one. More on that below.
In practice. A digital health company serving the hospice market started getting customer security questionnaires with a new AI section, asking about audit logging, training-data use, and AI supply chain. Unfortunately, logging that you haven’t built yet can’t be backfilled for the period covered by a security questionnaire you weren’t prepared for. A gateway that logs by default covers the period before anyone thought to ask. Getting that record out into the SIEM you already pay for is the part that varies, so ask your gateway provider about log export before you need it.
Do you actually need an LLM Gateway?
Direct API calls are the right answer for a lot of teams, and it’s certainly more frequent than most gateway vendors suggest.
Call providers directly when you use one model from one provider, you have no multi-team spend attribution problem, your logging needs are satisfied by application logs, and you aren’t handling regulated data.
Use a gateway when any of the following is true:
You call more than one provider (or expect to)
You need failover because model availability affects your product's availability
More than one team or environment shares model credentials
You need spend attribution or enforceable budget limits
You need a complete, centralized record of prompts and responses
You have a regulatory obligation attached to the data in those prompts
The usual sequence is direct calls first, then a gateway at the first of these triggers: a second provider, a credential shared across teams, a spend number nobody can attribute, or regulated data entering a prompt.
Note: the regulated-data trigger changes the decision more than the rest combined, because it moves the gateway from an operational convenience to a control point you have to be able to defend to an auditor.
What adoption actually costs
The integration. Most gateways expose an OpenAI-compatible endpoint, so adoption is a base URL and an API key in the SDK you already use. For an app already running the OpenAI or Anthropic client libraries, that’s just a config change. Coding agents that accept a custom endpoint (Claude Code among them) point at a gateway the same way.
The features you give up. The lossy normalization mentioned above is the real cost of a gateway pattern, and it’s usually only noticed after a migration. Audit which provider-specific capabilities your prompts depend on before you move.
The operational surface. A gateway sits in the critical path of every model call. Its availability becomes your availability, its logs become your most sensitive data store, and its credentials become the keys to every provider behind it. A managed gateway moves that work to a vendor. A self-hosted one keeps it, including patching and incident response.
LLM gateway versus API gateway versus MCP gateway
Routes by | Understands | Governs | |
|---|---|---|---|
API gateway | Path, method, header | HTTP requests | Your API |
LLM gateway | Model | Tokens, streaming, cost | Your model traffic |
MCP gateway | Tool | Tool calls and their arguments | Your agent's actions |
An API gateway (Kong, Apigee, AWS API Gateway) routes HTTP traffic by path, method, and header. It handles authentication, rate limiting by request count, and TLS termination. It has no concept of a token, a model, or a streaming completion. You can put an LLM behind one, but rate limiting by requests per second does not help when one request costs 200,000 tokens and the next costs 40. Kong says the same thing about its own two products: "If you just add an LLM's API behind Kong Gateway, you can only interact at the API level with internal traffic," which is the reason it ships a separate AI Gateway that can read the prompts going through it.
An LLM gateway understands the shape of model traffic. It counts tokens, normalizes across provider APIs, handles streaming responses, routes by model rather than by path, and attributes cost. Several vendors ship both products, which is why the categories blur.
An MCP gateway sits one layer up (in front of the tools a model can call rather than in front of the model itself). Model Context Protocol servers expose data sources, tools, and workflows to an AI application, and an MCP gateway governs which tools are reachable, what arguments are permitted, and what the agent is allowed to do with the results. If your concern is what an agent can execute rather than which model answers it, that’s a different product. We cover that distinction in the MCP security guide.
Teams running agents in production usually end up needing more than one of the three.
Capabilities to expect
Beyond the four core functions, the capabilities that separate a thin proxy from something you can run production traffic through are:
Model access policy. Restricting which models and providers are reachable, enforced centrally rather than by convention. Without this, any engineer with a gateway key can send data to any model you have configured.
Key management. Issuing, scoping, and rotating credentials per team or environment, so the gateway holds the provider keys and your services never see them. This is one of the stronger security arguments for a gateway: one credential to rotate instead of provider keys scattered across every service. It’s also, ironically, the counterargument: a gateway that holds every provider key is a single high-value target. Key management for AI systems covers both sides of that tradeoff.
Prompt injection and jailbreak detection. Inspecting inbound requests for attempts to override system instructions.
Output guardrails. Inspecting responses before they reach a user, for harmful content, hallucinated claims in high-stakes contexts, or data that should not have come back.
Streaming passthrough and timeout control. Whether the gateway streams tokens through without buffering, and whether you can set timeouts per model. A gateway that buffers a streaming response destroys your time to first token.
Region enforcement. Guaranteeing inference stays in a specified region, including on failover. Ask about model provenance in the same conversation. Most gateways carry open-weight models trained by providers subject to foreign jurisdiction (Aptible included), and in October 2026 Cohere published findings that a widely used open-weight model attempted unauthorized outbound network activity during security testing, including host reconnaissance and an attempted upload to cloud storage in Beijing. Region enforcement controls where the gateway routes your request; it doesn’t control what a model attempts once it is running (which is an argument for denying agent egress by default rather than filtering it, and for treating data residency as a routing control rather than a procurement checkbox).
Caching. Returning stored responses for repeated prompts. Exact-match caching is predictable. Semantic caching returns a stored answer for a prompt that is similar rather than identical, which is a cost win but a correctness risk. Either one is a liability if the cache holds sensitive data you haven’t accounted for.
De-identification. Scrubbing sensitive values before a request reaches a model or a log, and restoring them in the response. This is the capability moving fastest in the category, so verify it per vendor rather than trusting any comparison, including this one.
No, an LLM gateway doesn’t make you HIPAA compliant
This is the most common misconception about the category, and it costs teams lots of money when they discover it during a security review instead of before one.
A gateway is only one control in a compliance program. It can carry a meaningful share of the work, but it cannot make a system compliant on its own. No vendor can reasonably sell you compliance as a product.
Three specific errors account for most of the confusion:
1. Self-hosting the gateway doesn’t change your obligations
Here’s the most expensive misunderstanding. The reasoning sounds right: run the proxy inside your own VPC, no third party in the data path, no vendor to trust.
But a self-hosted gateway still sends prompts to hosted model providers. Those providers receive your data. Every one of them that receives protected health information needs a business associate agreement with you. 45 CFR 164.502(e) permits the disclosure only where you have obtained "satisfactory assurance that the business associate will appropriately safeguard the information," and 45 CFR 164.504(e) sets out what that contract has to contain. The gateway's network location has no bearing on it, because the gateway is not the thing receiving the PHI at the far end.
So self-hosting removes a vendor from the middle of the path and leaves the providers at the end of it untouched. But it adds operational work: you patch the gateway, rotate its credentials, control who can read its logs, prove retention to an auditor, and negotiate a separate BAA with every provider. Then you do it again when adding a new model.
It also makes you responsible for responding when the gateway itself is compromised. For example, in October 2026, a malicious release of LiteLLM reached PyPI and Docker registries carrying a credential stealer that targeted exactly what a gateway host has sitting around: cloud credentials, model provider API keys, SSH keys, and the gateway's own database credentials, pulled by direct SQL query. The entry point was an administrative key committed to a public repo five months earlier. LiteLLM published the full attack chain and Microsoft analyzed the payload. Someone had to notice, assess exposure, and rotate every credential that host could reach. On a self-hosted proxy, that someone is on your team.
None of that makes self-hosting wrong. If your requirement is that no third party sits in the inference path, self-hosting is the only thing that satisfies it, and LiteLLM and Bifrost are both solid choices.
2. A provider BAA doesn’t cover your gateway

A BAA from OpenAI or Anthropic covers that provider's liability for its own service. It doesn’t cover your gateway, your logs, your retention, your access controls, or the other providers you added last quarter. If the scope of a BAA is fuzzy to you, then start there.
If you sign BAAs provider by provider, you own the coverage map: which agreements exist, which models each one covers, which preview releases are excluded, and what happens when a request fails over to a provider you never signed with.
A managed gateway that signs its own BAA covering every provider behind it collapses that map to one agreement. Whether yours does or not is a question to ask directly (don’t forget to ask about specific models rather than in general).
3. Gateway logs are a PHI repository
Gateway logs contain every prompt and every response your application has ever sent. If any of those prompts contained PHI, the log is a PHI repository with everything that implies: retention obligations, access controls, encryption at rest and in transit, and an audit trail of who read it.
Teams routinely treat these like application logs, which means they land in whatever log aggregator the rest of the stack uses, readable by anyone with a dashboard login, retained according to whatever the default happens to be.
HIPAA's audit controls standard at 45 CFR 164.312(b) requires mechanisms that record and examine activity in systems containing ePHI, and a gateway carrying PHI is one of those systems. The Security Rule's documentation retention requirement at 45 CFR 164.316(b)(2) sets six years; once that period ends the logs still need secure disposal. A gateway that logs automatically and retains for the required duration is doing good compliance work. A gateway that logs to stdout has left you the retention, the access control, and the audit trail. (Note: there’s a further gap between logs that satisfy an auditor and logs your security team can investigate with, which is a different standard and a separate decision.)
Ask who in your organization can read stored prompts and responses, and whether you can restrict it. Granularity here varies a lot between vendors, and "the whole engineering team" is a common answer. Then ask: if a prompt containing PHI were accessed inappropriately, could you show which records were read, or only that you have no indication any were? Under 45 CFR 164.402, an impermissible use or disclosure of PHI is presumed to be a breach unless you can demonstrate "a low probability that the protected health information has been compromised" through a documented risk assessment.
4. What a gateway can actually carry
Compliance work | Can a gateway carry it? |
|---|---|
BAA coverage for model providers | Yes (if the vendor signs one covering providers behind it) |
Audit logging of prompts and responses | Yes |
Log retention for the required duration | Yes, if the vendor retains long enough to satisfy your obligation |
Access control over stored prompts | Partly; granularity varies |
Showing which records were accessed, not just that you have no evidence | Depends on log granularity |
Model and provider access policy | Yes, enforced centrally |
Region enforcement for inference | Yes, including on failover, if the vendor commits to it |
De-identification before the model sees data | Sometimes, depending on gateway |
Risk analysis, workforce training, policies, BCP | No. These are yours, under 45 CFR 164.308. |
TL;DR: a gateway governs model traffic only. Your compliance program covers your whole system; most of HIPAA's administrative requirements have nothing to do with the model request path at all.
Questions to ask a gateway vendor
The questions that separate a compliance badge from compliance coverage:
Compliance and BAA scope
Will you sign a BAA, on which tier, and can I see it before signing the contract?
Does that BAA cover the model providers behind your gateway, or only your own service?
Which models are excluded from coverage, including newest and preview releases?
Who in my organization can read stored prompts and responses, and can I restrict that?
How long are logs retained, and can I retrieve them six years from now?
If a prompt containing PHI were accessed inappropriately, can your logs show which records were read?
Do you have SOC 2 or HITRUST attestation, and can I see the report?
If a provider fails over, where does my request go, and is that target under the same BAA and in the same region?
Architecture and operations
For each open-weight model you offer, who trained it, and can you pin inference to a region?
Which provider-specific features survive your normalization layer, and which arrive as an untranslated passthrough?
Do you stream tokens through without buffering, and can I set timeouts per model?
What is your own availability history, and what happens to in-flight requests during your incidents?
Where to go next
If PHI is in your request path, one architectural question decides most of the rest: do you want one BAA or one per provider? Your answer determines your coverage map, your failover policy, and how much of the audit logging you end up building yourself.
Aptible's LLM Gateway is one managed answer to that question. Aptible signs one BAA that covers the supported models behind it: more than 150 across Anthropic, OpenAI, and open-weight families. The model list shows which are covered and which keep no data.
Request and response logging is automatic. Model access policy, per-key spend limits, and BAA signing lives in the product rather than in a support ticket. The platform also carries HITRUST R2-certified controls and SOC 2.
Adoption is a base URL and a key. The How it Works page walks through the integration for OpenAI-compatible SDKs, the Anthropic SDK, and Claude Code, and there is a $100 trial credit if you would rather test it than read about it.
If you’re earlier than this and HIPAA's requirements are themselves the unknown, start with the HIPAA compliance checklist instead.
FAQs
Does an LLM gateway make me HIPAA compliant?
No. A gateway can carry specific compliance work like BAA coverage for the providers behind it, automatic audit logging, retention, and model access policy. But it can't cover risk analysis, workforce training, policies, business continuity, or anything outside the model request path. Those remain your responsibility.
Does self-hosting an LLM gateway remove my BAA obligations?
No. A self-hosted gateway still sends prompts to hosted model providers, and each provider that receives PHI needs a BAA with you. Self-hosting removes a vendor from the middle of the path and changes nothing about the providers at the end of it.
Is an LLM gateway the same as an API gateway?
No. An API gateway routes HTTP by path and method and rate limits by request count. An LLM gateway understands tokens, models, streaming responses, and cost, and routes by model. Rate limiting by requests per second does not work when one request costs 200,000 tokens and the next costs 40.
Do I need an LLM gateway?
Not if you call one model from one provider, share credentials with nobody, and handle no regulated data. You probably do need one if you call multiple providers, need failover, share model credentials across teams, need enforceable spend limits, or have a regulatory obligation attached to the contents of your prompts.
What does it take to adopt an LLM gateway?
For most gateways, it just takes a base URL and an API key in the SDK you already use. The real migration cost is auditing which provider-specific features your prompts depend on, because prompt caching, extended thinking controls, structured outputs, and native tool-calling schemas do not always survive the normalization layer intact.
Can an LLM gateway change my model's output?
Yes. Failover routes a request to a different model than the one your prompt was tuned for. And a semantic cache can return a stored response for a prompt that is similar rather than identical. Both are features, and both change behavior without producing an error.
Does an LLM gateway add latency?
It adds a network hop. For a managed gateway that hop is relatively small compared to model response times measured in hundreds of milliseconds or seconds, but the number depends on where the gateway runs relative to your application and the provider. Caching and routing to a faster provider can make the end-to-end path quicker than a direct call. Measure it against your own traffic rather than trusting a vendor benchmark.
Can an LLM gateway stop prompt injection?
It can detect and block many attempts, but it's not a complete defense. Injection payloads can arrive through retrieved documents, tool outputs, and user content that never passes through the gateway as a prompt. Detection at the gateway is just one layer rather than a complete boundary.
How many models does an LLM gateway support?
It ranges from a handful to several hundred, but the count on its own isn't that important. What matters is which of them your BAA covers, which are excluded as preview releases, and who trained the open-weight ones. A gateway advertising 400 models where 20 are covered for PHI is worse for a regulated team than one advertising 50 that are all covered.
What is the difference between an LLM gateway and an LLM proxy?
In practice they're used interchangeably. "Proxy" tends to describe the routing and API-normalization function on its own, and "gateway" tends to imply governance on top: access policy, spend controls, logging, and guardrails. The distinction is marketing more than architecture, so read the capability list rather than the label.
An LLM gateway is a single API endpoint that sits between your application and the model providers it calls. Your code talks to the gateway; the gateway then talks to OpenAI, Anthropic, Google, Bedrock, or a self-hosted open-weight model. It handles routing, failover, authentication, rate limiting, spend tracking, and logging on the way through.

A gateway turns "which provider am I calling and how do I authenticate to it" into a configuration problem instead of a code problem. Adoption usually costs you a base URL and an API key, because most gateways expose an OpenAI-compatible interface. OpenRouter documents the OpenAI SDK pointed at its endpoint as "a drop-in replacement," and LiteLLM documents the same two-field change against a self-hosted proxy.
Plenty of teams don’t need a gateway. If you call a single model from a single provider and no regulated data is involved, a gateway is a dependency and a network hop that buys you very little. The rest of this post covers what a gateway gets you when you do need it, what it quietly costs you in provider-specific features, and misconceptions about it that gets teams in regulated industries into trouble.
The TL;DR
An LLM gateway is a proxy for model traffic. One endpoint, one credential, many providers behind it.
It solves provider abstraction, failover, centralized spend and rate limits, and request logging.
Adoption is usually a base URL and key change, since most gateways speak an OpenAI-compatible dialect.
The abstraction is lossy. Prompt caching, extended thinking controls, structured outputs, and native tool-calling schemas often do not survive normalization intact.
It is not an API gateway. API gateways route HTTP by path and method. LLM gateways understand tokens, models, streaming responses, and cost.
It does not make you HIPAA compliant (and self-hosting it doesn’t reduce your obligations either). Prompts still reach hosted providers, and every provider that receives PHI needs a business associate agreement (BAA) with you.
What a gateway can do is carry specific compliance work for you: BAA scope, audit logging, retention, access control, model access policy, and region enforcement. Whether or not yours does depends on the vendor.
What an LLM gateway actually does
Below are four main functions, roughly in the same order that teams discover they need them.
One API format across providers
Every provider has its own request shape, its own authentication, its own streaming format, and its own idea of what an error looks like. Writing against three of them directly means three integrations and three sets of edge cases.
A gateway normalizes that. Most of them expose an OpenAI-compatible interface, so switching from one model to another is a string change instead of a rewrite. This is the function that gets teams in the door, but it’s the least interesting one.
It’s also lossy, with tool definitions being the clearest case: OpenAI takes a tool's JSON Schema in a parameters field, and Anthropic takes the same schema in input_schema. A normalized layer either translates between shapes like that or hands them through untouched. LiteLLM documents the handing-through approach plainly: it "treats any non-openai param, as a provider-specific param, and passes it to the provider in the request body, as a kwarg," while noting that providers offer params OpenAI does not have. Prompt caching, extended thinking controls, structured output modes, and provider-specific sampling parameters all live in that category. Anthropic's prompt caching, for one, is requested with a cache_control block that has no OpenAI equivalent.
Check how your gateway handles the specific features your prompts depend on before you assume a model swap is a one-line change.
In practice. A pharmacy-operations company standardized on one hosted provider years ago because it was the only one that would sign a BAA at their size. They pay for that now in integration friction: the SDK provider package lags the API, and provider-side changes break their calls until the library catches up. Fine-tuning costs them a dedicated instance with a five-figure monthly floor. Behind a gateway, their existing client library works against the provider they already pay for, because the gateway speaks the dialect the ecosystem targets, and the next provider they add is a model string rather than a second integration.
Routing and failover
Providers have outages, rate limits, and capacity ceilings. When a request fails, something has to decide whether to retry, wait, or send it somewhere else.
Doing that in application code means every service that calls a model needs its own retry logic and its own fallback list. A gateway centralizes the policy: primary model, fallback model, retry budget, timeout. One place to change it when a provider degrades.
There are two downsides to failover, though. A request that fails over to a different provider hands your data to that provider, which matters a great deal if you have a BAA with one and not the other. And your prompts were tuned against a specific model, so silent failover changes output quality in ways your evals may not catch and your error rates will not show. Decide which is worse for your product (between a degraded answer or a failed request), because a default fallback chain makes that choice for you.
In practice. A medication-adherence company parses inbound patient texts with an LLM, replacing a rule-based system. When the provider degrades, patient messages stop getting parsed, so they added a fallback to a second provider they already had coverage for. That coverage came from a workspace agreement in place for office software, which extended to the vendor's model. An inventory of their AI vendors would not have turned it up. A gateway collapses both halves of that into one place: the fallback policy becomes configuration instead of retry logic in every service, and if the gateway's own BAA covers the providers behind it, the fallback target is in scope by default rather than by contract archaeology.
Centralized spend and rate limits
Model spend is easy to lose track of because it accrues per token across teams, environments, and features, and nobody notices until the invoice arrives.
A gateway is the natural place to attribute cost, because every request passes through it. That gives you per-key, per-team, or per-feature spend tracking, plus rate limits and budget controls that can actually reject a request rather than just reporting on it after the fact.
In practice. A telehealth company running several internal agents sits between $6,000 and $10,000 a month on model spend, and the number moves as they find out which workflows are expensive. One of those agents batch-reschedules two to three hundred patients at a time across hundreds of parallel instances. They moved it from the premium model to the cheaper one in the same family after measuring that it held roughly 95% of the quality for that task. A second team, on a single provider, built their own service to track who was using what and what each call cost. Give each agent its own gateway key and that build goes away: cost per workload becomes a dashboard read, and a per-key limit that rejects requests bounds what a misbehaving agent can spend before anyone notices it.
Request and response logging
The gateway sees every prompt and every response. That makes it the only place in the stack where you can get complete observability over model behavior without instrumenting every caller: latency, token counts, error rates, which prompts produce which outputs.
It also makes gateway logs the highest-sensitivity data store in your AI architecture, which almost nobody plans for on day one. More on that below.
In practice. A digital health company serving the hospice market started getting customer security questionnaires with a new AI section, asking about audit logging, training-data use, and AI supply chain. Unfortunately, logging that you haven’t built yet can’t be backfilled for the period covered by a security questionnaire you weren’t prepared for. A gateway that logs by default covers the period before anyone thought to ask. Getting that record out into the SIEM you already pay for is the part that varies, so ask your gateway provider about log export before you need it.
Do you actually need an LLM Gateway?
Direct API calls are the right answer for a lot of teams, and it’s certainly more frequent than most gateway vendors suggest.
Call providers directly when you use one model from one provider, you have no multi-team spend attribution problem, your logging needs are satisfied by application logs, and you aren’t handling regulated data.
Use a gateway when any of the following is true:
You call more than one provider (or expect to)
You need failover because model availability affects your product's availability
More than one team or environment shares model credentials
You need spend attribution or enforceable budget limits
You need a complete, centralized record of prompts and responses
You have a regulatory obligation attached to the data in those prompts
The usual sequence is direct calls first, then a gateway at the first of these triggers: a second provider, a credential shared across teams, a spend number nobody can attribute, or regulated data entering a prompt.
Note: the regulated-data trigger changes the decision more than the rest combined, because it moves the gateway from an operational convenience to a control point you have to be able to defend to an auditor.
What adoption actually costs
The integration. Most gateways expose an OpenAI-compatible endpoint, so adoption is a base URL and an API key in the SDK you already use. For an app already running the OpenAI or Anthropic client libraries, that’s just a config change. Coding agents that accept a custom endpoint (Claude Code among them) point at a gateway the same way.
The features you give up. The lossy normalization mentioned above is the real cost of a gateway pattern, and it’s usually only noticed after a migration. Audit which provider-specific capabilities your prompts depend on before you move.
The operational surface. A gateway sits in the critical path of every model call. Its availability becomes your availability, its logs become your most sensitive data store, and its credentials become the keys to every provider behind it. A managed gateway moves that work to a vendor. A self-hosted one keeps it, including patching and incident response.
LLM gateway versus API gateway versus MCP gateway
Routes by | Understands | Governs | |
|---|---|---|---|
API gateway | Path, method, header | HTTP requests | Your API |
LLM gateway | Model | Tokens, streaming, cost | Your model traffic |
MCP gateway | Tool | Tool calls and their arguments | Your agent's actions |
An API gateway (Kong, Apigee, AWS API Gateway) routes HTTP traffic by path, method, and header. It handles authentication, rate limiting by request count, and TLS termination. It has no concept of a token, a model, or a streaming completion. You can put an LLM behind one, but rate limiting by requests per second does not help when one request costs 200,000 tokens and the next costs 40. Kong says the same thing about its own two products: "If you just add an LLM's API behind Kong Gateway, you can only interact at the API level with internal traffic," which is the reason it ships a separate AI Gateway that can read the prompts going through it.
An LLM gateway understands the shape of model traffic. It counts tokens, normalizes across provider APIs, handles streaming responses, routes by model rather than by path, and attributes cost. Several vendors ship both products, which is why the categories blur.
An MCP gateway sits one layer up (in front of the tools a model can call rather than in front of the model itself). Model Context Protocol servers expose data sources, tools, and workflows to an AI application, and an MCP gateway governs which tools are reachable, what arguments are permitted, and what the agent is allowed to do with the results. If your concern is what an agent can execute rather than which model answers it, that’s a different product. We cover that distinction in the MCP security guide.
Teams running agents in production usually end up needing more than one of the three.
Capabilities to expect
Beyond the four core functions, the capabilities that separate a thin proxy from something you can run production traffic through are:
Model access policy. Restricting which models and providers are reachable, enforced centrally rather than by convention. Without this, any engineer with a gateway key can send data to any model you have configured.
Key management. Issuing, scoping, and rotating credentials per team or environment, so the gateway holds the provider keys and your services never see them. This is one of the stronger security arguments for a gateway: one credential to rotate instead of provider keys scattered across every service. It’s also, ironically, the counterargument: a gateway that holds every provider key is a single high-value target. Key management for AI systems covers both sides of that tradeoff.
Prompt injection and jailbreak detection. Inspecting inbound requests for attempts to override system instructions.
Output guardrails. Inspecting responses before they reach a user, for harmful content, hallucinated claims in high-stakes contexts, or data that should not have come back.
Streaming passthrough and timeout control. Whether the gateway streams tokens through without buffering, and whether you can set timeouts per model. A gateway that buffers a streaming response destroys your time to first token.
Region enforcement. Guaranteeing inference stays in a specified region, including on failover. Ask about model provenance in the same conversation. Most gateways carry open-weight models trained by providers subject to foreign jurisdiction (Aptible included), and in October 2026 Cohere published findings that a widely used open-weight model attempted unauthorized outbound network activity during security testing, including host reconnaissance and an attempted upload to cloud storage in Beijing. Region enforcement controls where the gateway routes your request; it doesn’t control what a model attempts once it is running (which is an argument for denying agent egress by default rather than filtering it, and for treating data residency as a routing control rather than a procurement checkbox).
Caching. Returning stored responses for repeated prompts. Exact-match caching is predictable. Semantic caching returns a stored answer for a prompt that is similar rather than identical, which is a cost win but a correctness risk. Either one is a liability if the cache holds sensitive data you haven’t accounted for.
De-identification. Scrubbing sensitive values before a request reaches a model or a log, and restoring them in the response. This is the capability moving fastest in the category, so verify it per vendor rather than trusting any comparison, including this one.
No, an LLM gateway doesn’t make you HIPAA compliant
This is the most common misconception about the category, and it costs teams lots of money when they discover it during a security review instead of before one.
A gateway is only one control in a compliance program. It can carry a meaningful share of the work, but it cannot make a system compliant on its own. No vendor can reasonably sell you compliance as a product.
Three specific errors account for most of the confusion:
1. Self-hosting the gateway doesn’t change your obligations
Here’s the most expensive misunderstanding. The reasoning sounds right: run the proxy inside your own VPC, no third party in the data path, no vendor to trust.
But a self-hosted gateway still sends prompts to hosted model providers. Those providers receive your data. Every one of them that receives protected health information needs a business associate agreement with you. 45 CFR 164.502(e) permits the disclosure only where you have obtained "satisfactory assurance that the business associate will appropriately safeguard the information," and 45 CFR 164.504(e) sets out what that contract has to contain. The gateway's network location has no bearing on it, because the gateway is not the thing receiving the PHI at the far end.
So self-hosting removes a vendor from the middle of the path and leaves the providers at the end of it untouched. But it adds operational work: you patch the gateway, rotate its credentials, control who can read its logs, prove retention to an auditor, and negotiate a separate BAA with every provider. Then you do it again when adding a new model.
It also makes you responsible for responding when the gateway itself is compromised. For example, in October 2026, a malicious release of LiteLLM reached PyPI and Docker registries carrying a credential stealer that targeted exactly what a gateway host has sitting around: cloud credentials, model provider API keys, SSH keys, and the gateway's own database credentials, pulled by direct SQL query. The entry point was an administrative key committed to a public repo five months earlier. LiteLLM published the full attack chain and Microsoft analyzed the payload. Someone had to notice, assess exposure, and rotate every credential that host could reach. On a self-hosted proxy, that someone is on your team.
None of that makes self-hosting wrong. If your requirement is that no third party sits in the inference path, self-hosting is the only thing that satisfies it, and LiteLLM and Bifrost are both solid choices.
2. A provider BAA doesn’t cover your gateway

A BAA from OpenAI or Anthropic covers that provider's liability for its own service. It doesn’t cover your gateway, your logs, your retention, your access controls, or the other providers you added last quarter. If the scope of a BAA is fuzzy to you, then start there.
If you sign BAAs provider by provider, you own the coverage map: which agreements exist, which models each one covers, which preview releases are excluded, and what happens when a request fails over to a provider you never signed with.
A managed gateway that signs its own BAA covering every provider behind it collapses that map to one agreement. Whether yours does or not is a question to ask directly (don’t forget to ask about specific models rather than in general).
3. Gateway logs are a PHI repository
Gateway logs contain every prompt and every response your application has ever sent. If any of those prompts contained PHI, the log is a PHI repository with everything that implies: retention obligations, access controls, encryption at rest and in transit, and an audit trail of who read it.
Teams routinely treat these like application logs, which means they land in whatever log aggregator the rest of the stack uses, readable by anyone with a dashboard login, retained according to whatever the default happens to be.
HIPAA's audit controls standard at 45 CFR 164.312(b) requires mechanisms that record and examine activity in systems containing ePHI, and a gateway carrying PHI is one of those systems. The Security Rule's documentation retention requirement at 45 CFR 164.316(b)(2) sets six years; once that period ends the logs still need secure disposal. A gateway that logs automatically and retains for the required duration is doing good compliance work. A gateway that logs to stdout has left you the retention, the access control, and the audit trail. (Note: there’s a further gap between logs that satisfy an auditor and logs your security team can investigate with, which is a different standard and a separate decision.)
Ask who in your organization can read stored prompts and responses, and whether you can restrict it. Granularity here varies a lot between vendors, and "the whole engineering team" is a common answer. Then ask: if a prompt containing PHI were accessed inappropriately, could you show which records were read, or only that you have no indication any were? Under 45 CFR 164.402, an impermissible use or disclosure of PHI is presumed to be a breach unless you can demonstrate "a low probability that the protected health information has been compromised" through a documented risk assessment.
4. What a gateway can actually carry
Compliance work | Can a gateway carry it? |
|---|---|
BAA coverage for model providers | Yes (if the vendor signs one covering providers behind it) |
Audit logging of prompts and responses | Yes |
Log retention for the required duration | Yes, if the vendor retains long enough to satisfy your obligation |
Access control over stored prompts | Partly; granularity varies |
Showing which records were accessed, not just that you have no evidence | Depends on log granularity |
Model and provider access policy | Yes, enforced centrally |
Region enforcement for inference | Yes, including on failover, if the vendor commits to it |
De-identification before the model sees data | Sometimes, depending on gateway |
Risk analysis, workforce training, policies, BCP | No. These are yours, under 45 CFR 164.308. |
TL;DR: a gateway governs model traffic only. Your compliance program covers your whole system; most of HIPAA's administrative requirements have nothing to do with the model request path at all.
Questions to ask a gateway vendor
The questions that separate a compliance badge from compliance coverage:
Compliance and BAA scope
Will you sign a BAA, on which tier, and can I see it before signing the contract?
Does that BAA cover the model providers behind your gateway, or only your own service?
Which models are excluded from coverage, including newest and preview releases?
Who in my organization can read stored prompts and responses, and can I restrict that?
How long are logs retained, and can I retrieve them six years from now?
If a prompt containing PHI were accessed inappropriately, can your logs show which records were read?
Do you have SOC 2 or HITRUST attestation, and can I see the report?
If a provider fails over, where does my request go, and is that target under the same BAA and in the same region?
Architecture and operations
For each open-weight model you offer, who trained it, and can you pin inference to a region?
Which provider-specific features survive your normalization layer, and which arrive as an untranslated passthrough?
Do you stream tokens through without buffering, and can I set timeouts per model?
What is your own availability history, and what happens to in-flight requests during your incidents?
Where to go next
If PHI is in your request path, one architectural question decides most of the rest: do you want one BAA or one per provider? Your answer determines your coverage map, your failover policy, and how much of the audit logging you end up building yourself.
Aptible's LLM Gateway is one managed answer to that question. Aptible signs one BAA that covers the supported models behind it: more than 150 across Anthropic, OpenAI, and open-weight families. The model list shows which are covered and which keep no data.
Request and response logging is automatic. Model access policy, per-key spend limits, and BAA signing lives in the product rather than in a support ticket. The platform also carries HITRUST R2-certified controls and SOC 2.
Adoption is a base URL and a key. The How it Works page walks through the integration for OpenAI-compatible SDKs, the Anthropic SDK, and Claude Code, and there is a $100 trial credit if you would rather test it than read about it.
If you’re earlier than this and HIPAA's requirements are themselves the unknown, start with the HIPAA compliance checklist instead.
FAQs
Does an LLM gateway make me HIPAA compliant?
No. A gateway can carry specific compliance work like BAA coverage for the providers behind it, automatic audit logging, retention, and model access policy. But it can't cover risk analysis, workforce training, policies, business continuity, or anything outside the model request path. Those remain your responsibility.
Does self-hosting an LLM gateway remove my BAA obligations?
No. A self-hosted gateway still sends prompts to hosted model providers, and each provider that receives PHI needs a BAA with you. Self-hosting removes a vendor from the middle of the path and changes nothing about the providers at the end of it.
Is an LLM gateway the same as an API gateway?
No. An API gateway routes HTTP by path and method and rate limits by request count. An LLM gateway understands tokens, models, streaming responses, and cost, and routes by model. Rate limiting by requests per second does not work when one request costs 200,000 tokens and the next costs 40.
Do I need an LLM gateway?
Not if you call one model from one provider, share credentials with nobody, and handle no regulated data. You probably do need one if you call multiple providers, need failover, share model credentials across teams, need enforceable spend limits, or have a regulatory obligation attached to the contents of your prompts.
What does it take to adopt an LLM gateway?
For most gateways, it just takes a base URL and an API key in the SDK you already use. The real migration cost is auditing which provider-specific features your prompts depend on, because prompt caching, extended thinking controls, structured outputs, and native tool-calling schemas do not always survive the normalization layer intact.
Can an LLM gateway change my model's output?
Yes. Failover routes a request to a different model than the one your prompt was tuned for. And a semantic cache can return a stored response for a prompt that is similar rather than identical. Both are features, and both change behavior without producing an error.
Does an LLM gateway add latency?
It adds a network hop. For a managed gateway that hop is relatively small compared to model response times measured in hundreds of milliseconds or seconds, but the number depends on where the gateway runs relative to your application and the provider. Caching and routing to a faster provider can make the end-to-end path quicker than a direct call. Measure it against your own traffic rather than trusting a vendor benchmark.
Can an LLM gateway stop prompt injection?
It can detect and block many attempts, but it's not a complete defense. Injection payloads can arrive through retrieved documents, tool outputs, and user content that never passes through the gateway as a prompt. Detection at the gateway is just one layer rather than a complete boundary.
How many models does an LLM gateway support?
It ranges from a handful to several hundred, but the count on its own isn't that important. What matters is which of them your BAA covers, which are excluded as preview releases, and who trained the open-weight ones. A gateway advertising 400 models where 20 are covered for PHI is worse for a regulated team than one advertising 50 that are all covered.
What is the difference between an LLM gateway and an LLM proxy?
In practice they're used interchangeably. "Proxy" tends to describe the routing and API-normalization function on its own, and "gateway" tends to imply governance on top: access policy, spend controls, logging, and guardrails. The distinction is marketing more than architecture, so read the capability list rather than the label.
Related posts
More on this topic from the Aptible blog.
More on this topic from the Aptible blog.
548 Market St #75826 San Francisco, CA 94104
© 2026. All rights reserved. Privacy Policy
548 Market St #75826 San Francisco, CA 94104
© 2026. All rights reserved. Privacy Policy
548 Market St #75826 San Francisco, CA 94104
© 2026. All rights reserved. Privacy Policy



