Vercel AI SDK Tutorial
Welcome to the Vercel AI SDK tutorial. It follows the official AI SDK docs (7.x) so you can wire LLMs into Next.js, React, and Node.js: streaming chat, tool calling, structured output, and (experimental) generative UI.
The SDK standardizes vendor APIs. The default global provider is Vercel AI Gateway (one AI_GATEWAY_API_KEY, then model strings). You can also install @ai-sdk/openai and talk to OpenAI directly. This tutorial uses openai/gpt-4.1-mini as the Gateway-style default. Model IDs change—always check the official docs and your provider console.
Table of contents
Basics
- Introduction — Positioning, three surfaces, vs LangChain
- Installation — Node 22+, pnpm, env vars, ESM
- Quick start —
generateTextand your first streaming chat
Development
- useChat —
@ai-sdk/react,parts,sendMessage, status - Streaming —
streamText, UI Message Stream, text streams - Tools —
tool(), Zod,stopWhen, multi-step loops - RSC and streamUI — Experimental generative UI and Server Actions
Integration
- Providers — Gateway vs direct, OpenAI-compatible, Ollama
- Next.js — App Router route handlers,
maxDuration, deploy
Practice
- Practical examples — Chat, multi-tool assistant, structured extract
- Resources — Official docs and related courses on this site
Learning path
Prerequisites
- TypeScript basics (
import, types, async/await) - React components and hooks; chat pages need
'use client' - Next.js App Router (
app/api/.../route.ts) - Node.js 22+ and pnpm (official quickstart)
Three surfaces (mental model)
AI SDK RSC (streamUI in @ai-sdk/rsc) is still experimental. Prefer AI SDK UI in production.
Related tutorials on this site
What you will be able to do
- Call
generateTextonce via a Gateway string and once via@ai-sdk/openai - Build realtime chat in Next.js with
streamText+useChat - Define Zod tools and run multi-step calls with
isStepCount - Point
@ai-sdk/openai-compatibleat Ollama/v1
Canonical sources: sdk.vercel.ai/docs, ai-sdk.dev/llms.txt. This tutorial does not invent undocumented APIs.