Skip to content

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

Notifications You must be signed in to change notification settings

komzweb/nextjs-gpt-api-chat

Repository files navigation

Next.js GPT API Chat

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

Next.js GPT API Chat

Project Setup

  1. Clone the repo:
git clone https://github.com/komzweb/nextjs-gpt-api-chat.git
  1. Add your OpenAI API key:
cd nextjs-gpt-api-chat
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

pages/api/openai.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!