# The AI layer for building frameworks and agents on Vercel

[Read the docs](https://ai-sdk.dev/)

$npm i ai

A unified TypeScript SDK for building AI apps with modern streaming, multi-model, and provider-agnostic capabilities

```
1import { generateText } from 'ai';
2

3const { text } = await generateText({
4  model: 'openai/gpt-5.6-luna',
5  prompt: 'Explain the concept of quantum entanglement.',
6});
7

8console.log(text);
```

Use with [AI Gateway](/ai-gateway)

-
-
-
-
-
-
-
-
-
-
-
-
-

## The framework agnostic AI toolkit

## AI SDK features

- Multi-provider supportSwitch providers with one line of code.

- Streaming that just worksReal-time responses without custom parsing.

- Built-in fallbacksReliable production behavior by default.

- AI Gateway compatibleRoute to any model through one endpoint.

## AI SDK code examples

[AI Playground](https://ai-sdk.dev/playground)

### generate-text.ts

Code

Preview

Explain quantum entanglement.

Ask a question…

## Scale with confidence

Plug the AI SDK into an entire ecosystem designed for modern AI applications that scale.

[

Vercel AI GatewayAccess 100+ models with no markup or having to manage multiple API keys.

```
npm i ai
```

](https://vercel.com/ai-gateway) [

Vercel SandboxRun agent generated code securely and at scale.

```
npm i @vercel/sandbox
```

](https://vercel.com/sandbox) [

Workflows

New

Build long running AI agents and apps that can suspend, resume, and survive function timeouts.

```
npm i workflow
```

](https://vercel.com/workflows) [

AI ElementsA UI component library and custom registry built to build AI-native applications faster.

```
npx ai-elements
```

](https://elements.ai-sdk.dev/)

![Opencode](/vc-ap-vercel-marketing/_next/static/immutable/media/opencode-light.1gk03ehqr67pj.svg)![Opencode](/vc-ap-vercel-marketing/_next/static/immutable/media/opencode-dark.28y5ytz1v28k0.svg)

> “OpenCode uses AI SDK.”

Dax RaadCEO & Founder, OpenCode

## Build with the AI SDK today

[

Chatbot Starter TemplateLearn how to build a full-featured AI chatbot with persistence, multi-modal chat, and more.

```
Copy install prompt
```

](https://vercel.com/templates/next.js/chatbot) [

Build a Slackbot AgentLearn how to build a Slackbot that responds to direct messages and mentions in channels.

```
Copy install prompt
```

](https://vercel.com/templates/other/ai-sdk-slackbot) [

Build a SQL AgentLearn how to build an app that interacts with a PostgreSQL database using natural language.

```
Copy install prompt
```

](https://vercel.com/templates/next.js/natural-language-postgres)