Patterns Overview

PreviousNext

Production-ready AI patterns built with the Vercel AI SDK. Understand the pattern system, categories, and how to use them.

Patterns are production-ready AI implementations you can copy into your Next.js project. Each pattern solves a specific problem — generating text, building chat UIs, orchestrating agents, integrating tools.

How Patterns Work

Every pattern is a self-contained implementation with:

  • Preview — live interactive demo in the browser
  • Source code — all files needed (components, API routes, utilities)
  • CLI install — one command to scaffold it into your project

Install via CLI

pnpm dlx shadcn add https://shadcnagents.com/r/{pattern-slug}

For example:

# Add a basic chat interface npx shadcn add https://shadcnagents.com/r/ai-elements-chat # Add text streaming npx shadcn add https://shadcnagents.com/r/basics-stream-text # Add web search tool npx shadcn add https://shadcnagents.com/r/tool-websearch-claude

Manual Installation

  1. Visit any pattern page at /patterns
  2. Switch to the Code tab
  3. Copy the source files into your project
  4. Install dependencies listed in the pattern

Categories

Patterns are organized into 9 categories based on what you're building.

Getting Started

The fundamentals. Text generation, streaming, image generation, speech, transcription, tool calling, and agent setup.

PatternDescription
Generate TextBasic text generation with AI models
Stream TextReal-time token streaming
Generate ImageAI image creation
Generate SpeechText to speech synthesis
Transcribe AudioSpeech to text transcription
Tool CallingFunction and tool invocation
Agent SetupCreate an AI agent

Chat & Conversations

Chat interfaces and display elements for building conversational AI products.

PatternDescriptionTier
Basic ChatSimple chat interfaceFree
ChatGPT CloneOpenAI-style chat UIPro
Claude CloneAnthropic-style chat UIPro
Grok ClonexAI-style chat UIPro
Reasoning DisplayShow model thinking processFree
Sources & CitationsReference and source displayFree
Plan DisplayStep-by-step plan renderingFree
Tool ApprovalConfirm tool actions inlineFree
Queue DisplayTask queue visualizationFree

Agents & Orchestration

Multi-agent patterns for routing, orchestration, and parallel execution.

PatternDescriptionTier
Routing PatternRoute requests to specialized agentsFree
Parallel ProcessingConcurrent agent executionFree
Orchestrator-WorkerDelegate subtasks to workersPro
Evaluator-OptimizerSelf-improving feedback loopsPro

Human in the Loop

Patterns for human oversight, approval flows, and user input gathering.

PatternDescriptionTier
Tool Approval BasicSimple approval flowFree
Context BuilderAgent-guided context gatheringPro
Needs ApprovalGated tool executionPro

Tools & Integrations

Web search, scraping, and file processing integrations.

PatternDescriptionTier
Claude Web SearchAnthropic search integrationFree
Exa Web SearchExa neural searchFree
Cheerio ScraperHTML DOM parsingFree
Jina AI ScraperAI-powered web scrapingFree
Markdown ScraperURL to markdown conversionFree
PDF AnalysisPDF file processingFree

Workflows & Pipelines

Sequential, parallel, and durable workflow patterns.

PatternDescriptionTier
URL AnalysisBasic URL analysis workflowFree
Sequential WorkflowStep-by-step execution flowPro
Evaluator WorkflowQuality assessment pipelinePro
Orchestrator WorkflowManaged task delegationPro

Artifacts & Generation

Structured output generation — tables, charts, JSON rendering.

PatternDescriptionTier
Table EditorEditable data tablesFree
Chart GenerationData visualizationFree
JSON Render ShadcnUI generation from JSONPro

Marketing & Landing

Pre-built sections for AI product landing pages.

PatternDescriptionTier
Code Block 1Code feature showcaseFree
Code Block 2Alternative code showcaseFree
Code Block 3Dark code showcaseFree
Feature GridGrid feature layoutFree
Bento LayoutBento grid compositionFree
Model ComparisonSide-by-side model comparePro

Full Examples

Complete applications combining multiple patterns.

PatternDescriptionTier
Chat-Base CloneFull-stack chat applicationPro
Form GeneratorDynamic form builderPro
Data Analysis AgentData insight extractionPro

Architecture

Every AI pattern follows the same structure:

components/stacks/{pattern-name}/
├── {pattern-name}.tsx     # Main component (client-side)
├── actions.ts             # Server actions (AI SDK calls)
└── types.ts               # TypeScript types (optional)

Client component — handles UI, state, user interaction. Uses useChat, useCompletion, or custom hooks from the AI SDK.

Server actions — makes the actual AI API calls using generateText, streamText, tool, or agent from the Vercel AI SDK. Runs server-side, keeps API keys secure.

Switching Providers

All patterns use the Vercel AI SDK's provider abstraction. Swap models in one line:

// Anthropic import { anthropic } from "@ai-sdk/anthropic" const model = anthropic("claude-sonnet-4-20250514") // OpenAI import { openai } from "@ai-sdk/openai" const model = openai("gpt-4o") // Google import { google } from "@ai-sdk/google" const model = google("gemini-2.0-flash")

Every pattern that calls an AI model accepts a model parameter. Change the import and model string — everything else stays the same.