The AI SDK by Vercel provides a unified interface for building AI applications, supporting various models like ChatGPT, Claude, and Gemini, either directly or via the Vercel AI Gateway. It simplifies interactions with providers such as OpenAI, Anthropic, and Google, offering features like tool-calling, structured output, and agentic capabilities. The current stable version is 6.0.168, with frequent patch releases and major version updates as new features and providers are integrated.
npm install aiVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to generate text using the AI SDK with an OpenAI model, requiring an API key configured as an environment variable.
Refer to the official migration guide for Vercel AI SDK v6 to update your application logic. Ensure you import specific provider functions (e.g., `openai` from `ai`) and adjust `generate` options accordingly.
Install `zod` in your project: `npm install zod` or `yarn add zod`.
Update your Node.js environment to version 18 or newer. We recommend using a Node.js version manager like `nvm` or `volta`.
Set the appropriate `_API_KEY` environment variable for your chosen provider in your development environment (`.env` file) and deployment pipeline.
Set the `OPENAI_API_KEY` environment variable with your actual OpenAI API key (or equivalent for other providers) before running your application.
Ensure your project is configured for ESM. For Node.js, add `"type": "module"` to your `package.json` file, or save your file with a `.mjs` extension.
Install Zod: `npm install zod` or `yarn add zod`.
Upgrade your Node.js installation to version 18 or higher. Use a version manager like `nvm use 18` or `volta install node@18`.
No dependency data recorded yet.