Skip to content

Simple chat app with OpenAI API and Next.js 13 App Router

Notifications You must be signed in to change notification settings

komzweb/chatgpt-nextjs-app-router

Repository files navigation

ChatGPT Next.js App Router

A simple chat app built with Next.js 13 App Router, Tailwind CSS, and OpenAI API.

ChatGPT Next.js App Router

Project Setup

  1. Clone the repo:
git clone https://github.com/komzweb/chatgpt-nextjs-app-router.git
  1. Add your OpenAI API key:
cd chatgpt-nextjs-app-router
cp .env.local.example .env.local

Set your secret API key to OPENAI_API_KEY in the .env.local file.

  1. Install dependencies:
npm install
# or
yarn
# or
pnpm
  1. Run the server:
npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

Configuration

app/api/openai/route.ts

  • If you belong to multiple organizations, you can specify your organization ID. See the API Reference for details.
  • You can change the system message and set the behavior of your assistant. By default, the assistant is instructed to be "You are a helpful assistant who speaks Japanese Kansai dialect."

Usage

Almost same as ChatGPT!