AI/TLDR

Vercel AI SDK

Provider-agnostic TypeScript toolkit for building AI apps, agents, and chat UIs

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.

bashbash
npm install ai

Generate text

Call generateText with a model string. By default this routes through the Vercel AI Gateway.

tsts
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.

bashbash
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google

Add UI hooks for chat

Install the package for your framework to use hooks like useChat for streaming chatbots and generative UI.

bashbash
npm install @ai-sdk/react

Commands 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.

ToolStarsWhat it does
CopilotKit★ 35.3kA 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★ 25kProvider-agnostic TypeScript toolkit for building AI apps, agents, and chat UIs
OpenUI★ 22.4kOpenUI 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.3kAn open protocol that standardizes how AI agents stream events and UI to frontend applications, with SDKs across multiple languages and frameworks.
Tambo★ 11.2kA 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.7kA 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.1kAn open standard and runtime for generative UI that uses a compact streaming language to let models emit interactive charts, forms, tables, and cards.