Overview
The Vercel AI SDK is a provider-agnostic TypeScript toolkit for building AI-powered applications and agents. It gives you one API to call models from providers like OpenAI, Anthropic, and Google, so you can swap models without rewriting your app code.
It is aimed at JavaScript and TypeScript developers working with UI frameworks such as Next.js, React, Svelte, Vue, and Angular, or on runtimes like Node.js. Core functions like generateText handle text generation, structured output, and tool-using agents.
In the generative UI space, the AI SDK UI module adds framework-agnostic hooks (such as useChat) that stream model output into your interface and let you render tool calls as React components, which fits its role as a generative-UI SDK.
What it does
- Unified, provider-agnostic API to call OpenAI, Anthropic, Google, and other model providers by passing a model string
- Works across popular UI frameworks: Next.js, React, Svelte, Vue, Angular, plus Node.js runtimes
- Text generation, structured output via Zod schemas (Output.object), and tool-loop agents with ToolLoopAgent
- AI SDK UI hooks like useChat for building chatbots and streaming, generative interfaces
- Render tool invocations as React components using UIToolInvocation and streamed message parts
- Vercel AI Gateway built in by default for access to major providers, or connect providers directly with @ai-sdk/* packages
Getting started
You need Node.js 22+ and npm (or another package manager). Install the core package, then generate text; add the React UI package when you build a chat interface.
Install the core package
Add the main ai package to your project.
npm install aiGenerate text
Call generateText with a model string. By default this routes through the Vercel AI Gateway.
import { generateText } from 'ai';
const { text } = await generateText({
model: 'openai/gpt-5.4', // use Vercel AI Gateway
prompt: 'What is an agent?',
});Connect a provider directly (optional)
Install a provider package and pass its model helper instead of a gateway string.
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/googleAdd UI hooks for chat
Install the package for your framework to use hooks like useChat for streaming chatbots and generative UI.
npm install @ai-sdk/reactCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Build a streaming chatbot in Next.js or React that renders tool calls as live UI components
- Generate structured data from a model using a Zod schema for type-safe output
- Create tool-using agents with ToolLoopAgent that run shell commands or generate images
- Keep your app provider-agnostic so you can switch between OpenAI, Anthropic, and Google models
How Vercel AI SDK compares
Vercel AI SDK alongside other open-source generative ui sdks tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| CopilotKit | ★ 35.3k | A frontend framework for adding in-app AI copilots and agent-driven generative UI to React and other apps, and the maker of the AG-UI protocol. |
| Vercel AI SDK | ★ 25k | Provider-agnostic TypeScript toolkit for building AI apps, agents, and chat UIs |
| OpenUI | ★ 22.4k | OpenUI lets you describe a UI in plain language, see it rendered live, ask for changes, and convert the result to React, Svelte, or Web Components. |
| AG-UI Protocol | ★ 14.3k | An open protocol that standardizes how AI agents stream events and UI to frontend applications, with SDKs across multiple languages and frameworks. |
| Tambo | ★ 11.2k | A generative UI SDK for React where you register components with Zod schemas and an agent picks the right one and streams its props to the user. |
| assistant-ui | ★ 10.7k | A TypeScript/React library of composable chat primitives for building AI chat apps that can render tool calls and JSON as interactive React components. |
| OpenUI (Thesys) | ★ 7.1k | An open standard and runtime for generative UI that uses a compact streaming language to let models emit interactive charts, forms, tables, and cards. |