AI SDK 6

Installation & Setup

How to install and configure the AI SDK 6.

Installation & Setup

Install

The core package is simply called ai:

pnpm add ai

Add a provider — here OpenAI as an example:

pnpm add @ai-sdk/openai

Other providers follow the same pattern: @ai-sdk/anthropic, @ai-sdk/google, etc.

Core Imports

Everything you need for backend generation lives in the ai package:

import { generateText, streamText, Output } from "ai";

Provider Import

import { openai } from "@ai-sdk/openai";

Environment Variable

# .env
OPENAI_API_KEY=sk-...

The provider SDKs read the relevant env var automatically (e.g. OPENAI_API_KEY for @ai-sdk/openai).

Note: You do not need to deploy to Vercel to use the AI SDK — it runs anywhere Node.js runs.