ai-sdk
AI SDK documentation and guidance for building AI-powered features with Vercel's framework.
- Covers core APIs including
generateText,streamText,ToolLoopAgent,embed, and tool calling across multiple AI providers (OpenAI, Anthropic, Google, etc.) - Supports building agents, chatbots, RAG systems, and text generation with structured output and streaming capabilities
- Includes React hooks (
useChat,useCompletion) and framework-specific patterns for Next.js, SvelteKit, and other platforms - Provides type-safe agent consumption with
InferAgentUIMessagefor end-to-end type safety and local DevTools for debugging
What the AI SDK Is
The AI SDK by Vercel (the ai package on npm) is a TypeScript toolkit for building AI applications. It provides a unified API across model providers for text generation, structured output, tool calling, agents, embeddings, and framework UI integrations.
- Repository: https://github.com/vercel/ai
- Documentation: https://ai-sdk.dev/docs
Critical: Do Not Trust Your Own Memory
Whatever you remember about the AI SDK is likely outdated. The SDK changes frequently across versions - APIs are renamed, removed, and added. Your training data almost certainly contains obsolete APIs, deprecated patterns, and model IDs that no longer exist. UI hooks like useChat are among the most frequently changed APIs, so be especially careful with client code.
Never write AI SDK code from memory. Always verify every API, option, and pattern against the documentation and source code for the version that is actually installed in the project.
Use the Bundled, Version-Matched Docs
The ai package ships its full documentation and source code inside node_modules. These always match the installed version, so trust them over anything you remember.
More in Next.js
vercel-react-best-practices
69 prioritized React and Next.js performance rules across 8 categories
vercel-labs/agent-skillsvercel-composition-patterns
Composable component architecture patterns for scalable Next.js apps
vercel-labs/agent-skillsnext-best-practices
File conventions, RSC boundaries, data patterns, async APIs, and metadata
vercel-labs/next-skillsdeploy-to-vercel
Deploy Next.js apps to Vercel with correct config and environment setup
vercel-labs/agent-skillsnext-cache-components
PPR, use cache directive, cacheLife, cacheTag, and revalidateTag
vercel-labs/next-skills