Model or dataset
vercel/ai avatar
vercel/ai

Vercel AI SDK 7: A provider-agnostic TypeScript layer for text, structured output, and agent loops

The AI Toolkit for TypeScript. From the creators of Next.js, the AI SDK is a free open-source library for building AI-powered applications and agents

26,761 stars5,141 forksTypeScriptNOASSERTION

At a glance

What is it?
The AI SDK from Vercel unifies OpenAI, Anthropic, Google, and other model providers behind one TypeScript API, with framework hooks for React, Svelte, and Vue. It is a serious option for teams standardizing on Next.js, but its default reliance on the Vercel AI Gateway and its fast release cadence deserve scrutiny.
Who is it for?
Adopt the AI SDK if you build AI features in TypeScript with React, Svelte, or Vue and want one API across OpenAI, Anthropic, and Google models, especially inside a Next.js app. Do not adopt it if you need to avoid Vercel's gateway by default or if you want a stable API: the project maintains three major release lines at once (5.x, 6.x, 7.x), and the README shows model IDs like 'claude-opus-4-6' that may not match the provider's current naming.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What the AI SDK actually standardizes

The AI SDK solves a narrow but painful problem: every model provider ships its own SDK with different request shapes, streaming formats, and error conventions. If you have ever swapped OpenAI for Anthropic in a codebase, you know the cost is not just changing an import. The AI SDK defines a common TypeScript interface for generating text, generating structured data, and running agent loops, then maps that interface onto each provider behind the scenes. The README shows two access paths. The first uses a model string like 'anthropic/claude-opus-4.6' and routes through the Vercel AI Gateway by default. The second imports a provider package directly, for example anthropic from '@ai-sdk/anthropic', and passes a model instance. Both paths feed the same generateText function. For teams that want to avoid vendor lock-in, the direct provider path is the one to watch, though the gateway is the default and the README presents it as the zero-config option.

Installation and the Node.js 22 requirement

Getting started is a single npm command: npm install ai. The README is explicit that you need Node.js 22 or newer, which is a meaningful constraint for teams still on Node 18 or 20 LTS releases. Many corporate environments standardize on older Node versions, and the AI SDK will not run there without an upgrade. The package itself is the core; UI hooks require a separate framework package such as @ai-sdk/react. There is also a skill for coding agents: npx skills add vercel/ai. That command adds the AI SDK skill to a repository for agents like Claude Code or Cursor. The skill is not a runtime dependency, but it signals that the project is designed to be consumed by AI coding assistants, which is unusual for a library and worth noting if your team uses those tools.

One function for text, structured output, and agents

The core API is compact. generateText takes a model and a prompt, and returns text. For structured data, the same function accepts an output option with a Zod schema, and the SDK returns typed output instead of raw text. The README example defines a recipe schema with nested objects and arrays, and the SDK validates the model response against that schema. That is a real time-saver because it removes the need to write JSON parsing and retry logic yourself. The agent story is newer. The README introduces ToolLoopAgent, a class that runs a model in a loop with tools. The example gives the agent a localShell tool that executes commands inside a Vercel Sandbox. The agent decides when to call the tool, gets the output, and continues. This is a higher-level abstraction than raw tool-calling loops in provider SDKs, but it also ties the shell example to Vercel's sandbox product, which may not be portable to other hosting environments.

UI hooks and the agent UI streaming route

The UI module is where the AI SDK differentiates itself from a plain API wrapper. The @ai-sdk/react package provides a useChat hook that manages message state, status, and sending. The README shows a complete Next.js App Router flow: define an agent with tools, expose a POST route that calls createAgentUIStreamResponse, and render messages in a client component. The interesting part is the typed message stream. The agent's UI message type is inferred with InferAgentUIMessage, and the client can switch on message part types like 'tool-generateImage'. For image generation, the tool output is a base64 PNG that the UI component renders directly. This is a generative UI pattern where the model's tool calls drive what the user sees, not just what text comes back. The hooks are framework agnostic, with packages for React, Svelte, and Vue, but the README examples are all Next.js, which suggests the smoothest path is still a Next.js app.

Where the SDK is the wrong tool

The AI SDK is not a good fit if you need fine-grained control over a single provider's unique features. The abstraction necessarily hides provider-specific parameters, and the README's model ID 'claude-opus-4.6' looks suspicious; Anthropic's naming convention uses hyphens between major and minor versions, not a dot. That inconsistency suggests the documentation may lag behind actual model releases. If your application depends on a provider feature that has no equivalent in the unified API, you will either fight the abstraction or drop down to the provider SDK anyway. Another limitation is the default gateway. The README states that by default the SDK uses the Vercel AI Gateway. That means your requests go through Vercel's infrastructure unless you explicitly install and configure a direct provider package. For teams with strict data residency or compliance requirements, that default is a dealbreaker unless you override it. The README does not explain how to disable the gateway globally, only how to use direct provider packages, so you will need to read the docs carefully.

Alternatives: LangChain.js and provider-native SDKs

The most direct alternative is LangChain.js, which also provides a unified interface across providers but takes a different architectural approach. LangChain.js is built around chains and agents as composable primitives, with a large ecosystem of integrations for vector stores, retrievers, and memory. The AI SDK is leaner: it focuses on text generation, structured output, and tool loops, and leaves broader orchestration to your own code. If you need retrieval-augmented generation with multiple document loaders and vector databases out of the box, LangChain.js gives you those pieces. If you want a thin, typed layer over chat and completion endpoints, the AI SDK is closer to that. The other alternative is to skip the abstraction and use the provider SDKs directly, for example @ai-sdk/openai is itself a wrapper, but you could use the openai npm package. That gives you full access to provider features but forces you to write and maintain your own switching logic. The AI SDK's value is exactly that switching logic, so the trade-off is between control and convenience.

Release cadence and maintenance reality

The repository shows three active major release lines: ai@5.0.254, ai@6.0.279, and ai@7.0.95, all pushed on the same day. That is a rapid release schedule, with patch releases numbering in the hundreds for each major version. For a library this young, that cadence means APIs can shift between majors, and you must pin your version carefully. The README examples use features like ToolLoopAgent and Output.object that may not exist in version 5 or 6. The project is not archived and receives frequent pushes, which is good for bug fixes, but it also means you should expect breaking changes when you upgrade majors. The license is listed as NOASSERTION on GitHub, which is not a standard SPDX identifier. The README does not state a license explicitly, so before adopting the SDK in a commercial product, you must check the LICENSE file in the repository or the package metadata on npm. This is not legal advice, but the absence of a clear license identifier is a red flag that should be resolved before you commit.

Editorial conclusion

Adopt the AI SDK if you build AI features in TypeScript with React, Svelte, or Vue and want one API across OpenAI, Anthropic, and Google models, especially inside a Next.js app. Do not adopt it if you need to avoid Vercel's gateway by default or if you want a stable API: the project maintains three major release lines at once (5.x, 6.x, 7.x), and the README shows model IDs like 'claude-opus-4-6' that may not match the provider's current naming. Before committing, verify that your chosen provider package (@ai-sdk/openai, @ai-sdk/anthropic, @ai-sdk/google) supports the exact model and tool features you need, and test the ToolLoopAgent's local shell tool only inside a sandbox you control. The SDK is a pragmatic abstraction, not a guarantee of provider parity.

Official sources

  1. Issues
  2. Project website
  3. README
  4. Releases
  5. vercel/ai on GitHub
Community notes

Community notes