Imagine your AI provider suddenly becomes too expensive, or another provider releases a model that performs better for your use case. How difficult would it be to switch?
For some applications, switching providers is as simple as changing a configuration. For others, it means touching multiple parts of the codebase, rewriting API integrations, adjusting prompts, and retesting everything.
When you first integrate an AI model, using its official SDK and API makes sense. You get access to its features and can get your application running quickly.
But as your application grows, that integration can spread. Your backend starts depending on provider-specific request formats. Your error handling assumes a particular response structure. Your streaming implementation follows one provider's conventions. Even your logging and monitoring may be tied to its API.
Eventually, changing providers becomes more complicated than changing a model name.
Why switching providers becomes difficult
There are four areas where provider lock-in tends to show up.
1. Your application code
Different AI providers have different APIs, SDKs, request formats, and response structures.
For example, an application using Anthropic's SDK might make a request like this:
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const response = await anthropic.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [
{
role: "user",
content: "Explain how an AI gateway works.",
},
],
});
console.log(response.content);
Moving to another provider could mean replacing the SDK, changing how requests are constructed, and updating how responses are handled.
If these integrations are scattered across your application, the migration becomes even more tedious.
2. Model behaviour
Switching providers isn't just about getting your API requests to work.
Different models can interpret the same prompt differently. They may produce different response formats, follow instructions differently, or vary in how they handle structured output and tool calls.
This means you need to test more than whether the new provider returns a response. You need to verify that your application still behaves as expected.
3. Infrastructure and integrations
AI integrations often extend beyond the API request itself.
You might have streaming responses, tool calling, retry mechanisms, token usage tracking, and error handling built around a specific provider.
Some providers support certain features differently, and some expose capabilities that others don't.
When switching, you may need to revisit these integrations to make sure they still work correctly.
4. Operations and monitoring
You also need to consider what happens after deployment.
How do you track token usage? How do you monitor latency? How do you manage API keys? How do you identify failed requests?
If your monitoring and billing logic depend on provider-specific data, switching providers can introduce another layer of work.
The more of your infrastructure that depends on one provider, the harder it becomes to move away from it.
The solution: put an AI gateway between your application and providers
An AI gateway provides a consistent interface between your application and multiple model providers.
Your application sends requests to the gateway, and the gateway handles communication with the selected provider.
This gives you a central place to manage provider connections, model selection, API keys, and other AI-related infrastructure.
Migrating an application with Cencori
Cencori provides an AI gateway that lets you access different AI providers through a unified interface. It also supports an OpenAI-compatible API, so applications already using the OpenAI SDK can connect through Cencori by changing their API configuration.
Let's look at what that means in practice.
Using the Cencori SDK
You can use the Cencori SDK to make requests to different providers through the same interface.
For example:
import { Cencori } from "cencori";
const cencori = new Cencori({
apiKey: process.env.CENCORI_API_KEY,
});
const response = await cencori.ai.chat({
model: "claude-sonnet-4.5",
messages: [
{
role: "user",
content: "Explain how an AI gateway works.",
},
],
maxTokens: 1024,
});
console.log(response.content);
To use another supported model, you can change the model identifier without building another provider integration into your application.
The SDK also supports streaming and tool calling, so you can build applications that need more than basic text generation.
Using the OpenAI-compatible API
If your application already uses the OpenAI SDK, you may not need to replace it.
You can configure the client to send requests through Cencori instead:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.CENCORI_API_KEY,
baseURL: "https://api.cencori.com/v1",
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [
{
role: "user",
content: "Explain how an AI gateway works.",
},
],
});
console.log(response.choices[0].message.content);
This approach is particularly useful when you're migrating an existing application that already uses an OpenAI-compatible client.
For applications using a provider's native SDK, such as Anthropic's SDK, you may need to change the client and request interface to use the Cencori SDK or another supported integration.
The goal is to reduce how much provider-specific integration your application has to maintain.
You shouldn't have to start from scratch
You still need to evaluate the new model, test your prompts, verify feature compatibility, and make sure your application produces the expected results.
But you shouldn't have to rebuild your entire AI integration every time you want to try something new.
AI providers will continue releasing better models, adjusting their prices, and introducing new capabilities. Your application should be able to take advantage of those changes without becoming permanently tied to the provider you chose at the beginning.
That's the advantage of keeping your application separate from the infrastructure powering its AI features.

Top comments (0)