An intelligent routing system that automatically selects the optimal AI model and configuration for any given task using LLM-powered analysis.
The AI Model Router analyzes your prompts and automatically:
- Selects the best AI provider (OpenAI, Anthropic, Google)
- Chooses the optimal model for your specific task type
- Configures ideal parameters (temperature, thinking levels, reasoning effort)
- Applies specialized instructions tailored to your task category
Instead of manually deciding between GPT-4, Claude, or Gemini for each task, the router uses AI to make these decisions intelligently.
- Uses Gemini Flash 2.0 to analyze and categorize your prompts
- Automatically detects task types: coding, creative writing, tutoring, conversation
- Selects optimal model configurations based on task requirements
- OpenAI: GPT models with reasoning effort controls
- Anthropic: Claude models with temperature tuning
- Google: Gemini models with thinking budgets and temperature controls
- Temperature Control: Automatically adjusts creativity vs precision
- Thinking Levels: Configures reasoning depth for complex tasks
- Specialized Instructions: Applies task-specific system prompts
- CLI Tool: Interactive terminal interface for developers
- Web App: Modern streaming chat interface with real-time model selection display
- JSON-based configuration system
- Hot-reloadable settings
- Built-in backup system for configuration changes
- Easy to add new models and task categories
- Python 3.8+
- API keys for at least one provider (OpenAI, Anthropic, or Google)
-
Clone the repository
git clone <repository-url> cd Model_Router
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp env_template.txt .env # Edit .env and add your API keys -
run the web interface
python app.py # Open http://localhost:5000 in your browser
-
Router (
router.py)- LLM-powered prompt analysis
- Model and parameter selection logic
- Configuration validation
-
CLI Interface (
main.py)- Interactive terminal chat
- Conversation history management
- Multi-provider execution
-
Web Interface (
app.py)- Flask-based streaming API
- Real-time model selection display
- Configuration management UI
-
Configuration (
model_prompt.json)- Task category definitions
- Model mappings and parameters
- Specialized instruction templates
- Conversational AI: General chat with Gemini Flash Lite
- Creative Writing: Storytelling and poetry with Gemini Flash
- Professional Coding: Development tasks with Gemini Pro + thinking budget
- Tutoring: Educational content with OpenAI o4-mini + reasoning effort
Get your API keys from:
- OpenAI: https://platform.openai.com/api-keys
- Anthropic: https://console.anthropic.com/
- Google: https://makersuite.google.com/app/apikey
Add them to your .env file:
OPENAI_API_KEY=your_key_here
ANTHROPIC_API_KEY=your_key_here
GOOGLE_API_KEY=your_key_hereFor questions, suggestions, or issues, please open a GitHub issue or reach out to the maintainers.