A weekend experiment to build a lightweight AI control plane that:
- Classifies incoming prompts
- Routes them to a model
- Toggles reasoning mode
- Logs every decision
- Analyzes behavior
npm installCopy the example file:
cp .env.example .envThen edit .env and set your OpenRouter API key:
OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
CLASSIFIER_MODEL=openrouter/openai/gpt-5.2-chat
EXECUTION_MODEL_DEFAULT=openrouter/openai/gpt-5.2-chat.env file.
Start the CLI:
npm run devYou’ll be prompted to enter a prompt.
The system will:
- Classify it
- Show routing decision
- Execute via OpenRouter
- Log the decision in
logs/
To benchmark the router against the 15 categorized prompts:
tsx src/runTestSuite.ts(Optional) Add a script in package.json:
"test-suite": "tsx src/runTestSuite.ts"Then run:
npm run test-suiteThis will:
- Parse prompts from
test-suite.md - Classify each prompt
- Execute via the router
- Measure latency
- Compute overall and per-category accuracy
After running multiple prompts:
tsx src/analyzeLogs.tsThis prints:
- Total runs
- Average latency
- Category distribution
- Reasoning usage breakdown
src/
classifierPrompt.ts → Classification instructions
routingTable.ts → Static routing rules
openrouter.ts → OpenRouter API integration
logger.ts → JSONL logging
analyzeLogs.ts → Analytics script
index.ts → CLI entrypoint
test-suite.md → 15-prompt evaluation set
logs/ → Router decision logs
- ≥80% classification accuracy
- Measure reasoning usage
- Measure latency impact
- Evaluate subjective output quality