AI SDK Patterns
that compose into apps
16 open-source AI SDK patterns — primitives, then the agent loop. Chat, tools, HITL, RAG, MCP. Pick patterns, generate a full-stack Next.js app.
✓ Streaming response readyProvider: anthropic | Model: claude-sonnet-4-5Provider-agnostic — works with any AI SDK provider
Interactive feature showcase
Explore core AI SDK capabilities with animated examples. Click any card to see the actual pattern implementation.
Start with the agent loop
10 patterns that cover calling a model, giving it tools, and stopping for a human. Compose them into one app.
Streaming Chat
PopularStream text responses from AI models in real-time using streamText and the useChat hook.
"name": "..."
"score": 42
}
Structured Output
Generate typed, validated JSON data using Zod schemas and generateText with Output.object.
Tool Calling
PopularLet the AI model call functions and use external tools with the multi-step tool loop.
Generative UI
Render dynamic React components from AI tool calls using streamText and useChat.
Multi-Step Agent
PopularBuild an agent that orchestrates multiple tool calls in sequence, using stopWhen: stepCountIs() and automatic tool result forwarding.
Human-in-the-Loop
Pause AI execution to get human approval before executing sensitive tool calls. Uses tool confirmation flow with the AI SDK.
Web Search Agent
Integrate third-party search APIs (Tavily, Exa) with the AI SDK to build a grounded search agent with source citations.
RAG Pipeline
PopularRetrieval-Augmented Generation: embed documents, store in a vector database, and retrieve context for grounded AI responses.
MCP Client Agent
NewConnect to any Model Context Protocol server, discover tools dynamically, and let the AI use them in a chat interface. Includes a demo MCP server with weather and calculator tools.
Chat with Citations
A chat interface that includes inline source citations with expandable source cards. Responses include numbered references that link to source details.
One pattern or many — your call
Install a single pattern via CLI, or use the Composer to merge several into one integrated Next.js app.
npx shadcn add https://ai-sdk-patterns.dev/r/streaming-chat100% open source — no accounts, no paywalls