|
| 1 | +<a href="https://chat.vercel.ai/"> |
| 2 | + <img alt="Next.js 14 and App Router-ready AI chatbot." src="app/(chat)/opengraph-image.png"> |
| 3 | + <h1 align="center">Next.js AI Chatbot</h1> |
| 4 | +</a> |
| 5 | + |
| 6 | +<p align="center"> |
| 7 | + An Open-Source AI Chatbot Template Built With Next.js and the AI SDK by Vercel. |
| 8 | +</p> |
| 9 | + |
| 10 | +<p align="center"> |
| 11 | + <a href="#features"><strong>Features</strong></a> · |
| 12 | + <a href="#model-providers"><strong>Model Providers</strong></a> · |
| 13 | + <a href="#deploy-your-own"><strong>Deploy Your Own</strong></a> · |
| 14 | + <a href="#running-locally"><strong>Running locally</strong></a> |
| 15 | +</p> |
| 16 | +<br/> |
| 17 | + |
| 18 | +## Features |
| 19 | + |
| 20 | +- [Next.js](https://nextjs.org) App Router |
| 21 | + - Advanced routing for seamless navigation and performance |
| 22 | + - React Server Components (RSCs) and Server Actions for server-side rendering and increased performance |
| 23 | +- [AI SDK](https://sdk.vercel.ai/docs) |
| 24 | + - Unified API for generating text, structured objects, and tool calls with LLMs |
| 25 | + - Hooks for building dynamic chat and generative user interfaces |
| 26 | + - Supports OpenAI (default), Anthropic, Cohere, and other model providers |
| 27 | +- [shadcn/ui](https://ui.shadcn.com) |
| 28 | + - Styling with [Tailwind CSS](https://tailwindcss.com) |
| 29 | + - Component primitives from [Radix UI](https://radix-ui.com) for accessibility and flexibility |
| 30 | +- Data Persistence |
| 31 | + - [Vercel Postgres powered by Neon](https://vercel.com/storage/postgres) for saving chat history and user data |
| 32 | + - [Vercel Blob](https://vercel.com/storage/blob) for efficient file storage |
| 33 | +- [NextAuth.js](https://github.com/nextauthjs/next-auth) |
| 34 | + - Simple and secure authentication |
| 35 | + |
| 36 | +## Model Providers |
| 37 | + |
| 38 | +This template ships with OpenAI `gpt-4o` as the default. However, with the [AI SDK](https://sdk.vercel.ai/docs), you can switch LLM providers to [OpenAI](https://openai.com), [Anthropic](https://anthropic.com), [Cohere](https://cohere.com/), and [many more](https://sdk.vercel.ai/providers/ai-sdk-providers) with just a few lines of code. |
| 39 | + |
| 40 | +## Deploy Your Own |
| 41 | + |
| 42 | +You can deploy your own version of the Next.js AI Chatbot to Vercel with one click: |
| 43 | + |
| 44 | +[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot&env=AUTH_SECRET,OPENAI_API_KEY&envDescription=Learn%20more%20about%20how%20to%20get%20the%20API%20Keys%20for%20the%20application&envLink=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot%2Fblob%2Fmain%2F.env.example&demo-title=AI%20Chatbot&demo-description=An%20Open-Source%20AI%20Chatbot%20Template%20Built%20With%20Next.js%20and%20the%20AI%20SDK%20by%20Vercel.&demo-url=https%3A%2F%2Fchat.vercel.ai&stores=[{%22type%22:%22postgres%22},{%22type%22:%22blob%22}]) |
| 45 | + |
| 46 | +## Running locally |
| 47 | + |
| 48 | +You will need to use the environment variables [defined in `.env.example`](.env.example) to run Next.js AI Chatbot. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/projects/environment-variables) for this, but a `.env` file is all that is necessary. |
| 49 | + |
| 50 | +> Note: You should not commit your `.env` file or it will expose secrets that will allow others to control access to your various OpenAI and authentication provider accounts. |
| 51 | +
|
| 52 | +1. Install Vercel CLI: `npm i -g vercel` |
| 53 | +2. Link local instance with Vercel and GitHub accounts (creates `.vercel` directory): `vercel link` |
| 54 | +3. Download your environment variables: `vercel env pull` |
| 55 | + |
| 56 | +```bash |
| 57 | +pnpm install |
| 58 | +pnpm dev |
| 59 | +``` |
| 60 | + |
| 61 | +Your app template should now be running on [localhost:3000](http://localhost:3000/). |
0 commit comments