Topic 4 of 4 · 4 min read
Gateway lock-in, latency and data trade-offs
Goal: Weigh a hosted gateway against direct provider calls on latency, data handling, lock-in and availability.
A gateway adds convenience and takes something in return: an extra network hop, another party that may see your prompts, a new single point of failure, and compatibility gaps. Decide with a comparison, not a feeling.
Check yourself · 1 of 3
A hosted gateway sits in front of all your model calls. Which new risk does it add?
Why it matters
Teams often adopt a gateway for one clear benefit, such as budgets or fallbacks, and discover the costs later in an incident or a security review. Each cost can be managed, but only if you looked for it first.
The four trade-offs
- Latency. Every request goes app, gateway, provider, then back. A gateway in the same region as your app usually adds a small delay compared with a model call that takes seconds. A hosted gateway on another continent can add noticeably more. Measure it with your own traffic; do not trust a number from a blog post.
- Data handling. A hosted gateway sees prompts and responses, and may log them. Check its retention, who can read logs, whether it trains on data, and whether it can be hosted in your region. A self-hosted proxy such as LiteLLM keeps data inside your network but you operate it. Add the provider's own terms on top: the data now passes through two parties.
- Availability. The gateway is now in the path of every call. If it is down, every feature using a model is down, even when the providers are healthy. Your uptime cannot be higher than the gateway's unless you have a bypass.
- Lock-in and compatibility. The more of your setup lives in gateway features (virtual keys, routing rules, prompt stores), the harder it is to leave. Gateways also lag provider releases: a new parameter may not pass through yet, or may be translated imperfectly.
How to weigh it
Build a small table for your own case: rows for latency, data, availability, lock-in and operating effort; columns for "direct to providers", "hosted gateway" and "self-hosted gateway". Fill it with measured or documented facts. Then add mitigations: a direct-call fallback path, a region choice, keeping routing config in your own repo, and a log policy.
Before and after
Before: "We will use a hosted gateway, it is easy." After a review: the gateway handles budgets and logs, routing rules live in the app's repo, requests to one provider can bypass it behind a feature flag, and prompts that contain customer health data go direct to a provider under an existing contract.
What goes wrong
- Treating the gateway as free. Hosted tiers may charge a fee or a margin on usage; read the pricing page.
- No bypass. An outage of the gateway stops every AI feature at once.
- Sensitive data sent through a new party with no review of its logging.
- Config scattered across the vendor dashboard, so rebuilding elsewhere takes weeks.
Examples
The bypass flag
A team routes all calls through a hosted gateway. A feature flag lets one service call its provider directly. During a gateway incident they flip the flag for the checkout assistant and it keeps working, while less critical features stay down until the gateway recovers.
Health data stays direct
A clinic app uses a gateway for marketing copy and internal summaries. Patient notes go straight to a provider covered by the clinic's existing data agreement, so a new third party never sees them.
Key points
- Every gateway adds a network hop; measure the delay on your own traffic and region.
- A hosted gateway is another party that sees prompts; check its logging, retention and training terms.
- A gateway in the request path caps your availability unless you keep a direct bypass.
- Keep routing rules and config in your own repo to limit lock-in.
- Compare direct, hosted and self-hosted options in a table using documented or measured facts.
Common mistakes
- Adopting a hosted gateway without reading its logging, retention and training terms.
- Having no bypass, so a gateway outage disables every AI feature.
- Storing routing rules and prompts only in a vendor dashboard.
- Assuming a new provider parameter passes through the gateway unchanged.
Check yourself · 2 of 3
The hosted gateway has an outage while the providers are healthy. What would have kept critical features running?
Check yourself · 3 of 3
You must choose between a hosted gateway and a self-hosted proxy for prompts that contain customer data. What decides it most?
Practice items, not counted towards your mastery.
Start here
- LiteLLM documentation (opens in a new tab)DocsFree
One interface and proxy server for many providers, with keys, budgets and logging.
- OpenRouter quickstart (opens in a new tab)DocsFree
Calling many models through one OpenAI-compatible endpoint with one key.
- AI SDK: providers and models (opens in a new tab)DocsFree
How a provider-neutral SDK swaps models behind one function call.
More for this topic
- Cloudflare AI Gateway (opens in a new tab)DocsFree
A hosted gateway with caching, rate limits, logging and fallbacks in front of provider APIs.