vercel/ai: one generateText call across providers, routed through Vercel's AI Gateway unless you opt out
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
At a glance
- What is it?
- The AI SDK is Vercel's provider agnostic TypeScript toolkit for text generation, structured output, tool calling agents and chat UIs. Its shortest path sends model strings through the Vercel AI Gateway, it needs Node.js 22 or newer, and GitHub cannot identify its license, so a few decisions deserve a look before you adopt it.
- Who is it for?
- The AI SDK fits TypeScript teams on Node.js 22 or newer who want one API for several model providers plus chat hooks for Next.js, React, Svelte or Vue. Teams that do not want Vercel infrastructure in the request path should install the @ai-sdk provider packages from day one instead of using bare model strings, and teams with strict license review should read the LICENSE file, since GitHub reports 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 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 November 14, 2026, and from our analysis. They are not legal advice.
Star history
- vercel/ai27,947 ★ · +1,274
| Repository | 2026-09-10 | 2026-11-14 |
|---|---|---|
| vercel/ai | 26.7k | 27.9k |
1,274 Stars in the last 65 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
A bare model string means a trip through Vercel AI Gateway
The AI SDK's headline is a unified API over providers such as OpenAI, Anthropic and Google. The default wiring matters: when you pass a plain string as the model, the SDK uses the Vercel AI Gateway, which gives access to all major providers without installing anything else.
const result = await generateText({
model: 'anthropic/claude-opus-5.5', // or 'openai/gpt-6-astra', 'google/gemini-3.8-flash', etc.
prompt: 'Hello!',
});That convenience has a consequence. Every call written this way depends on Vercel's gateway being part of your stack, so its availability and account terms become yours too. If you want requests to go straight to a provider, install the provider packages and pass a provider function instead of a string:
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/googleimport { 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!',
});Note that the two forms do not use the same identifier: the gateway string is anthropic/claude-opus-5.5 while the direct provider call uses claude-opus-5-5. Switching between them is a code change across every call site, not a configuration flag, so pick the routing early.
Node.js 22 is the floor, and the core package is just ai
The SDK requires Node.js 22 or newer plus npm or another package manager on the development machine. Projects pinned to an older Node release cannot adopt it without a runtime upgrade first. The core package name is short:
npm install aiFramework bindings are separate packages. For React the hooks come from @ai-sdk/react:
npm install @ai-sdk/reactThere is also a skill for coding agents such as Claude Code or Cursor, added to a repository with:
npx skills add vercel/aiThe repository itself carries a skills/ directory alongside .claude/, .cursor/, .codex/ and an AGENTS.md file, so the project is set up for agent assisted work on its own code as well.
Structured output goes through Output.object and a zod schema
Structured data does not use a separate function. You call the same generateText and pass an output option built with Output.object around a zod schema, then read the typed result from output rather than text:
import { generateText, Output } from 'ai';
import { z } from 'zod';
const { output } = await generateText({
model: 'openai/gpt-6-astra',
output: Output.object({
schema: z.object({
recipe: z.object({
name: z.string(),
ingredients: z.array(
z.object({ name: z.string(), amount: z.string() }),
),
steps: z.array(z.string()),
}),
}),
}),
prompt: 'Generate a lasagna recipe.',
});The practical upshot is that zod becomes a dependency of any project that wants typed output, and the schema you write doubles as the shape the model is asked to produce.
ToolLoopAgent examples are not copy and paste ready
Agents are built with ToolLoopAgent, which takes a model, an optional system prompt and a tools map. The sandbox agent sample wires openai.tools.localShell to a Vercel Sandbox: each shell action calls getSandbox(), then sandbox.runCommand with the command and arguments, and returns stdout as output. The image generation sample uses openai.tools.imageGeneration with partialImages set to 3 and exports a message type through InferAgentUIMessage.
These snippets show shape, not finished programs. The sandbox agent uses openai without importing it and calls a getSandbox helper that is never defined, and the page component calls useState without an import. Pasting them unchanged will fail to compile, and the shell tool in particular runs real commands, so you have to supply your own sandbox rather than pointing it at the host you develop on.
UI hooks cover Next.js, React, Svelte and Vue, with Angular only in examples
AI SDK UI is the module of hooks for chatbots and generative interfaces, and the hooks are stated to work in Next.js, React, Svelte and Vue. The end to end pattern is three files: an agent module, a Next.js App Router route that returns createAgentUIStreamResponse with the agent and the incoming messages, and a client page that calls useChat typed with the agent's message type. Tool calls render through UIToolInvocation, whose state moves from input-available to output-available, so a component can show a placeholder such as Generating image... before the result arrives.
Angular appears in the SDK's list of supported UI frameworks and in examples/angular, but not in the list of frameworks the hooks target. Angular teams should start from that example rather than assuming the React hook API carries over.
Three major versions ship side by side
Releases are published per package from a pnpm and Turborepo monorepo managed with Changesets. The most recent batch shipped [email protected], [email protected] and [email protected] within about a minute of each other. Three major lines receiving patch releases at once is good news if you are stuck on 5.x or 6.x, but it also means search results and snippets can come from any of them. The README samples, including ToolLoopAgent and Output.object, should be checked against the major version in your lockfile before you rely on them. The API Reference at ai-sdk.dev/docs/reference is the place to confirm a signature.
GitHub reports the license as NOASSERTION
The project calls itself a free open source library, and the repository contains a LICENSE file, but GitHub's license detection returns NOASSERTION, meaning it could not match the file to a standard license. For hobby work that is a footnote. For companies with an approved license list, it means someone has to read the LICENSE text before the package enters production, because automated scanners keyed to GitHub's detection will not classify it for you.
The monorepo's scripts show where providers and examples live
Contributors work in a private root package named ai-repo. The build script runs turbo build --concurrency 16, build:packages limits it to @ai-sdk/* and ai, and test excludes the @example/* packages. There are scripts to generate and verify model capability docs, validate docs property tables, verify package READMEs, run bundler tests and run a memory benchmark from tools/memory-benchmark. The examples/ directory holds working integrations for Angular, Express, Fastify, Hono, Nest, Nuxt, SvelteKit, MCP, Next.js with Sentry or Upstash rate limits, Next.js with FastAPI and Next.js with LangChain, which are a better starting point than the README fragments. Contribution guidelines live in CONTRIBUTING.md, and questions go to the AI SDK category on the Vercel Community forum.
Editorial conclusion
The AI SDK fits TypeScript teams on Node.js 22 or newer who want one API for several model providers plus chat hooks for Next.js, React, Svelte or Vue. Teams that do not want Vercel infrastructure in the request path should install the @ai-sdk provider packages from day one instead of using bare model strings, and teams with strict license review should read the LICENSE file, since GitHub reports NOASSERTION. Before upgrading, check which of the parallel 5.x, 6.x and 7.x lines your code targets.
Frequently asked questions
what is vercel ai sdk
The AI SDK from vercel/ai is a provider agnostic TypeScript toolkit for building AI applications and agents with frameworks such as Next.js, React, Svelte, Vue and Angular on runtimes like Node.js.
how to install vercel ai sdk
Install Node.js 22 or newer, then run npm install ai. Framework hooks come from separate packages such as @ai-sdk/react.
Is Vercel AI free?
The AI SDK in vercel/ai describes itself as a free open source library. GitHub reports its license as NOASSERTION, so read the LICENSE file in the repository for the exact terms.
what is vercel ai gateway
It is the default route the AI SDK uses when you pass a model string such as 'openai/gpt-6-astra', giving access to all major providers without installing provider packages.
how to use vercel ai sdk
Import generateText from ai and call it with a model and a prompt, for example model 'openai/gpt-6-astra' and prompt 'What is an agent?', then read text from the result.
Official sources
Where developers are discussing it
Posts on Hacker News, dev.to and Lobsters that link to this repository, found by our scan of those communities. 2 in the last 30 days; newest first.
- AI SDK 7.0.163 Added Two Stream Parts in a Patch Release. My Exhaustive Switch Stopped Compilingdev.to · Nov 9, 2026 · 5 points · 1 comments
- November 2–8, 2026: Next.js 16.4.5, AI SDK 7.0.165, TanStack AI 1.2dev.to · Nov 8, 2026 · 5 points · 0 comments
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.
[](https://hysenlabs.com/projects/vercel-ai)Star history chart for your README
[](https://hysenlabs.com/projects/vercel-ai)Was this useful?