A simple chat app built with Next.js, Tailwind CSS, and OpenAI API.
- Clone the repo:
git clone https://github.com/komzweb/nextjs-gpt-api-chat.git
- 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.
- Install dependencies:
npm install
# or
yarn
# or
pnpm
- Run the server:
npm run dev
# or
yarn dev
# or
pnpm dev
Open http://localhost:3000 with your browser to see the result.
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."
Almost same as ChatGPT!