Prompt
What should I use to avoid vendor lock-in with LLM APIs?
Latest observation
Oct 10, 2026
OpenAI APIWeb search: off
To avoid vendor lock-in with LLM APIs, use an abstraction layer between your app and the model provider.
Good options:
-
Provider-agnostic SDKs / gateways
- Examples: LiteLLM, OpenRouter, LangChain/LlamaIndex model wrappers
- These let you switch between OpenAI, Anthropic, Google, Azure, etc. with minimal code changes.
-
Your own thin wrapper
- Create an internal interface like:
generateText(prompt, options)embedText(text)streamChat(messages)
- Keep provider-specific code in adapters behind that interface.
- Create an internal interface like:
-
Standard request/response formats
- Normalize things like:
- chat message schema
- tool/function calling
- streaming events
- error handling
- This makes swapping providers easier.
- Normalize things like:
-
Model gateway / orchestration layer
- Route requests through a service that can:
- fail over to another model
- do A/B testing
- switch by cost/latency/quality
- Useful if you expect to manage multiple providers.
- Route requests through a service that can:
-
Avoid provider-specific features in core logic
- Minimize dependence on:
- proprietary function-calling formats
- custom safety settings
- special prompt templates
- vendor-only memory/session features
- Minimize dependence on:
-
Abstract embeddings, rerankers, and vector DBs too
- Lock-in often happens in the surrounding stack, not just the chat API.
Practical recommendation:
- If you want the fastest path: use LiteLLM or OpenRouter
- If you want the most control: build your own provider abstraction layer
- If you want enterprise routing/failover: use a model gateway
If you want, I can sketch a simple provider-agnostic interface in TypeScript, Python, or Go.