API Reference

@ai-sdk/openai

OpenAI provider for the Vercel AI SDK, exposing chat, completion, embedding, and image models with typed config.

Official Documentation ↗
CompatibilityThis documentation covers version v4.0.108. Check the official docs for the latest API surface.

Installation

npmnpm install @ai-sdk/openai

Methods

@ai-sdk/openai is openai provider for the vercel ai sdk, exposing chat, completion, embedding, and image models with typed config. This page documents the core methods, installation, and common usage patterns for the current stable release.

Installation

Install @ai-sdk/openai with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.

Core methods

The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v1.2 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.

Frequently asked questions

The faq section in the frontmatter answers the most common questions about @ai-sdk/openai, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.

API reference evidence

Fetched from official sources on 2026-11-08T19:29:00+08:00 via WebFetch https://cdn.jsdelivr.net/npm/@ai-sdk/[email protected]/dist/index.d.ts(返回 provider V4 规格声明,与页面标注的 v4.0.108 不符);WebFetch https://unpkg.com/@ai-sdk/[email protected]/dist/index.d.ts(同上);WebFetch https://cdn.jsdelivr.net/npm/@ai-sdk/openai@1/dist/index.d.ts(provider V1 规格,LanguageModelV1/EmbeddingModelV1,与 AI SDK v4 对应).

FAQ

Does it support Azure OpenAI?
Use @ai-sdk/azure or set baseURL and headers on createOpenAI for Azure-compatible endpoints.
Can I use structured outputs?
Yes. Pass the model to generateObject with a Zod schema; the provider uses JSON mode.
Are tool calls supported?
Yes. Define tools with zod schemas; the SDK handles multi-step tool loops.