@ai-sdk/openai provider SDK. Use this when you only need OpenAI models and want the simplest setup with type-safe model IDs.
Setup
- Get an API key from OpenAI Platform
- Add to
.env.local:
- Set the gateway in your config:
chat.config.ts
Authentication
| Variable | Description |
|---|---|
OPENAI_API_KEY | Required. Your OpenAI API key |
Available Models
All models available to your API key (GPT, DALL-E, and embedding models). The full list is fetched at runtime and cached for 1 hour.Model IDs
Unlike the Vercel and OpenRouter gateways which useprovider/model format, the OpenAI gateway uses bare model IDs since all models come from OpenAI:
gpt-5-minigpt-5-nanogpt-4oo3-mini
@ai-sdk/openai SDK, giving you autocomplete in chat.config.ts.
Image Generation
The OpenAI gateway supports dedicated image models throughcreateImageModel():
gpt-image-1gpt-image-1.5dall-e-3
Related
- Gateways Overview for the full gateway comparison
- Vercel Gateway for multi-provider access via a single key