# Vercel AI SDK

> Provider-agnostic TypeScript toolkit for building AI apps, agents, and chat UIs

- Category: App UIs & Builders / Generative UI SDKs
- Language: TypeScript
- Repository: https://github.com/vercel/ai
- Website: https://ai-sdk.dev
- Canonical page: https://ai-tldr.dev/tools/vercel-ai-sdk/

## In short

Vercel AI SDK is Provider-agnostic TypeScript toolkit for building AI apps, agents, and chat UIs. It gives you one API to call models from providers like OpenAI, Anthropic, and Google, so you can swap models without rewriting your app code. It sits in the Generative UI SDKs category of the App UIs & Builders tools and is open-source, written in TypeScript.

## Overview

The Vercel AI SDK is a provider-agnostic TypeScript toolkit for building AI-powered applications and agents. It gives you one API to call models from providers like OpenAI, Anthropic, and Google, so you can swap models without rewriting your app code.

It is aimed at JavaScript and TypeScript developers working with UI frameworks such as Next.js, React, Svelte, Vue, and Angular, or on runtimes like Node.js. Core functions like generateText handle text generation, structured output, and tool-using agents.

In the generative UI space, the AI SDK UI module adds framework-agnostic hooks (such as useChat) that stream model output into your interface and let you render tool calls as React components, which fits its role as a generative-UI SDK.

## What it does

- Unified, provider-agnostic API to call OpenAI, Anthropic, Google, and other model providers by passing a model string
- Works across popular UI frameworks: Next.js, React, Svelte, Vue, Angular, plus Node.js runtimes
- Text generation, structured output via Zod schemas (Output.object), and tool-loop agents with ToolLoopAgent
- AI SDK UI hooks like useChat for building chatbots and streaming, generative interfaces
- Render tool invocations as React components using UIToolInvocation and streamed message parts
- Vercel AI Gateway built in by default for access to major providers, or connect providers directly with @ai-sdk/* packages

## Getting started

You need Node.js 22+ and npm (or another package manager). Install the core package, then generate text; add the React UI package when you build a chat interface.

1. Install the core package

   Add the main ai package to your project.

```bash
npm install ai
```

2. Generate text

   Call generateText with a model string. By default this routes through the Vercel AI Gateway.

```ts
import { generateText } from 'ai';

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

3. Connect a provider directly (optional)

   Install a provider package and pass its model helper instead of a gateway string.

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

4. Add UI hooks for chat

   Install the package for your framework to use hooks like useChat for streaming chatbots and generative UI.

```bash
npm install @ai-sdk/react
```

## When to use it

- Build a streaming chatbot in Next.js or React that renders tool calls as live UI components
- Generate structured data from a model using a Zod schema for type-safe output
- Create tool-using agents with ToolLoopAgent that run shell commands or generate images
- Keep your app provider-agnostic so you can switch between OpenAI, Anthropic, and Google models
