-
Install dependencies:
npm install
-
Set up environment variables:
- Create a
.env.localfile in the root directory. - Add your OpenAI API key:
OPEN_API_KEY=your_openai_api_key
- Create a
-
Run the development server:
npm run dev
-
Open your browser:
- Visit http://localhost:3000 to view the app.
app/page.js— Main page component. Edit this file to change the homepage UI.app/api/chat/route.js— API route for standard chat completions.app/api/chat-stream/route.js— API route for streaming chat completions (SSE).public/— Static assets (SVGs, icons, etc).globals.css— Global styles.
- The project uses
next/fontfor font optimization and loads Geist. - The API routes require a valid OpenAI API key set in your environment variables.
To learn more about Next.js and related technologies:
- Next.js Documentation — Features and API reference.
- Learn Next.js — Interactive tutorial.
- Next.js GitHub repository — Source code and community.
The easiest way to deploy your Next.js app is to use the Vercel Platform.
See Next.js deployment documentation for more details.