Skip to content

Repository files navigation

Chatbot

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


Features

  • 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
  • shadcn/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

Model Provider

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.

Running locally

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 dev

Your app should now be running on localhost:3000.

Verifying

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 smoke

Note: You should not commit your .env.local file or it will expose secrets.

Releases

Packages

Contributors

Languages