Home / Insights / Generative AI and LLMs

Generative AI and LLMs

LLM Gateways and Model Routing: Using Several Models Without Vendor Lock-In

Most organisations that ship more than one AI feature end up using more than one model. An LLM gateway gives you one place to route, secure, observe and pay for those calls, and keeps the option to change providers without rewriting your applications.

TopicsGenerative AI and LLMsArchitecture and Modernization

Key takeaways

  • An LLM gateway is a thin internal layer between your applications and model providers that centralises authentication, routing, quotas, logging and fallbacks.
  • Routing pays off when requests vary in difficulty: research such as FrugalGPT and RouteLLM shows large cost reductions from sending easy queries to cheaper models.
  • Lock-in rarely comes from the API call itself; it comes from prompts, schemas, evaluation data and provider-specific features spread across codebases.
  • Models are retired on a schedule, so a gateway plus an evaluation suite turns forced migrations into configuration changes you can test.
  • Start small: a gateway with a common interface, per-feature model configuration and logging delivers most of the value before any automated routing.

A year ago, many teams picked one model provider and called its SDK directly from each application. That was reasonable for a first feature. By now, most organisations we work with have several AI features in production or close to it: a support assistant, a document extraction pipeline, a summarisation job, perhaps an internal agent. Each has different quality, latency, cost and data-handling needs, and no single model is the best answer to all of them.

Calling several providers directly from several applications quickly becomes hard to govern. Keys are scattered, costs are hard to attribute, every team writes its own retry logic, and changing a model means changing code in many places. An LLM gateway addresses this by putting one controlled layer between your software and the models. This article is for CTOs, architects and engineering leads. It explains what a gateway does, when routing between models is worth it, the build and buy options, how to implement one, and how to keep the architecture portable.

What is an LLM gateway and what problems does it solve?

An LLM gateway is a service, or a configured API management layer, that every application uses to reach language models. Applications call the gateway with a consistent request format; the gateway decides which provider and model to call, applies policies, and returns a consistent response.

Typical responsibilities

  • Unified interface. One request and response format for chat, embeddings and tool calls, regardless of provider.
  • Credentials. Provider keys live in the gateway, not in each application.
  • Routing and fallbacks. Send each request to the configured model, and fail over to an alternative when a provider is slow or unavailable.
  • Quotas and budgets. Token limits per application, team or customer.
  • Observability. Consistent logs, token counts, latency and cost per feature.
  • Policy enforcement. Redaction, content filtering, data residency rules and allowed-model lists.
  • Caching. Reusing answers for repeated or near-identical requests where that is safe.

Cloud API management products have added these capabilities explicitly. Microsoft’s documentation for AI gateway capabilities in Azure API Management, for example, describes token limit policies per consumer, token usage metrics, semantic caching, load balancing across backends with round-robin, weighted and priority strategies, and circuit breakers that stop sending traffic to unresponsive backends. Open-source proxies and commercial gateways offer similar features.

Why use several models at all?

Cost

Prices between models differ widely. The FrugalGPT paper (Chen, Zaharia and Zou, 2023) noted that fees across popular LLM APIs can differ by two orders of magnitude, and reported that a learned cascade of models could match the performance of the strongest model with up to 98% cost reduction on the tasks studied. The RouteLLM work, which trains routers to choose between a stronger and a weaker model per request, reported cost reductions of over two times in certain cases without reducing response quality. Your results will differ, but the principle holds: if many requests are easy, paying the top price for all of them is wasteful.

Fit for purpose

Different tasks reward different models. A fast, small model may be ideal for classification and routing; a larger model for complex reasoning; a specialist model for embeddings or speech; an open-weight model for workloads that must stay inside your own cloud account.

Resilience

Provider outages and rate limits happen. A fallback model, even a slightly weaker one, keeps a customer-facing feature available.

Forced change

Models are retired. OpenAI’s deprecations page records, for example, that gpt-3.5-turbo-0613 was announced for deprecation in November 2023 and shut down in September 2024, and that gpt-4-vision-preview was announced in June 2024 and shut down in December 2024. Every provider retires models. If model names are hard-coded across applications, each retirement becomes a cross-team project.

Which routing strategies are worth considering?

StrategyHow it worksBest forComplexity
Static per featureEach feature is configured to use a specific modelMost organisations, as a starting pointLow
Fallback chainPrimary model, then alternatives on error, timeout or rate limitCustomer-facing features that need availabilityLow
Weighted or canaryA percentage of traffic goes to a new model for comparisonSafe model upgrades and A/B evaluationMedium
Rule-basedRoute by request attributes: tenant, language, input length, data sensitivityResidency rules, premium tiers, long documentsMedium
CascadeTry a cheaper model; escalate if confidence or validation failsHigh-volume tasks with checkable outputsMedium to high
Learned routerA classifier predicts which model a request needsVery high volume with varied difficultyHigh

In practice, static per-feature configuration plus fallbacks delivers most of the operational value. Cascades and learned routers make sense once you have enough volume for the savings to matter and an evaluation set reliable enough to prove quality has not dropped.

When routing is not worth it

  • Volume is low, so the cost difference is small compared with engineering time.
  • Outputs cannot be checked automatically, so you cannot tell whether a cheaper model was good enough.
  • Prompts depend heavily on one model’s behaviour and would need re-tuning for each alternative.

Should you build, configure or buy a gateway?

There are three broad routes, and the right one depends on your existing platform and team.

Configure your existing API management

If you already run an API management platform, its AI gateway features may cover quotas, metrics, load balancing and caching with little new infrastructure. The trade-off is that these products tend to work best with their own cloud’s model services and may need custom policies for other providers.

Deploy an open-source or commercial gateway

Dedicated LLM proxies provide a unified API across many providers, spend tracking and fallbacks out of the box. Evaluate them like any infrastructure dependency: maturity, release cadence, security model, how keys are stored, and whether you can self-host.

Build a thin internal layer

A small internal library or service that wraps provider SDKs behind your own interface. It gives full control and fits naturally with your logging and authorisation, but you own maintenance as providers change their APIs.

CriterionConfigure API managementOpen-source or commercial gatewayBuild thin layer
Time to valueFast if already in useFastModerate
Multi-provider coverageVariesBroadWhatever you implement
Control and customisationPolicy-levelPlugin or config levelFull
Ongoing maintenanceLowUpgrades and patchingHighest
New lock-in riskTied to the API platformTied to the gateway projectLowest, but more code to own

For example, an illustrative mid-sized SaaS company already on Azure might start with API management policies for its Azure-hosted models, then add a lightweight internal adapter for one non-Azure provider. A start-up with no existing platform might deploy an open-source proxy in its own cloud account. Neither choice is permanent if your applications talk to your own interface rather than the gateway’s specifics.

How do you implement a gateway step by step?

  1. Inventory current usage. List every application calling a model, which provider and model it uses, the data it sends, and who owns it.
  2. Define your own interface. A request format with logical model names ("extraction-default", "chat-fast") rather than provider model IDs, and a response format with usage, latency and model actually used.
  3. Centralise credentials. Move provider keys into the gateway’s secret store and issue per-application credentials for the gateway itself.
  4. Add logging and cost attribution. Record application, feature, tenant, model, tokens, latency and outcome for every call, with redaction where content is sensitive. Our guide to observability with OpenTelemetry covers vendor-neutral tracing that works well here.
  5. Configure fallbacks and limits. Per feature: primary model, fallbacks, timeouts, retries, and token budgets.
  6. Migrate one feature at a time. Start with a low-risk internal feature, compare results before and after, then move on.
  7. Add evaluation gates. Before switching any feature’s model, run its evaluation set through the gateway against the candidate model and compare quality, cost and latency.
  8. Introduce smarter routing last. Canary traffic, rule-based routing or cascades, once the basics are stable and measured.

Where does lock-in really come from, and how do you limit it?

Switching the HTTP call from one provider to another is the easy part. Real lock-in sits elsewhere, and it is the same pattern we describe for infrastructure in cloud vendor lock-in: accept some, but know where it is and keep an exit path.

Sources of lock-in

  • Prompts tuned to one model. Wording, examples and formatting that work well on one model may underperform on another.
  • Provider-specific features. Structured output modes, tool-calling formats, caching mechanisms, file and assistant APIs, and built-in tools differ between providers.
  • Embeddings. Vectors from one embedding model cannot be searched with another, so changing embeddings means re-indexing.
  • Fine-tuned models. A model fine-tuned on one platform usually cannot be moved.
  • Contracts and data terms. Committed spend, data processing agreements and residency commitments.

Practical mitigations

  • Keep prompts and schemas in version control, outside application code, with a variant per model family where needed.
  • Prefer features with equivalents across providers; isolate the rest behind adapters.
  • Maintain an evaluation suite per feature so you can measure any candidate model quickly.
  • Store source text and metadata for anything you embed, so re-embedding is possible.
  • Review provider deprecation notices as part of regular operations, not as surprises.

What are the risks and costs, and what is the checklist?

Risks to manage

  • A new single point of failure. Run the gateway with redundancy and health checks, and keep its logic simple.
  • Added latency. Usually small for a well-placed proxy, but measure it, especially for streaming responses.
  • Sensitive data in logs. Central logging is valuable and risky; redact, restrict access and set retention.
  • Silent quality drops. Fallbacks and cheaper routes can lower quality without anyone noticing unless outcomes are monitored.
  • Governance drift. Without ownership, gateway configuration becomes another unmanaged system. Assign a platform owner.

Gateway readiness checklist

  1. All model calls go through one interface with logical model names.
  2. Provider keys are stored centrally; applications hold only gateway credentials.
  3. Every call is logged with feature, tenant, model, tokens, latency and cost, with redaction rules.
  4. Each feature has a primary model, fallbacks, timeouts and token budgets.
  5. Each feature has an evaluation set that runs before any model change.
  6. Data residency and allowed-model rules are enforced at the gateway.
  7. Deprecation notices from each provider are tracked with owners and dates.
  8. The gateway itself is monitored, redundant and owned.

PoliteTech’s LLM application development team builds production AI features with retries, timeouts, caching, typed outputs and fallback models, compares models and prompts on quality, cost and speed, and sets up LLMOps monitoring, prompt versioning and cost dashboards. A gateway is often where those pieces come together.

Frequently asked questions

Do we need an LLM gateway if we only use one provider?

Not necessarily on day one, but a thin internal interface is still worth having. It centralises keys, logging and budgets, and it makes future model upgrades and provider changes much cheaper.

Will routing to cheaper models reduce quality?

It can, which is why routing should be backed by an evaluation set and monitoring. Research such as FrugalGPT and RouteLLM shows large savings are possible without quality loss on the tasks studied, but you need to verify that on your own workload.

Does a gateway add noticeable latency?

Usually little compared with model response time, but it depends on where it runs and what policies it applies. Measure time to first token and total latency before and after introducing it.

Can a gateway enforce data residency?

Yes. Rules can restrict certain tenants or data classifications to models hosted in specific regions or in your own cloud account, and block requests that would breach them.

What is the first step for an organisation with several AI features already live?

Inventory every model call, then introduce a common interface with logical model names and central logging for one low-risk feature. Expand feature by feature, adding fallbacks and evaluation gates as you go.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. Microsoft Learn: AI gateway capabilities in Azure API Management — accessed 9 November 2026. Gateway features in a mainstream API platform: token limits, token metrics, semantic caching, backend load balancing and circuit breakers.
  2. Chen, Zaharia and Zou: FrugalGPT (arXiv, May 2023) — accessed 9 November 2026. LLM API fees differ by two orders of magnitude; model cascades matched GPT-4 performance with up to 98% cost reduction on studied tasks.
  3. Ong et al.: RouteLLM: Learning to Route LLMs with Preference Data (arXiv, 2024) — accessed 9 November 2026. Routers choosing between strong and weak models reduced costs by over two times in certain cases without quality loss.
  4. OpenAI: Deprecations (API documentation) — accessed 9 November 2026. Examples of model deprecation announcements and shutdown dates used to illustrate forced model migrations.

Could a gateway make your AI features cheaper and easier to change?

We can map your current model usage and design a gateway and routing approach that fits your platform, budget and data rules.