Installation
The AI SDK is available as npm packages. You can install the core SDK and optional provider packages based on your needs.Requirements
Before you begin, ensure you have:- Node.js: Version 18 or higher
- Package manager: npm, pnpm, yarn, or bun
Install the core SDK
Theai package contains the core SDK functionality including generateText, streamText, and other core APIs:
Choose a provider
You have two options for accessing AI models:Option 1: Vercel AI Gateway (recommended)
The Vercel AI Gateway provides access to hundreds of models from different providers with a single API key. The gateway provider is included in theai package by default.
Get an API key
Sign up for a Vercel AI Gateway API key
Option 2: Direct provider packages
Install specific provider packages to connect directly to AI services:Framework-specific packages
If you’re building chat or generative UI applications, install the framework integration for your UI library:Additional packages
Depending on your use case, you may need additional packages:Schema validation
For structured outputs and tool definitions, install Zod:Next.js RSC (React Server Components)
For Next.js applications using React Server Components:Verify installation
Create a simple test file to verify your installation:Make sure you’ve set up your API keys in the
.env.local file before running the test.TypeScript configuration
The AI SDK is written in TypeScript and provides full type safety. Ensure yourtsconfig.json includes:
Next steps
Quickstart
Build your first AI application
Providers
Learn about available AI providers
AI SDK Core
Explore core functions and APIs
AI SDK UI
Build chat and generative interfaces