next-openai-chatgpt icon indicating copy to clipboard operation
next-openai-chatgpt copied to clipboard

Next.js + OpenAI API ChatGPT

OpenAI ChatGPT + NextJs

This example shows how to implement a simple chat bot using Next.js and OpenAI API.

Online Demo: https://next-openai-chatgpt.vercel.app

Preview

Set up environment variables

  • rename .env.example to .env.local:
cp .env.example .env.local
  • update OPENAI_API_KEY with your OpenAI secret key.
OPENAI_API_KEY = xxxxx;

Development

npm install
npm run dev

# or

yarn
yarn dev

View the app at http://localhost:3000