Vercel
Streaming chat UIs and tool-call agents for Next.js, Svelte, and Vue.
GitHub Stars
24.3K
Contributors
638
npm / Week
13.1M
PyPI / Month
—
The Vercel AI SDK, maintained by Vercel and released in 2023 under the Apache 2.0 license, is a TypeScript-native toolkit for building streaming chat interfaces and tool-calling agents. It occupies the intersection of inference SDK and orchestration: it provides a unified, provider-agnostic API for calling LLMs while also handling the streaming and state management needed for production chat experiences.
This is the toolkit that powers many of the AI features you see in Next.js applications, and it ships with first-class integrations for React, Svelte, Vue, and Node.js. With over 20 million monthly downloads (as of late 2025) and adoption by teams from startups to Fortune 500 companies like Thomson Reuters and Clay, the Vercel AI SDK is widely considered the de facto standard for shipping chat UIs in the TypeScript ecosystem. It is not a multi-agent orchestrator or a framework for complex graph-based workflows, but it excels at what it was designed for: streaming conversations and single-agent tool use.
The Vercel AI SDK is code-first and imperative. You import functions and hooks from the ai package and call them directly. There are no configuration files, YAML pipelines, or declarative DSLs. The core abstractions are simple:
TextStream that you can pipe to a UI.execute callback.Control flow is straightforward: you call generateText or streamText, optionally pass a set of tools, and the SDK handles the tool-calling loop for you if you use ToolLoopAgent. For streaming, the SDK uses Server-Sent Events (SSE) under the hood, and the React/Svelte/Vue hooks (useChat, useCompletion, useAssistant) manage the state and reconnection logic.
The SDK is provider-agnostic at the core. You choose a model by importing a provider-specific package (e.g., @ai-sdk/openai, @ai-sdk/anthropic) and passing the model instance to the generation function. This means switching from OpenAI to Anthropic is a one-line change.
For Next.js users, the SDK also offers React Server Components (RSC) support through the ai/rsc entry point, enabling server-rendered streaming chat UIs without client-side JavaScript waterfalls.
Streaming primitives. The SDK ships with hooks and helpers for streaming text, tool calls, and structured outputs. In React, useChat gives you a ready-to-use chat state with streaming messages, loading indicators, and error handling. The underlying streamText function returns a TextStream object that can be consumed in any runtime.
Provider-agnostic API. A single API surface works with OpenAI, Anthropic, Google Gemini, Mistral, Groq, and dozens of other providers through community or official adapters. This makes A/B testing different models or providers trivial without touching application logic.
AI Elements. Pre-built React components for chat interfaces, available as part of the SDK. These include message lists, input fields, and automatic scroll behavior. You can drop them into a Next.js app and have a functional chat UI in minutes.
Tool calling and structured output. The SDK has full support for tool definitions using Zod schemas, with automatic JSON parsing and validation. The ToolLoopAgent class (introduced in SDK 6) manages the tool-calling loop, including context management and stopping conditions. You can also generate structured data directly using the generateObject function.
MCP support. The Vercel AI SDK supports the Model Context Protocol (MCP), allowing you to connect to MCP servers for tool discovery and execution. This enables integration with external tool registries.
Type safety throughout. Everything from tool schemas to streaming callbacks is typed. The SDK exports TypeScript types for all message formats, stream events, and error shapes.
Self-hostable and cloud-hosted. You can run the SDK entirely on your own infrastructure (no Vercel dependency) or deploy to Vercel’s edge network. The SDK itself is just an npm package.
Streaming chat UIs. The primary use case. Teams use the Vercel AI SDK to build production chat experiences in Next.js, Svelte, Vue, or vanilla TypeScript. The streaming hooks handle backpressure, reconnection, and state management out of the box. Examples include customer support chatbots, internal knowledge assistants, and AI copilots embedded in SaaS products.
Tool-call agents. Single-agent apps that call external tools and stream results back to the UI. Clay, a sales intelligence platform, built Claygent using the Vercel AI SDK – an agent that scrapes public data, connects to first-party sources via MCP, and returns targeted insights in real time. Thomson Reuters built CoCounsel, an AI assistant for legal and accounting teams, with just three developers in two months using the SDK.
Provider switching and experimentation. Because the SDK abstracts model providers, teams can A/B test different models without rewriting code. For example, a chatbot might use GPT-4o for complex reasoning and switch to a cheaper Mistral model for simple Q&A, all driven by the same streamText call with a different model argument.
Background agents. The ToolLoopAgent class enables lightweight background agents that run on Vercel’s edge functions or serverless infrastructure. These agents can perform sequential processing, parallel tasks, or evaluation/feedback loops – but they are single-agent systems. For multi-agent coordination, you would pair the Vercel AI SDK with Mastra or LangGraph.
The SDK is a poor fit for complex multi-agent orchestrations, durable execution with retries and state persistence, or scenarios that require evals and observability built-in. You would bring your own tooling for those layers.
Install the core package and a provider adapter:
1npm install ai @ai-sdk/openai
Set your OPENAI_API_KEY environment variable. Then the smallest meaningful example:
1import { generateText } from 'ai';2import { openai } from '@ai-sdk/openai';34const { text } = await generateText({5 model: openai('gpt-4o'),6 prompt: 'What is the capital of France?',7});89console.log(text);
For a streaming chat UI in React:
1import { useChat } from 'ai/react';23function Chat() {4 const { messages, input, handleInputChange, handleSubmit } = useChat();5 return (6 <div>7 {messages.map(m => <div key={m.id}>{m.role}: {m.content}</div>)}8 <form onSubmit={handleSubmit}>9 <input value={input} onChange={handleInputChange} />10 </form>11 </div>12 );13}
Beyond the core package, you typically need:
@ai-sdk/anthropic, @ai-sdk/google, etc.)@ai-sdk/react or @ai-sdk/svelte for framework-specific hooksDocumentation lives at [ai-sdk.dev](https://ai-sdk.dev). The GitHub repository (vercel/ai) has over 24k stars and is actively maintained with frequent releases. Community support is available through GitHub Discussions and the Vercel community forums.
Vercel AI SDK vs LangChain. LangChain is a broader ecosystem with support for Python, JavaScript, and multiple orchestration patterns (chains, agents, retrievers). The Vercel AI SDK is smaller in scope and purely TypeScript. If you need Python support, complex agent graphs, or built-in document loaders and vector store integrations, LangChain is the better choice. If you are building a chat UI in Next.js and want the simplest path to streaming, the Vercel AI SDK wins.
Vercel AI SDK vs CrewAI. CrewAI is a multi-agent framework designed for role-based agent teams. The Vercel AI SDK does not have a multi-agent abstraction – you would use CrewAI or Mastra for that. If your use case requires multiple specialized agents collaborating (e.g., a researcher, a writer, and an editor), CrewAI is more appropriate. If you need a single agent that calls tools and streams results to a UI, the Vercel AI SDK is simpler and more performant.
Vercel AI SDK vs Mastra. Mastra sits closer to the Vercel AI SDK but adds durable execution, built-in evals, and multi-agent orchestration. If you want those features out of the box, Mastra is a stronger candidate. If you prefer to bring your own observability and evals, and want the tightest Next.js integration, the Vercel AI SDK is the leaner option.
In short: choose the Vercel AI SDK when you need a battle-tested, streaming-first TypeScript toolkit for chat interfaces and single-agent tool calling. Supplement it with another orchestration framework when you outgrow the single-agent model.
What the framework gives you out of the box, in plain language.
Hooks and helpers for streaming text, tool calls, and structured outputs.
One API for OpenAI, Anthropic, Google, Mistral, Groq, and dozens more.
Pre-built React components for chat interfaces, ready to drop into a Next.js app.
The jobs this framework is best suited for.
Production chat experiences in Next.js, Svelte, Vue, or vanilla TypeScript.
Single-agent apps that call tools and stream the results back to the UI.
A/B test different model providers without changing app code.
Side-by-Side
Add a second or third framework and see stars, downloads, and capabilities lined up next to each other.
Close alternatives worth a look before you decide.
Composable building blocks for LLM apps — chains, agents, retrievers, and integrations.
Composable LLM building blocks
Stars
137.0K
npm / wk
2.2M
PyPI / mo
241.8M
Multi-agent crews with role-based prompts and explicit task hand-offs.
Role-based multi-agent crews
Stars
51.6K
npm / wk
—
PyPI / mo
9.6M
TypeScript-first agent framework with workflows, RAG, and built-in evals.
Type-safe TypeScript agents
Stars
24.0K
npm / wk
961.9K
PyPI / mo
—