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

At a glance

How it runs
Library / SDKFramework
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
Node.js 22+npm (or another package manager)Shell / CLINetwork accessLocal filesystem
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

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.

  1. A Next.js or React team that wants to add a streaming chat interface to an existing product without building its own model plumbing.
  2. A backend developer who needs model responses that strictly match a zod schema, such as recipes, form payloads or classification records.
  3. A developer building an agent that must call external tools — running shell commands or generating images — and surface intermediate UI states.
  4. A team that wants to keep OpenAI, Anthropic and Google interchangeable behind one API instead of committing to a single vendor.
  5. 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 ai

To call providers directly instead of through the Vercel AI Gateway, install their SDK packages:

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

For frontend hooks, install the package for your framework:

npm install @ai-sdk/react

If you use coding agents such as Claude Code or Cursor, add the AI SDK skill:

npx skills add vercel/ai

How 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?

Pros
  • 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.
Limitations
  • 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?

FollowAgents source review · FARS-2.1
Major gaps
50/ 100 5-point scale 2.5 / 5
Trust 12/29
Reliability 9/14
Adaptability 9/18
Convention 10/18
Effectiveness 7/13
Verifiability 3/8
Why each dimension lost points
Trust12 / 29 · 2.1/5

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.

Reliability9 / 14 · 3.2/5

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.

Adaptability9 / 18 · 2.5/5

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.

Convention10 / 18 · 2.8/5

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.

Effectiveness7 / 13 · 2.7/5

Examples are directly reusable, marginal value scores 2; cost-benefit lacks quantified benchmarks, score 1.

Verifiability3 / 8 · 1.9/5

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.

Risks and how to mitigate them
  • 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.
Evidence confidence: Low Reviewed Oct 20, 2026 Reviewed revision b343f67c4930
See the full review method →

FAQ

Is there a cost beyond the library itself?
The npm package is free and open source. Calls go through the Vercel AI Gateway by default or directly to OpenAI, Anthropic, Google and others, so you supply keys and pay providers per use; the source states no prices.
Can I avoid the Vercel AI Gateway entirely?
Yes. The README shows installing @ai-sdk/openai, @ai-sdk/anthropic or @ai-sdk/google and calling providers directly, e.g. anthropic('claude-opus-5-5').
Which frameworks and runtimes are supported?
The README names Next.js, React, Svelte, Vue, Angular and the Node.js runtime, and describes the UI hooks as framework agnostic.
Where does my data go?
Prompts are sent to whichever model provider you select, or to the Vercel AI Gateway by default. The library does not claim local inference.
What is the license?
GitHub reports the license as NOASSERTION with no standard SPDX identifier, so review the license files in the repository before commercial adoption.
View on GitHub ↗ Install ↓

Related agents