Skip to content

Vercel AI SDK: one TypeScript API for every model, with streaming and tool calls

Better Design

Direct answer

The Vercel AI SDK is a free, open-source TypeScript toolkit for building AI apps and agents: AI SDK Core gives one API for text, structured data and tool calls across model providers, and AI SDK UI gives hooks such as useChat for streaming chat interfaces. You install it with npm install ai.

A hand-drawn browser window with Vercel AI SDK written in it and a short list of what it does.

What Vercel AI SDK is

Each fact comes from the sources listed at the end of this page, read on November 12, 2026.

  • The AI SDK is a TypeScript toolkit from Vercel for building AI applications and agents with React, Next.js, Vue, Svelte, Node.js and more.
  • Its code is open source in the vercel/ai GitHub repository, and the ai package on npm is licensed Apache-2.0.
  • AI SDK Core is a unified API for generating text, structured objects and tool calls, and for building agents.
  • AI SDK UI is a set of framework-agnostic hooks for chat and generative interfaces: useChat, useCompletion and useObject.
  • AI SDK UI supports React, Vue.js, Svelte and Angular, plus SolidJS through a community package.
  • Core functions include generateText for non-interactive tasks and streamText for interactive ones such as chatbots.
  • Both generateText and streamText return typed, schema-validated structured output through the output property.
  • A tool has a description, an inputSchema written in Zod or JSON Schema, and an optional execute function.
  • By default the SDK routes model strings such as anthropic/claude-sonnet-5.5 through the Vercel AI Gateway, which ships with the ai package.
  • You can also call providers directly with their packages, such as @ai-sdk/openai, @ai-sdk/anthropic and @ai-sdk/google.
  • The SDK also has AI SDK Harnesses, which run agent harnesses such as Claude Code and Codex through HarnessAgent.

The parts of the AI SDK

AI SDK Core
What it does

Generates text, structured data and tool calls

Package or function

generateText, streamText in the ai package

AI SDK UI
What it does

Streams chat and completions into the interface

Package or function

useChat, useCompletion, useObject in @ai-sdk/react and others

Providers
What it does

Connect one API to many model vendors

Package or function

@ai-sdk/openai, @ai-sdk/anthropic, @ai-sdk/google and more

AI Gateway
What it does

Reaches many models with one API key

Package or function

Model strings such as anthropic/claude-sonnet-5.5

AI SDK Harnesses
What it does

Runs established agent harnesses

Package or function

HarnessAgent

Get started with Vercel AI SDK

  • Install Node.js 22 or later.
  • Run npm install ai, or pnpm add ai @ai-sdk/react zod for a Next.js chat app.
  • Add an AI_GATEWAY_API_KEY to .env.local, or install a provider package such as @ai-sdk/anthropic.
  • Call streamText in a route handler such as app/api/chat/route.ts.
  • Render the conversation in the browser with the useChat hook.

Vercel AI SDK in four steps

The four steps, in the order you take them.

A hand-drawn four-step path for Vercel AI SDK: Install the ai package, Pick a provider, Stream with streamText, Render with useChat.
  1. Step 1: Install the ai package
  2. Step 2: Pick a provider
  3. Step 3: Stream with streamText
  4. Step 4: Render with useChat

Caveats Vercel AI SDK states

  • The docs list Node.js 22+ as a prerequisite for the quickstart and the package.
  • The default model strings go through the Vercel AI Gateway, which needs its own API key; install a provider package to call a vendor directly.
  • UI messages and model messages are different types, so the route converts them with convertToModelMessages.
  • MCP Apps support in AI SDK UI is listed for React only, not for Vue, Svelte or Angular.
  • The docs note that streaming is not always needed: a smaller, faster model without streaming can be simpler.

Steal this workflow

Run this guide in your own assistant. The prompt carries the guide link and the workflow summary, so the assistant can adapt it to your project.

Read the guide "Vercel AI SDK: one TypeScript API for every model, with streaming and tool calls" at https://better-design.com/blog/vercel-ai-sdk and help me apply it to my project.

The Vercel AI SDK is a free, open-source TypeScript toolkit for building AI apps and agents: AI SDK Core gives one API for text, structured data and tool calls across model providers, and AI SDK UI gives hooks such as useChat for streaming chat interfaces. You install it with npm install ai.

Start by asking what I am building and which tools I use. Then walk me through the workflow step by step, adapted to my answers.

Claude and ChatGPT open with the prompt filled in. Gemini copies the prompt to your clipboard first, so paste it when the app opens.

Questions

What is the Vercel AI SDK?

It is a free, open-source TypeScript toolkit for building AI apps and agents. AI SDK Core handles model calls, and AI SDK UI handles streaming chat interfaces in React, Vue, Svelte and Angular.

How do I install the Vercel AI SDK?

Run npm install ai. For a Next.js chat app, the quickstart installs ai, @ai-sdk/react and zod.

Which providers does Vercel AI support?

The AI SDK has first-party providers such as OpenAI, Anthropic, Google, Mistral, xAI, Amazon Bedrock and Groq, an OpenAI-compatible provider, and community providers such as Ollama and OpenRouter.

Does the AI SDK support tool calling?

Yes. You pass tools to generateText or streamText, each with a description, an input schema and an optional execute function, and stopWhen limits how many steps the model takes.

What is the difference between AI SDK Core and AI SDK UI?

Core runs on the server and calls models with functions such as generateText and streamText. UI runs in the browser and shows streamed results with hooks such as useChat.

Where these Vercel AI SDK facts come from

Each fact comes from the pages listed here, read on November 12, 2026. Products change, so check those pages for the current version.

Build the interface in your own code instead

A coding agent such as Claude Code, Cursor or Codex can build your interface in your own code. Better Design gives that agent a design system, interface principles and review rules, so the result looks designed.