A modern, extensible chat interface for testing and comparing different AI language models.
- 🤖 Support for multiple AI models (GPT-4, Claude, Gemini)
- 💬 Real-time streaming responses
- 🎨 Beautiful UI with dark/light theme support
- ⚙️ Customizable model parameters
- 📝 Markdown rendering with syntax highlighting
- 💾 Conversation history management
- 📊 Token usage tracking
- 🔐 Secure API key management
- Node.js 18+ and npm
- API keys for the AI services you want to use
- Clone the repository:
git clone <your-repo-url>
cd ai-chat-playground
- Install dependencies:
npm install
- Set up environment variables:
cp .env.local.example .env.local
Edit .env.local
and add your API keys:
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
GOOGLE_API_KEY=your_google_key
- Run the development server:
npm run dev
- Open http://localhost:3000 in your browser
src/
├── app/ # Next.js app router
├── components/ # React components
│ ├── ui/ # Reusable UI components
│ └── ... # Feature components
├── lib/ # Utility functions
├── store/ # Zustand state management
└── types/ # TypeScript type definitions
To connect to real AI APIs, implement the API routes in /app/api/chat/route.ts
:
// Example implementation
import { OpenAI } from 'openai';
export async function POST(req: Request) {
const { message, model } = await req.json();
// Add your API logic here
const response = await openai.chat.completions.create({
model: model,
messages: [{ role: 'user', content: message }],
stream: true,
});
return new Response(response);
}
- Update the model list in
src/components/sidebar.tsx
- Add API integration in
/app/api/chat/route.ts
- Update the store if needed in
src/store/chat-store.ts
The project uses Tailwind CSS with a custom theme. Modify the theme in:
tailwind.config.ts
- Tailwind configurationsrc/app/globals.css
- Global styles and CSS variables
npm run build
vercel deploy
Build the production version:
npm run build
npm start
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
For issues and questions, please open an issue on GitHub.