A modern Next.js application powered by the Vercel AI SDK with a beautiful chat interface featuring streaming responses. Built with React, TypeScript, and Tailwind CSS.
Before running this project, you'll need:
- An OpenAI API key - Get one from OpenAI Platform
- Node.js 18+ installed on your machine
- Clone and install dependencies:
npm install
# or
yarn install
# or
pnpm install- Set up your environment variables:
Create a .env.local file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here- Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev- Open your browser:
Navigate to http://localhost:3000 to see the chat interface.
src/app/page.tsx- Main chat interface using@ai-sdk/reactsrc/app/api/chat/route.ts- API route handling streaming chat responsessrc/app/layout.tsx- Root layout with metadata and fonts
Edit src/app/api/chat/route.ts to customize the AI's behavior:
const result = streamText({
model: openai('gpt-4.1'), // Change model
system: 'You are a helpful assistant.', // Modify system prompt
messages: convertToModelMessages(messages),
});This project uses Tailwind CSS. Modify styles in src/app/globals.css or component files.
- Vercel AI SDK Documentation - Learn about the AI SDK features and API
- Next.js Documentation - Learn about Next.js features and API
- OpenAI API Documentation - Learn about OpenAI's API
- BuildKit Documentation - Learn about BuildKit
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.