Note START by importing this repo into v0
Learn to build modern AI-powered applications with the latest Vercel AI SDK and v0
This is a hands-on workshop template for AI Ship 2025 that teaches you how to refactor AI applications from traditional patterns to modern, secure, and scalable approaches using the latest Vercel AI SDK v5 features. The workshop focuses on migrating to best practices including agents, workflows, structured outputs, and AI Elements.
- Next.js - React framework for production
- AI SDK 5 - Vercel's AI SDK with modern agent patterns
- shadcn/ui - Beautiful, accessible component library
- AI Gateway - All AI providers in one place
- AI Elements - Pre-built UI components for AI interactions
- Upstash KV - Redis-compatible storage for workflows
- Workflows SDK - Long-running async operations
- Vercel Sandbox - Secure code execution environment
Before starting the workshop, ensure you have:
- ✅ React knowledge
- ✅ Next.js experience
- ✅ v0 Account
- ✅ Vercel Account
- ✅ Vercel AI Gateway API key
- ✅ GitHub Account
- ✅ Node.js and pnpm installed
Run the development server:
pnpm install
vercel link
vercel env pull
pnpm dev
Open http://localhost:3000 to see your application.
Test the application with "iPhone" in the brand input field.
- Clone workshop template from v0.dev into your personal workspace
- Connect your v0 project to GitHub and create new repository
- Deploy project from v0 to Vercel and verify deployment
- Clone GitHub repository to your local machine
- Run
pnpm installto install dependencies - Run
vercel linkto link your local project to vercel project - Set up environment variables with
vercel env pull - Test the application locally with
pnpm dev
- Import
Experimental_Agent as AgentandOutputfromaipackage - Refactor
create-brand-contextAPI route to use Agent class withexperimental_output: Output.object() - Add system prompt to create-brand-context Agent
- Create Zod schema for brand context structured output
- Ensure contextData matches
BrandContexttype fromupstash.ts - Refactor
generate-questionsAPI route to use Agent class with structured output - Add system prompt to generate-questions Agent with brand name restrictions
- Create validation tool that checks for brand mentions in questions
- Configure Agent with
stopWhen: stepCountIs(3)for max 3 steps - Update Agent system prompt to instruct calling validateQuestions tool
- Remove manual validation check and trust Agent tool validation
- Ensure questions match
Question[]type fromupstash.ts - Refactor
check-visibilityAPI route to use Agent class - Add system prompt to check-visibility Agent for brand detection
- Create Zod schema for brand detection with
isVisibleandpositionfields - Ensure answerData matches
VisibilityAnswertype fromupstash.ts - Test all three API routes with brand name input
- Install
@next/envpackage for environment variable loading - Create
lib/envConfig.tswithloadEnvConfigfrom@next/env - Create
scripts/full-agent-flow.tsto importenvConfigat the top - Use types from
lib/upstash.tsandlib/constants.ts - Create
checkVisibilityfunction withPromise.allSettledfor parallel execution - Test CLI script locally with
pnpm full-agent-flow iphone run222 - Verify all 27 checks run in parallel
- Confirm results are stored in Redis with the correct runId
- Install
@vercel/sandbox,ms, and@types/mspackages - Create
app/api/full-flow-agent/route.tsendpoint - Configure Sandbox to clone from GitHub repository
- Set Sandbox resources to 4 vCPUs and 10 minute timeout
- Pass all required environment variables to
runCommand(not Sandbox.create) - Run
pnpm installin Sandbox with environment variables - Execute
pnpm full-agent-flow <brand> <runId>in detached mode - Do not use
sandbox.stop()to keep sandbox running until completion - Update
app/page.tsxto call/api/full-flow-agentinstead of 3 separate routes - Remove unused
MODELSimport frompage.tsx - Update button text to indicate Sandbox execution
- Test locally with
vercel env pullfor OIDC token - Test endpoint with
curl -X POST http://localhost:3000/api/full-flow-agent -H "Content-Type: application/json" -d '{"brand": "iphone"}' - Verify frontend polling displays results in real-time
- Push changes to GitHub main branch
- Sync v0 with GitHub to pull latest changes
- Verify deployment on Vercel production
- Test production Sandbox endpoint
- Monitor sandboxes in Vercel Dashboard Observability tab
- Test production application end-to-end
Once you've completed Phase 1-5, try these advanced challenges:
- Integrate AI Elements into results display
- Use v0 to generate chart components for visualization
- Add interactive data visualizations to results
- Implement BotID for bot detection and prevention
- Add rate limiting middleware to API routes
- Configure Vercel Firewall or Upstash rate limiting
- Monitor and log API usage patterns
- Add Stripe for payment processing
- Claim Stripe Sandbox account
- test Stripe payment processing in Stripe dashboard
- Make sure you have
AI_GATEWAY_API_KEYenvironment variable set in.env.local - Make sure youhave REDIS connected in v0 and then do
vercel env pullto pull the environment variables into your local environment.
- AI SDK v5 Documentation
- Agent Building Guide
- Vercel Sandbox Documentation
- v0 Documentation
- Next.js Documentation
- Next.js Environment Variables
Happy Building! 🚀