Providers and models
The AI SDK uses providers to hide vendor HTTP differences. In 7.x the default global provider is Vercel AI Gateway: model can be the string "openai/gpt-4.1-mini". You can also install @ai-sdk/openai (and others) and call a vendor directly.
Model IDs change. This tutorial uses the Gateway string openai/gpt-4.1-mini; the official quickstart often shows xai/grok-4.6; direct OpenAI examples use openai('gpt-5.1'). Trust Providers and Models and your console.
Gateway (default)
Three equivalent forms: a raw string, gateway() from 'ai', and gateway() from '@ai-sdk/gateway'. One key reaches many vendors—handy for experiments and Vercel deploys.
You can replace the global default provider so every string in the app hits your chosen backend. See official Provider Management.
Direct OpenAI: @ai-sdk/openai
The default openai('...') factory uses the Responses API. If a custom baseURL only implements Chat Completions, use openai.chat('model-id') or the OpenAI Compatible package below.
Do not pass the Gateway string "openai/gpt-4.1-mini" into openai(), and do not treat openai('gpt-5.1') as a Gateway route.
Other first-party packages include @ai-sdk/anthropic, @ai-sdk/google, @ai-sdk/xai, @ai-sdk/azure, @ai-sdk/mistral, @ai-sdk/groq. Install the package and import { anthropic } from '@ai-sdk/anthropic'.
OpenAI-compatible APIs and local Ollama
Many local and gateway servers speak OpenAI HTTP. Official package:
Start Ollama with this site’s Ollama tutorial. Inside Docker do not use localhost; use host.docker.internal:11434. The compatibility layer depends on Ollama’s /v1 implementation. If tools or structured output are missing, try the community package ollama-ai-provider-v2 (see official Community Providers).
vLLM, llama.cpp, and OpenAI-compatible regional gateways use the same createOpenAICompatible({ baseURL }). Add apiKey, headers, or queryParams when the server requires them.
Capability gaps
Not every model supports image input, tool streaming, or object generation. Check the official capability table before switching. Gateway "provider/model" strings and direct-package IDs are not the same catalog—verify both when you migrate.
In TypeScript, keep model in config (process.env.MODEL_ID or gateway(...)) instead of pasting IDs into ten files.