AI SDK
A provider-agnostic TypeScript toolkit from the Next.js team for building AI applications and agents with one unified API.
- Source repo
- vercel/ai
- Stars
- ★ 27k
- Last updated
- today
- License
- NOASSERTION
- Primary language
- TypeScript
- FA score
- 50/100 · Major gaps
At a glance
- How it runs
- Works with
- Universal · cross-platformOpenAI API · Claude API
- Cost
- Free software; you pay for model usage
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- A Next.js or React team that wants to add a streaming chat interface to an existing product without building its own model plumbing.
- Not a fit if
- Projects on non-JavaScript/TypeScript stacks
- Users wanting a finished chat product rather than an SDK to integrate
- Source review
- 50/100 · Major gaps
What does this agent do, and when should you use it?
The AI SDK is a provider-agnostic TypeScript toolkit for building AI-powered applications and agents, usable with UI frameworks such as Next.js, React, Svelte, Vue, and Angular as well as runtimes like Node.js. It exposes a unified API over model providers — OpenAI, Anthropic, Google and more — defaulting to the Vercel AI Gateway, while also allowing direct connection through per-provider packages such as @ai-sdk/openai. Core pieces include generateText for text generation, Output.object for zod-schema structured output, ToolLoopAgent for tool-loop agents, and the AI SDK UI module with hooks like useChat plus helpers such as createAgentUIStreamResponse and InferAgentUIMessage. It ships as an npm package that requires Node.js 22+ and is meant to be imported into your own code and applications rather than run as a standalone product.
generateText resolves a model string such as 'anthropic/claude-opus-5.5' or a provider handle such as anthropic('claude-opus-5-5'), sends the prompt and returns a { text } result. Passing Output.object with a zod schema constrains the response into a typed object, as in the recipe example with nested ingredients and steps arrays. ToolLoopAgent takes a model, a system prompt and a tools map, and drives the model through a tool loop; the documented example wires openai.tools.localShell to run commands in a Vercel Sandbox and return stdout. For UIs, the framework-agnostic useChat hook tracks messages and status, while createAgentUIStreamResponse streams an agent's UI messages from a route handler, and InferAgentUIMessage / UIToolInvocation type the message parts and tool-invocation components rendered in the client.
- A Next.js or React team that wants to add a streaming chat interface to an existing product without building its own model plumbing.
- A backend developer who needs model responses that strictly match a zod schema, such as recipes, form payloads or classification records.
- A developer building an agent that must call external tools — running shell commands or generating images — and surface intermediate UI states.
- A team that wants to keep OpenAI, Anthropic and Google interchangeable behind one API instead of committing to a single vendor.
- A Svelte or Vue developer who needs a framework-agnostic chat state hook for generative UI.
How do you install or deploy this agent?
Node.js 22+ and npm (or another package manager) are required locally.
Install the core package:
npm install aiTo call providers directly instead of through the Vercel AI Gateway, install their SDK packages:
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/googleFor frontend hooks, install the package for your framework:
npm install @ai-sdk/reactIf you use coding agents such as Claude Code or Cursor, add the AI SDK skill:
npx skills add vercel/aiHow do you use this agent?
Minimal call using the default Vercel AI Gateway:
import { generateText } from 'ai';
const { text } = await generateText({
model: 'openai/gpt-6-astra', // use Vercel AI Gateway
prompt: 'What is an agent?',
});Or connect directly with a provider package:
import { anthropic } from '@ai-sdk/anthropic';
const result = await generateText({
model: anthropic('claude-opus-5-5'), // or openai('gpt-6-astra'), google('gemini-3.8-flash'), etc.
prompt: 'Hello!',
});Define a tool-using agent and expose it from a Next.js App Router route:
import { imageGenerationAgent } from '@/agent/image-generation-agent';
import { createAgentUIStreamResponse } from 'ai';
export async function POST(req: Request) {
const { messages } = await req.json();
return createAgentUIStreamResponse({
agent: imageGenerationAgent,
messages,
});
}Consume messages and tool parts in the client with useChat:
'use client';
import { useChat } from '@ai-sdk/react';
export default function Page() {
const { messages, status, sendMessage } =
useChat<ImageGenerationAgentMessage>();
// render messages and tool parts
}The source does not document how to configure each provider's API keys or its billing details; check the individual provider documentation before wiring it up.
What are this agent's strengths and limitations?
- One provider abstraction: the same generateText call works through the Vercel AI Gateway, @ai-sdk/openai, @ai-sdk/anthropic or @ai-sdk/google by changing the model identifier.
- Tight frontend integration: framework-agnostic useChat plus documented Next.js App Router streaming via createAgentUIStreamResponse and typed tool-invocation components.
- Structured output is first-class — Output.object accepts a zod schema directly, removing hand-written JSON parsing and validation.
- Clear agent abstraction: ToolLoopAgent ties tool definitions, the tool loop and UI message types (InferAgentUIMessage, UIToolInvocation) into one path.
- Maintained by the Vercel and Next.js teams, with official templates and a dedicated documentation site at ai-sdk.dev.
- The out-of-box path defaults to the Vercel AI Gateway for access to all providers, which teams should evaluate before adopting.
- Requires Node.js 22 or newer, so older Node environments need an upgrade first.
- The repository license is reported as NOASSERTION; confirm the actual terms before commercial use.
- Example model identifiers (e.g. gpt-6-astra, claude-opus-5-5) track provider changes and must be kept current against the docs.
- The source documents no offline mode; model calls depend on network access and external APIs.
How does this agent compare with similar options?
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| AI SDK This agent | 50 · Major gaps | Library / SDKFree + model costs | ★ 27k | today | TypeScript | OpenAI API · Claude API |
| Open Generative UI | 44 · Major gaps | CLIFree + model costs | ★ 3.6k | 7d ago | TypeScript | Claude API |
| Strands Agents | 30 · Major gaps | Library / SDKFree + model costs | ★ 8.9k | today | TypeScript | OpenAI API · Claude API |
| MiniCode | 50 · Major gaps | CLIFree + model costs | ★ 1.1k | 11d ago | TypeScript | Claude API |
How does FollowAgents rate this agent?
Why each dimension lost points
Evidence shows Apache-2.0 licensing, a changeset verifier with symlink protection (CWE-59), and pinned dependency versions; no documentation of least privilege, user confirmation, data-flow transparency, or sensitive-data handling for agent runtime, so those score 1. Dependency security scores 2 due to pinned versions and CI checks. Rollback is only indirectly implied via changesets, score 1. Source attribution scores 2 via LICENSE and repository field.
package.json scripts, engines constraints, and changeset verification logic are self-consistent with specific failure messages (missing changeset, invalid bump), score 2; dependency availability supported by pnpm lock and workspace refs, score 2. Not executed, so capped at 2.
Examples cover WebSocket chat, structured output, Zod schemas across scenarios, score 2; capability boundaries and trigger precision lack explicit agent-facing declarations, score 1. Environment fit has Node version constraints, score 2.
Repo structure, changeset versioning, and examples are solid, information architecture and naming stability score 2; install notes are thin in package.json, score 1; known limitations lack a consolidated section, score 1; maintenance responsibility scores 1 because publisher is unverified; license and versioning score 2.
Examples are directly reusable, marginal value scores 2; cost-benefit lacks quantified benchmarks, score 1.
Test files and CI verification scripts trace some claims, but no end-to-end evidence of agent behavior, claim traceability and cross-source corroboration score 1; fact/inference separation is not explicitly marked, score 1.
- Publisher identity is unverified by FollowAgents; maintenance responsibility and update path are unclear.
- Repository is a general AI SDK framework, not a dedicated agent product; agent capability boundaries and trigger precision lack explicit documentation.
- No tests were executed; all scores are static-source based with low confidence.
- License metadata is NOASSERTION; actual license terms need manual verification.