Model or dataset
vercel/ai avatar
vercel/ai

vercel/ai (the AI SDK): a provider-agnostic TypeScript toolkit for LLM apps

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,904 stars5,158 forksTypeScriptNOASSERTION

At a glance

What is it?
The AI SDK wraps OpenAI, Anthropic, Google and other model providers behind one TypeScript API, with separate modules for text generation, structured output, agents and UI hooks. It is well suited to TypeScript teams; the licence file needs a closer look before you ship.
Who is it for?
Adopt the AI SDK if your application is already TypeScript and you want one call shape across OpenAI, Anthropic and Google, or a streaming chat UI in React, Svelte or Vue without writing your own transport. Do not adopt it if you need a non-JavaScript runtime, or if you cannot accept that the default model routing goes through the Vercel AI Gateway and that the repository ships a LICENSE file GitHub reports as NOASSERTION.
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 last received commits 12 days ago.
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 17, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem the AI SDK solves for TypeScript teams

Every model vendor ships its own client library with its own request shape, its own streaming format and its own error types. A team that starts on one provider and later adds a second ends up maintaining two code paths for the same feature. The AI SDK's answer is a single call surface: a model is identified by a string such as 'openai/gpt-5.4' or by a provider function such as anthropic('claude-opus-4-6'), and the surrounding code does not change.

The audience is narrow and specific. The README states the toolkit is designed for AI-powered applications and agents built with Next.js, React, Svelte, Vue, Angular and Node.js. If your backend is TypeScript and your front end is one of those frameworks, the fit is direct. If you are writing Python services or Go workers, the library is not aimed at you at all.

One model string, two routing paths

The architecture has two layers. At the bottom, provider packages such as @ai-sdk/openai, @ai-sdk/anthropic and @ai-sdk/google translate the SDK's calls into each vendor's API. On top, the core ai package exposes the functions you actually call: generateText, Output.object for schema-constrained responses, and ToolLoopAgent for tool-calling loops.

By default the SDK routes through the Vercel AI Gateway, which the README describes as giving access to all major providers out of the box. That is convenient, and it is also the detail worth pausing on: the default path sends traffic through Vercel infrastructure rather than straight to the vendor. Connecting directly is supported, but it means installing the provider packages and importing their functions explicitly. Teams with data-residency or procurement constraints should decide which path they want before writing application code, because switching later touches every call site.

Installing the AI SDK and making a first call

The README requires Node.js 22+ and a package manager. The install is a single package:

bash
npm install ai

With that in place, the smallest useful program imports generateText and passes a model string. The README's own example uses 'openai/gpt-5.4' and destructures the text field from the result:

ts
import { generateText } from 'ai';

const { text } = await generateText({
  model: 'openai/gpt-5.4',
  prompt: 'What is an agent?',
});

If you would rather talk to a vendor directly, install that vendor's package and pass a provider function instead of a string. The README gives both forms side by side:

bash
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
ts
import { anthropic } from '@ai-sdk/anthropic';

const result = await generateText({
  model: anthropic('claude-opus-4-6'),
  prompt: 'Hello!',
});

The README also notes a skill for coding agents, added with npx skills add vercel/ai, which is aimed at tools such as Claude Code or Cursor rather than at your runtime.

Structured output and agent loops in the same package

Two features separate the SDK from a thin HTTP wrapper. The first is Output.object, which takes a Zod schema and returns parsed data instead of prose. The README's recipe example nests an object with a name string, an ingredients array of name and amount pairs, and a steps array of strings. The schema is the contract; the model fills it.

The second is ToolLoopAgent, which runs the model, executes the tools it asks for, and feeds results back until the loop ends. The README's shell example defines a tool whose execute function unpacks a command array, runs it in a sandbox, and returns stdout. This is where the SDK stops being a client library and starts being a runtime, and it is also where the failure modes move: a tool that throws, a loop that does not terminate, or a sandbox that is not actually isolated are your problems, not the SDK's. The README shows the shape of the tool, not the error handling around it.

UI hooks and the parts-based message model

For chat interfaces the SDK splits into a separate module. You install the package for your framework, for example npm install @ai-sdk/react, and use the useChat hook. What is distinctive is the message shape: a message carries a parts array, and each part has a type such as 'text' or 'tool-generateImage'. Rendering a tool call means switching on that type and returning a component for each state, in the README's example 'input-available' and 'output-available'.

On the server, createAgentUIStreamResponse takes the agent and the incoming messages and returns the stream. The README's route handler for Next.js App Router is four lines of body. The hooks are described as framework agnostic, so the same message model carries over to Svelte and Vue, but the per-framework packages are separate installs.

Where the AI SDK is the wrong tool

The toolkit is TypeScript-first, and that is a boundary rather than a preference. A Python data pipeline, a Go service or a JVM backend cannot use it, and there is no documented polyglot bridge. If your model calls live outside a JavaScript or TypeScript runtime, look elsewhere.

The second limitation is version spread. The release list shows [email protected], [email protected] and [email protected] all published on 2026-09-09, which means three major lines are receiving releases in parallel. That is good for teams pinned to an older major, and it also means the documentation you read may describe a different major than the one you installed. Check the version in your lockfile against the docs page before copying an example.

The third is maintenance expectations around the licence. The repository's LICENSE file is reported by GitHub as NOASSERTION, meaning the licence could not be matched to a known template. The README does not explain the terms. If your organisation requires an approved open source licence before adoption, that file is the first thing to read, not the last.

How it compares with the LangChain JavaScript packages

LangChain's JavaScript packages solve an overlapping problem, and the repository itself acknowledges the adjacency: there is an examples/next-langchain/ directory alongside the rest of the example apps. The difference is in where the abstraction sits. LangChain centres on chains, retrievers and document loaders, so a retrieval-augmented application has ready-made pieces to assemble. The AI SDK centres on the model call and the UI stream, so provider swapping and streaming chat are first-class while retrieval plumbing is something you bring yourself.

The practical consequence: if your application is mostly a chat interface over one or two models, the AI SDK's surface is smaller and the message parts model maps cleanly onto rendering. If your application is mostly document ingestion and retrieval with a model at the end, you will write more of that yourself here.

Editorial conclusion

Adopt the AI SDK if your application is already TypeScript and you want one call shape across OpenAI, Anthropic and Google, or a streaming chat UI in React, Svelte or Vue without writing your own transport. Do not adopt it if you need a non-JavaScript runtime, or if you cannot accept that the default model routing goes through the Vercel AI Gateway and that the repository ships a LICENSE file GitHub reports as NOASSERTION. Before you commit, install ai in a throwaway project, run generateText against one provider string, and read the LICENSE file together with your own legal team.

Frequently asked questions

Is the Vercel AI SDK free?

The README describes the AI SDK as a free open-source library, and it installs from npm with npm install ai. Model usage is separate: by default the SDK routes through the Vercel AI Gateway, which the README links to Vercel's own documentation rather than describing its terms.

How to install the Vercel AI SDK?

Install Node.js 22+ and a package manager, then run npm install ai. For a chat UI you also install the framework package, for example npm install @ai-sdk/react.

What is the Vercel AI SDK used for?

It is a provider-agnostic TypeScript toolkit for building AI-powered applications and agents. The README covers text generation, schema-constrained structured output, tool-calling agents, and UI hooks for Next.js, React, Svelte and Vue.

How to use the Vercel AI SDK?

Import generateText from ai, pass a model string such as 'openai/gpt-5.4' and a prompt, and read the text field from the result. For agents, use ToolLoopAgent with a tools object; for UI, use the useChat hook from your framework's package.

How to use the Vercel AI Gateway with the AI SDK?

The README states the SDK uses the Vercel AI Gateway by default, so passing a model string for any supported model is enough. To bypass it, install the provider package such as @ai-sdk/anthropic and pass the provider function instead of a string.

Official sources

  1. Issues
  2. Project website
  3. README
  4. Releases
  5. vercel/ai on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/vercel-ai.svg)](https://hysenlabs.com/projects/vercel-ai)