Prerequisites
Before you begin, make sure you have:- Node.js 18.x or higher installed
- pnpm 9.x or higher (specified in package.json:
[email protected]) - A Vercel account (for AI Gateway, Blob storage, and Postgres)
- Git installed on your machine
The chatbot uses pnpm as its package manager. While you can use npm or yarn, pnpm is recommended for consistency with the project configuration.
Get started in 5 steps
Clone the repository
Clone the chatbot repository to your local machine:This downloads the complete chatbot template including all source code, configuration files, and database schemas.
Install dependencies
Install all required packages using pnpm:This installs:
- Next.js 16 - React framework with App Router
- AI SDK 6.0 - Vercel’s AI toolkit for LLM integration
- Drizzle ORM - TypeScript ORM for database operations
- Auth.js - Authentication framework
- shadcn/ui - UI component library
- And 90+ other dependencies for a complete chatbot experience
Installation typically takes 1-2 minutes depending on your internet connection.
Set up environment variables
Create a Open
.env.local file in the root directory with your configuration:.env.local and configure the required variables:.env.local
Quick setup with Vercel CLI
If you’re deploying to Vercel, you can automatically pull environment variables:Run database migrations
Set up your database schema by running migrations:This command:
- Connects to your PostgreSQL database using
POSTGRES_URL - Creates all required tables (users, chats, messages, documents, etc.)
- Applies the latest schema changes from
lib/db/migrations
If
POSTGRES_URL is not defined, migrations will be skipped. This is useful for deployments where migrations run automatically.Start the development server
Launch the chatbot in development mode:This starts:
- Next.js development server with Turbopack (faster builds)
- Hot module replacement for instant updates
- API routes for chat, documents, and authentication
Verify your setup
Once the server is running, test your chatbot:- Open your browser to http://localhost:3000
- Create an account or sign in (Auth.js handles this automatically)
- Start chatting - Try asking “What can you help me with?”
- Test file uploads - Upload a document to see the artifact system in action
By default, the chatbot uses GPT-4.1 Mini via Vercel AI Gateway. You can switch to other models like Claude or Gemini in the model selector.
Common issues
Migration fails with connection error
Migration fails with connection error
Problem:
POSTGRES_URL is not configured correctly.Solution:- Verify your database connection string is correct
- Ensure your database is accessible (check firewall/network settings)
- For Vercel Postgres, make sure you’ve created a database in your project
AI Gateway authentication error
AI Gateway authentication error
Problem: Missing or invalid
AI_GATEWAY_API_KEY.Solution:- Create an API key at https://vercel.com/ai-gateway
- For Vercel deployments, OIDC tokens are used automatically (no key needed)
- Verify the key is correctly set in
.env.local
Port 3000 already in use
Port 3000 already in use
Problem: Another process is using port 3000.Solution:
Next steps
Now that your chatbot is running:Explore features
Learn about the chat interface, artifacts, and AI tools
Add AI tools
Extend your chatbot with custom tools and capabilities
Deploy to Vercel
Deploy your chatbot to production in one click
Customize UI
Make the chatbot match your brand
Available scripts
Here are the key commands you’ll use during development:| Command | Description |
|---|---|
pnpm dev | Start development server with Turbopack |
pnpm build | Build for production (runs migrations first) |
pnpm start | Start production server |
pnpm db:migrate | Run database migrations |
pnpm db:studio | Open Drizzle Studio to view database |
pnpm db:generate | Generate new migration files |
pnpm lint | Check code quality with Ultracite |
pnpm format | Auto-fix formatting issues |