◀ Knowledge hub

03, AI & intelligence

Vendor neutral AI with the AI SDK and Gateway

codeAmani Labs Engineering
Cinematic still for Vendor neutral AI with the AI SDK and Gateway

Provider choice should be configuration, not code

The fastest way to paint yourself into a corner is to write your application against one AI vendor's client library. When that vendor has an outage, raises prices, or falls behind on capability, you are not changing a setting, you are rewriting code. A single interface across providers turns that rewrite into a one line change.

One interface, many providers

The AI SDK gives you a uniform way to call a model, and the Gateway lets you name the provider and model as a string. Swapping vendors is editing the string.

import { generateText } from "ai";

const { text } = await generateText({
  model: "anthropic/claude-sonnet-4-6",
  prompt: userPrompt,
});

To move that call to a different provider, you change "anthropic/claude-sonnet-4-6" to another "provider/model" string. The rest of the application does not know or care which vendor answered, because the shape of the call and the shape of the result are the same across all of them.

Fallback chains for reliability

Because the interface is uniform, you can try one provider and fall back to another when the first fails or is slow. The user sees an answer; they do not see which model produced it.

async function answer(prompt: string) {
  for (const model of ["openai/gpt", "anthropic/claude", "deepseek/chat"]) {
    try {
      return await generateText({ model, prompt });
    } catch {
      continue; // try the next provider
    }
  }
  throw new Error("all providers failed");
}

Cost is a dashboard, not a surprise

Routing every call through one gateway means every call is measured in one place. You see spend per provider, per model, and per feature, which is what lets you move high volume, low stakes work to a cheaper reasoning tier and keep the expensive model for the work that needs it.

Why neutrality is a procurement advantage

A buyer in government or healthcare does not want to hear that your product depends on one company's continued goodwill. "We can route to any major provider, and switching is a configuration change" is a much stronger answer than "we are an X shop". Vendor neutrality is not just engineering hygiene here, it is a thing you can put in a proposal.

Qualified conversation

Have a build to de-risk? Let's talk.

Tell us what you are building. We respond within two business days.