How krishnnavarun/modelmux works
ModelMux is an inference-routing service: an application submits a prompt, the API checks the semantic cache, classifies misses, dispatches them through resilient provider adapters, and records the outcome. The README also documents operational metrics and a live dashboard. The graph preserves those product branches; unsampled configuration and storage wiring is shown only where the API excerpt or README supports it.
Main entry points: main.py Chat API · base.py Provider contract · __init__.py Provider registry · heuristic.py Complexity classifier
Components 21
Request handling
- Chat API
app/main.py - Semantic cache
app/cache.py
Classification and routing
- Complexity classifier
app/classifier/heuristic.py - Complexity signals
app/classifier/signals.py - Embedding classifier
app/classifier/embedding.py - Token counting
app/tokens.py - Tier selection
app/router.py
Provider dispatch
- Retry and circuits
app/resilience.py - Provider registry
app/providers/__init__.py - Provider contract
app/providers/base.py - Groq adapter
app/providers/groq.py - Google adapter
app/providers/google.py - Anthropic adapter
app/providers/anthropic.py - Mock adapter
app/providers/mock.py
State and operations
- Runtime configuration
app/config.py - Request records
app/db.py - Usage metrics
app/metrics.py - Rate limiting
app/ratelimit.py - Live dashboard
dashboard/index.html
Other components
- Application caller
- LLM providers
Connections 24
- Application caller → Chat API: submits prompt
README.md - Chat API → Semantic cache: checks cache
app/main.py - Chat API → Tier selection: selects tier
app/main.py - Tier selection → Complexity classifier: scores complexity
- Complexity classifier → Complexity signals: uses signals
app/classifier/heuristic.py - Complexity classifier → Embedding classifier: combines scoring
- Embedding classifier → Complexity signals: uses signals
app/classifier/embedding.py - Complexity signals → Token counting: counts tokens
app/classifier/signals.py - Chat API → Retry and circuits: dispatches request
app/main.py - Retry and circuits → Provider contract: calls adapter
app/resilience.py - Provider registry → Groq adapter: constructs
app/providers/__init__.py - Provider registry → Google adapter: constructs
app/providers/__init__.py - Provider registry → Anthropic adapter: constructs
app/providers/__init__.py - Provider registry → Mock adapter: constructs
app/providers/__init__.py - Groq adapter → Provider contract: implements
app/providers/groq.py - Google adapter → Provider contract: implements
app/providers/google.py - Anthropic adapter → Provider contract: implements
app/providers/anthropic.py - Mock adapter → Provider contract: implements
app/providers/__init__.py - Provider contract → LLM providers: calls model API
- Chat API → Request records: records requests
app/main.py - Chat API → Usage metrics: serves metrics
app/main.py - Chat API → Rate limiting: applies limits
app/main.py - Chat API → Runtime configuration: loads settings
app/main.py - Live dashboard → Chat API: displays live data
README.md