A minimal, open-source chatbot template built with Next.js and the AI SDK — chat, tools, and persistence, nothing else.
Features · Model Provider · Running locally
- Next.js App Router
- React Server Components (RSCs) and Server Actions
- AI SDK
- Streaming chat with tool calling (
getWeather, with a human-in-the-loop approval flow) - Hooks for building dynamic chat UIs
- Streaming chat with tool calling (
- shadcn/ui
- Styling with Tailwind CSS
- Component primitives from Radix UI
- Data Persistence
- Postgres (via Drizzle ORM) for chat history and user data
- Redis (optional) for resumable streams and IP rate limiting
- Auth.js
- Email/password accounts plus guest sessions
This template talks to OpenAI directly via @ai-sdk/openai. The default model is gpt-5-mini; the selectable models live in lib/ai/models.ts. Set OPENAI_API_KEY to use it.
With the AI SDK, you can switch to other providers like Anthropic, Google, or the Vercel AI Gateway by changing lib/ai/providers.ts.
Copy .env.example to .env.local and fill it in. Required: AUTH_SECRET, OPENAI_API_KEY, POSTGRES_URL. Optional: REDIS_URL.
pnpm install
pnpm db:migrate # create the database schema
pnpm devYour app should now be running on localhost:3000.
pnpm smoke runs the app end to end — guest auth, a real chat message, and the tool call — and prints the streamed reply. It exits non-zero with a one-line reason if anything is broken.
pnpm smokeNote: You should not commit your
.env.localfile or it will expose secrets.