An intelligent router that automatically selects the best AI model for your requests. No more manually choosing between GPT, Claude, or other models - our system analyzes your message and routes it to the optimal model.
A smart traffic controller for AI requests that analyzes your message and selects the best model:
- Simple chat →
gpt-oss-20b(free and fast) - Coding tasks →
claude-sonnet-4(excellent for development) - Complex reasoning →
gpt-5-mini(advanced problem solving)
- Next.js 14 with App Router
- TypeScript for type safety
- Tailwind CSS for styling
- OpenRouter API for model access
- Custom logging system
- Clone the repository
git clone <your-repo>
cd nextjs-template- Install dependencies
npm install- Set up environment variables
cp .env.example .env.local
# Add your OPENROUTER_API_KEY- Start development server
npm run devThe routing logic is in src/app/api/chat/route.ts:
- User sends message → Frontend hits our API
- Router analyzes content → Uses AI to determine intent
- Model selection → Picks the optimal model based on the task
- Execution → Sends the request to the selected model
- Response → Returns both the model used and the answer
Simple but scalable design:
- Frontend: React with hooks, clean component structure
- Backend: Next.js API routes with proper error handling
- Routing Logic: AI-powered decision making
- State Management: Local state with React hooks
Want to add more models? Update the routing prompt in llmRouter(). The system is model-agnostic - as long as OpenRouter supports it, we can route to it.
- Routing: ~100ms (using gemini-2.5-flash-lite for decisions)
- Response: Depends on the selected model
- Fallback: Always defaults to gpt-oss-20b if something goes wrong
This is a side project that grew into something useful. Feel free to:
- Open issues for bugs
- Submit PRs for improvements
- Share ideas for enhancements
MIT License
Built in San Francisco with modern web technologies.