# Vercel AI Chatbot

> Open-source Next.js starter for building full-featured AI chatbots with the AI SDK

- Category: App UIs & Builders / Chat UIs
- Language: TypeScript
- Repository: https://github.com/vercel/chatbot
- Website: https://chat.vercel.ai
- Canonical page: https://ai-tldr.dev/tools/vercel-ai-chatbot/

## In short

Vercel AI Chatbot is Open-source Next.js starter for building full-featured AI chatbots with the AI SDK. It sits in the Chat UIs category of the App UIs & Builders tools and is open-source, written in TypeScript. To get started: install the Vercel CLI and link your project.

## Overview

Vercel AI Chatbot (formerly AI Chatbot) is a free, open-source template built with Next.js and the AI SDK. It gives you a working chatbot application out of the box, so you can start from a complete project instead of wiring up the chat UI, routing, and model calls yourself.

It's aimed at developers who want to ship an AI chat app on Next.js. The template uses the App Router with React Server Components, shadcn/ui components styled with Tailwind CSS, Auth.js for sign-in, Neon Serverless Postgres for chat history, and Vercel Blob for file storage.

As a chat UI starter, it routes across multiple models through the Vercel AI Gateway, with per-model routing configured in lib/ai/models.ts. You can also switch to direct LLM providers such as OpenAI, Anthropic, or Cohere with a few lines of code.

## What it does

- Built on Next.js App Router with React Server Components and Server Actions
- Uses the AI SDK for text, structured objects, tool calls, and chat hooks
- Multi-model routing via the Vercel AI Gateway, configured in lib/ai/models.ts
- shadcn/ui components with Tailwind CSS and Radix UI primitives
- Chat history and user data stored in Neon Serverless Postgres; files in Vercel Blob
- Authentication handled by Auth.js

## Getting started

You can deploy your own copy to Vercel with one click, or run it locally with the Vercel CLI to pull environment variables. The steps below follow the README's local setup.

1. Install the Vercel CLI and link your project

   Install the CLI globally, link the local instance to your Vercel and GitHub accounts, then pull the environment variables defined in .env.example.

```bash
npm i -g vercel
vercel link
vercel env pull
```

2. Install dependencies, migrate the database, and run

   Install packages, apply the latest database changes, and start the dev server. The app runs on localhost:3000.

```bash
pnpm install
pnpm db:migrate
pnpm dev
```

3. Configure model access (non-Vercel deployments)

   On Vercel, AI Gateway auth is automatic via OIDC tokens. Elsewhere, set an AI Gateway API key in your .env.local file.

```bash
AI_GATEWAY_API_KEY=your_key_here
```

## When to use it

- Bootstrapping a production-style AI chat app on Next.js without building the UI, routing, and persistence from scratch
- Prototyping with several models behind one interface by configuring per-model routing in lib/ai/models.ts
- Adding saved chat history and authenticated user accounts to a chatbot using Postgres and Auth.js
- Starting point for a custom assistant that you later point at a direct provider like OpenAI or Anthropic
