Reduce provider lock-in
Build an application that can move between model vendors without rewriting its AI SDK Core calls.
AI Tools · Const
Provider abstraction gives AI SDK Core a common interface for working with models from different providers. It lets applications use the same API while switching among provider integrations more easily.
Provider abstraction gives AI SDK Core a standardized language-model interface, hiding provider-specific API differences. Application code can use the same Core operations while selecting models from different providers, making provider changes simpler and reducing vendor lock-in.
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
generateText({ model: openai('model-id'), prompt: '...' });import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
const result = await generateText({
model: openai('gpt-4o'),
prompt: 'Explain provider abstraction in one sentence.',
});
console.log(result.text);The same AI SDK Core call can target a provider model through the standardized model interface.
Build an application that can move between model vendors without rewriting its AI SDK Core calls.
Use one application programming model for models exposed by multiple supported providers.
Implement or adopt a provider integration that conforms to the AI SDK language-model specification.
AI SDK Corelanguage model specificationAI SDK Providerscustom providers