- clone repo
npm i
- Create nextjs project
npx create-next-app@latest
-
create api folder in app folder
-src -app -api -prompt -route.ts
-
install latest openai package
npm install openai@^4.0.0
- login to openai website and create api key
https://platform.openai.com/login
- create .env.local file in root and paste in the key
OPENAI_API_KEY= Your api key for openai
-
create openai-config.ts file
-src -openai-config.ts
-
install shadcnui for frontend
-
request api to get reply from chatgpt backend