Universal AI layer for building frameworks and agents

A unified TypeScript SDK for building AI apps with modern streaming, fallbacks, and multi-model support—powered by Vercel

$npm install ai
generate-text.ts
import { generateText } from 'ai';

const { text } = await generateText({
  model: 'spacexai/grok-4.7',
  prompt: 'Explain the concept of quantum entanglement.',
});

console.log(text);
Explain quantum entanglement in simple terms.
Entanglement is nature's way of keeping a secret between two particles. Once entangled, observing one instantly reveals information about the other — no signal needed, no matter how far apart they are.

See all supported LLM models

Weekly downloads
34.5M
GitHub stars
27.2K
Contributors
728+
Models supported
100+

The framework agnostic AI toolkit

The open-source AI toolkit designed to help developers build AI-powered applications and agents with React, Next.js, Vue, Svelte, Node.js, and more.

  • Next.js
  • React
  • Svelte
  • Angular
  • Vue
  • Nuxt
  • Solid
  • Multi-provider support

    Switch providers with one line of code.

  • Streaming that just works

    Real-time responses without custom parsing.

  • Built-in fallbacks

    Reliable production behavior by default.

  • AI Gateway compatible

    Route to any model through one endpoint.

AI Playground

generate-text.ts

Scale with confidence

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

What builders say about the AI SDK

“We built a full AI agent with 40+ tools, resumable streams, and multi-step reasoning on AI SDK. Every hard problem we’d solved with duct tape before, streaming, tool call repair, message management, tool based UI, they already had a clean API for.”
Adir DuchanSenior AI Engineer, Elementor
“OpenCode uses AI SDK.”
Dax RaadCEO & Founder, OpenCode

Build with the AI SDK today

Get started with the AI SDK by using our recipes or templates.

Read the docs
$npm i ai