Answers you can trust, from Codeables
Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.
Explore CodeablesHow do we support multiple LLMs (OpenAI, Anthropic, Google) without creating a governance and vendor-lock-in mess?
For most teams, the excitement of plugging into OpenAI, Anthropic, and Google models quickly collides with a harsh reality: every new LLM adds more complexity, more governance risk, and more potential for vendor lock‑in. You want the freedom to route workloads to the best model for the job today—without making it impossible to switch providers tomorrow.
This article breaks down how to support multiple LLMs (OpenAI, Anthropic, Google, and others) in a way that is scalable, governable, and vendor‑neutral, while keeping your architecture lean and your compliance team calm.
The real problem: fragmentation, not just vendor lock‑in
When organizations start using multiple LLMs, they typically run into four intertwined problems:
-
Fragmented integrations
Each provider (OpenAI, Anthropic, Google) ships its own API shape, parameters, auth, rate limits, and tooling. Engineering teams end up building and maintaining separate code paths. -
Inconsistent governance and controls
Safety filters, logging, PII handling, retention, and redaction differ by vendor. That makes it hard to answer basic questions like:- Where did this answer come from?
- Which model generated it?
- Was PII exposed to an external vendor?
-
Hidden vendor lock‑in at the application layer
Even if you think you’re “multi‑LLM,” tightly coupling prompts, tools, or fine‑tuned logic to a single provider’s behaviors (or SDK) makes switching later expensive. -
Scaling chaos
As use grows, so do:- Rate limit juggling across vendors
- Cost optimization across models
- Reliability concerns (failover, circuit breakers)
Most teams solve these per‑app, creating a governance and operational mess.
The goal is not just “multi‑LLM support.” It’s multi‑LLM abstraction with centralized governance and minimal lock‑in.
Core principles for a clean multi‑LLM strategy
To support OpenAI, Anthropic, Google, and future providers without a governance or vendor-lock-in mess, design around these principles:
-
Abstract at the platform layer, not in each app
Build (or adopt) a single LLM access layer: a gateway or platform service that all applications call. That service then talks to external LLM vendors. -
Standardize interfaces and policies, not providers
Don’t try to force vendors to behave identically. Instead:- Define an internal, stable API schema
- Define internal governance policies
- Map each vendor to those standards
-
Decouple three things: logic, routing, and vendors
- Application logic (prompts, tools, workflows)
- Routing and orchestration (which model, failover, A/B testing)
- Vendor implementations (OpenAI, Anthropic, Google, self‑hosted)
-
Centralize observability and auditability
Logs, traces, redactions, and model selection decisions should live in one place where security and compliance can see them. -
Plan for portability from day one
Use neutral formats where possible (e.g., OpenAI‑compatible schemas, OpenAPI/JSON schemas, generic tool definitions) and avoid deep dependencies on vendor‑specific quirks unless absolutely necessary.
Architecture pattern: the LLM gateway
The most practical way to support multiple LLMs without chaos is to introduce an LLM gateway (sometimes called an “AI gateway,” “orchestration layer,” or “LLM router”).
1. High‑level architecture
A typical pattern looks like this:
-
Client applications
Chatbots, internal tools, customer‑facing apps, agents, workflows. -
LLM gateway (your platform)
- Single unified API for all LLM calls
- Governance policies (redaction, filtering, approvals)
- Routing/selection logic (model choice, fallbacks)
- Observability (metrics, logs, prompts, outputs)
-
Providers and runtimes
- OpenAI (GPT family, o3, embeddings)
- Anthropic (Claude family)
- Google (Gemini)
- Others: Cohere, Mistral, Azure OpenAI, self‑hosted open‑source models
All applications call the gateway. Only the gateway calls external vendors.
2. What the gateway standardizes
Your gateway should define a single internal contract that apps use, regardless of vendor:
-
Request schema:
modelormodel_groupinput/messages/system_prompttools/functions(if using tool calling)metadata(user, tenant, data classification)constraints(latency budgets, max cost, required regions)
-
Response schema:
output(final answer)reasoning/steps(if you keep structured reasoning)tokens(usage)model(actual provider/model used)trace_id,run_id
Internally, the gateway translates to the specifics of OpenAI, Anthropic, Google, etc. Externally, your apps remain stable—even when providers change.
Avoiding vendor lock‑in at the design level
Supporting multiple LLMs is not enough; you also want to avoid quietly locking yourself into one. Focus on these areas.
1. Use a neutral model naming convention
Instead of peppering app logic with provider‑specific names (e.g., "gpt-4.1", "claude-3-5-sonnet", "gemini-1.5-pro"), define logical model identifiers:
general_chat_advancedgeneral_chat_fastcode_generation_strictlegal_summary_precise
Your gateway maps those logical IDs to actual models per environment:
- In prod US:
general_chat_advanced→gpt-4.1-mini(OpenAI)general_chat_fast→claude-3-haiku(Anthropic)
- In EU or regulated:
general_chat_advanced→ Self‑hosted open‑source modelgeneral_chat_fast→ Gemini, depending on data residency rules
This lets you switch providers without touching every application.
2. Normalize prompts where it makes sense
Prompts often get tightly tuned to a specific provider. Mitigate lock‑in with:
- Prompt templates stored centrally, not hard‑coded in apps
- Shared instructions:
- Base system prompt (style, safety, tone)
- Domain‑specific blocks (legal, medical, finance)
- Versioning:
base_v1,base_v2,legal_v3, etc.
You can maintain small provider‑specific variants if needed, but keep the core structure and intent unified.
3. Standardize tool and function calling
Each vendor has its own flavor of tools/functions. To reduce lock‑in:
- Define tools in a vendor‑agnostic schema, e.g.:
- JSON schema
- OpenAPI
- Simple
{name, description, input_parameters}structure
- The gateway:
- Converts this schema into each provider’s native tool/function format
- Enforces which tools are allowed per app or per data classification
Applications don’t care whether they’re using OpenAI’s tools, Anthropic’s tools, or Google function calling—the interface is stable.
4. Keep application code vendor‑neutral
In code, isolate vendors via:
- Interfaces / adapters
E.g., useLLMClientorAIClientinterfaces instead of the vendor SDK types everywhere. - Configuration, not code, for routing
Model choice, temperature, top_p, provider preferences—put these in config or policy, not in scattered constants.
This pattern lets you easily drop in new vendors or self‑hosted models with limited changes.
Governance: centralizing safety and compliance across LLMs
Multi‑LLM architectures fail in practice when governance is an afterthought. The gateway is your best tool to avoid a governance mess.
1. Treat the gateway as a policy enforcement point
The gateway should enforce organization‑wide rules before and after every LLM call:
-
Input policies
- PII detection and redaction (e.g., names, SSNs, email, health data)
- Data residency checks (does this user’s data stay in EU?)
- Tenant isolation (no cross‑tenant leakage)
-
Output policies
- Safety filters (toxicity, harassment, self‑harm guidance, etc.)
- Hallucination mitigation (e.g., require citations for critical domains)
- Content classification or labeling (for compliance / analytics)
These policies should be provider‑agnostic, so you’re not reimplementing them per vendor.
2. Unify logging and auditing
Make the gateway the single source of truth for:
- Prompts and outputs (with configurable retention)
- Model used and parameters (temperature, top_p, tools allowed)
- User metadata (who requested what, from where)
- Routing decisions (why this provider/model was chosen)
- Safety and policy decisions (blocked, redacted, escalated)
Expose this through:
- Dashboards for product/eng
- Audit logs for security/compliance
- APIs for automated reporting and review
This is key to avoiding a governance mess as your multi‑LLM footprint grows.
3. Handle approvals and risk tiers centrally
Different workloads have different risk profiles. Encode that:
- Tiered risk model
- Tier 1: Internal experimentation; relaxed constraints
- Tier 2: Internal productivity; stronger safety and logging
- Tier 3: Customer‑facing; strict safety, logging, legal review
- Tier 4: Regulated/high‑risk; limited models and vendors allowed
The gateway enforces which models and providers are allowed per tier, which tools they can call, and what data can pass through.
Routing and orchestration: using the “best” LLM without chaos
Supporting multiple LLMs is only useful if you can intelligently route to the right one per request.
1. Basic routing strategies
Start with simple, transparent rules:
-
Static routing by use case
- Chat support → fast, cheap models
- Legal drafting → high‑accuracy, more expensive models
- Code review → models tuned for code
-
Feature‑based routing
- Need image understanding? Route to Gemini or GPT‑4o‑style models
- Need long context (hundreds of pages)? Route to models with extended context
-
Jurisdiction‑based routing
- EU users → EU‑compliant models and data centers
- US healthcare → specific HIPAA‑aligned models / vendors
2. Advanced routing: optimization and experimentation
Over time, add intelligence to the gateway:
-
Cost vs quality optimization
- Default to cheaper models
- Automatically escalate to more capable ones when:
- The task is complex (estimated via classifier)
- The first answer is low confidence (e.g., too short, missing required fields)
-
A/B testing & canary releases
- Route a percentage of traffic to a new model
- Compare quality, latency, and cost
- Gradually increase allocation if it performs well
-
Failover and resilience
- If OpenAI throttles or fails, automatically switch to Anthropic or Google for suitable tasks
- Define per‑workflow SLAs and enforce them via routing rules
Your goal is a routing brain that’s extensible and transparent, not a tangle of ad‑hoc if‑statements in every codebase.
Data strategy: keeping your data portable and governable
Supporting multiple LLMs without lock‑in also means treating your data (prompts, contexts, embeddings) with care.
1. Own your embeddings strategy
If you rely heavily on embeddings:
- Use vendor‑agnostic vector stores (e.g., Pinecone, Weaviate, pgvector, Qdrant) instead of vendor‑locked solutions when possible.
- Store metadata that lets you:
- Rebuild or migrate embeddings if you change providers
- Audit which data was embedded and why
- Consider a standard embedding interface through the gateway, same as for chat/completions.
2. Separate knowledge from models
Avoid fine‑tuning every vendor separately for knowledge that’s actually your own (docs, policies, FAQs). Instead:
- Use retrieval‑augmented generation (RAG) as your default:
- Keep your knowledge in a search index or vector store
- Use LLMs as reasoning layers on top of your data
- This makes it easier to swap LLMs, because the knowledge stays in your control.
If you do fine‑tune, treat it as an optimization layer, not your only representation of business logic or knowledge.
3. Define clear data sharing rules per provider
Not all providers are equal in terms of data residency, training usage, or compliance posture. Centralize rules such as:
- Which data classifications may be sent to which vendor
- Whether data can be used for model improvement (opt‑out where possible)
- What regions and endpoints are allowed
Again, the gateway is the enforcement point for these rules.
Practical implementation roadmap
Here’s a pragmatic path to supporting OpenAI, Anthropic, Google, and others without creating a governance and vendor-lock-in mess.
Phase 1: Stabilize the basics
- Introduce an LLM gateway service (or adopt a platform that acts like one)
- Define a unified request/response schema
- Implement adapters for:
- OpenAI
- Anthropic
- Google (Gemini)
- Centralize:
- Authentication to each vendor
- Basic logging (requests, responses, models used)
Phase 2: Centralize governance
- Add:
- PII detection & redaction in the gateway
- Basic safety filtering on outputs
- Data classification tags in requests
- Implement:
- Role‑based access to certain models/tools
- Simple routing by use case and region
Phase 3: Optimize and de‑risk
- Introduce:
- Logical model IDs (e.g.,
general_chat_advanced) - Provider‑agnostic tool definitions
- Centralized prompt templates with versioning
- Logical model IDs (e.g.,
- Build:
- A/B testing and canary mechanisms for new models
- Failover logic between vendors
Phase 4: Mature observability and policy
- Deploy dashboards for:
- Cost per provider and model
- Usage patterns by app and tier
- Safety incidents and policy blocks
- Formalize:
- Risk tiers and provider allowlists
- Data retention policies for prompts and outputs
At each phase, you can keep adding new models and vendors without rebuilding everything.
Common pitfalls to avoid
As you design multi‑LLM support around OpenAI, Anthropic, Google, and others, watch out for these traps:
-
Embedding vendor SDKs directly in every service
This creates deep coupling and makes large‑scale changes painful. Always go through your gateway or a clearly defined interface. -
Letting each team “do their own thing” with prompts and routing
You’ll end up with inconsistent quality and an unmanageable governance surface. Centralize shared templates and routing policies. -
Under‑investing in monitoring and auditability
Without good logs and metrics, you can’t manage risk or optimize cost/quality across vendors. -
Over‑fitting to one provider’s features
It’s fine to use unique features, but isolate them:- Keep them behind flags or feature‑specific abstractions
- Document where behavior depends on a specific model/provider
-
Treating “multi‑LLM” as a checkbox instead of a strategy
The point is flexibility, compliance, and control—not just having more logos on your architecture diagram.
Summary: multi‑LLM without the mess
To support multiple LLMs like OpenAI, Anthropic, and Google without creating governance chaos or vendor lock‑in:
- Centralize access through an LLM gateway
One API for all apps; adapters for all vendors. - Standardize your internal contract
Unified request/response schema, logical model IDs, and tool definitions. - Decouple applications from providers
Vendor‑neutral interfaces, prompts, and routing policies. - Make governance a first‑class concern
Policy enforcement, redaction, safety, logging, and auditing all live in the gateway. - Continuously optimize routing and models
Use routing, A/B tests, and metrics to choose the best model per use case over time.
Done well, this approach gives you freedom to switch providers, confidence in governance, and a clean path to scale as the LLM ecosystem evolves.