Intelligent multi-model task routing via OpenRouter
Friday Router automatically classifies task complexity and routes to the optimal GLM model. Simple tasks get fast responses, complex problems get deep thinking — all without manual selection.
graph TD
A["Task Input"] --> B["STAGE 1: Triage
GLM 4.7 Flash
Classify complexity"]
B -->|"simple"| C["GLM 4.7 Flash
Fast responses"]
B -->|"medium"| D["GLM 4
Balanced"]
B -->|"complex"| E["STAGE 2: Orchestrator
GLM 5.0"]
E -->|"configure"| C
E -->|"configure"| D
E -->|"configure"| F["STAGE 3: Sub-agent
GLM 5.0
Deep analysis"]
C --> G["Response + Metadata"]
D --> G
F --> G
style A fill:#6366f1,stroke:#4f46e5,color:#ffffff
style B fill:#10b981,stroke:#059669,color:#ffffff
style E fill:#f59e0b,stroke:#d97706,color:#ffffff
style F fill:#8b5cf6,stroke:#7c3aed,color:#ffffff
style G fill:#1a1a1a,stroke:#6366f1,color:#ffffff
style C fill:#1a1a1a,stroke:#10b981,color:#ffffff
style D fill:#1a1a1a,stroke:#f59e0b,color:#ffffff
Every task flows through three intelligent stages to ensure optimal model selection and response quality.
Each stage uses a specialized GLM model optimized for its role in the routing pipeline.
zhipu/glm-4-flash Ultra-fast classification, <1s responsezai/glm-5 Smart routing and configurationzhipu/glm-4-flash Quick responses, max 500 tokenszhipu/glm-4 Balanced performance, max 2000 tokenszai/glm-5 Maximum capability, max 4000 tokensFriday Router automatically categorizes tasks into three complexity levels, each with optimized model selection and token limits.
| Complexity | Model | Examples | Max Tokens | Typical Time |
|---|---|---|---|---|
| ⚡ Simple | glm-4-flash |
Definitions, basic questions, simple conversions, quick lookups, single-step operations | 500 | <1s |
| 🔶 Medium | glm-4 |
Explanations with examples, comparisons, summaries, code reviews, multi-step analysis | 2000 | 2-5s |
| 🟣 Complex | glm-5 |
Architecture design, implementation from scratch, complex refactoring, multi-component systems | 4000 | 5-15s |
Get started with Friday Router in minutes. Requires Node.js 18+ and an OpenRouter API key.
clawhub install friday-router
cd ~/.openclaw/workspace/skills
git clone https://github.com/your-org/friday-router.git
export OPENROUTER_API_KEY=sk-or-v1-your-key-here
Sign up at openrouter.ai to get your API key. OpenRouter provides unified access to multiple AI models including GLM.
Use Friday Router from the command line for quick tasks and testing.
node scripts/route.mjs "What is machine learning?"
node scripts/route.mjs "Explain React hooks" --context "frontend developer"
node scripts/route.mjs "Review this code" --file ./code.js
FRIDAY_LOG_LEVEL=debug node scripts/route.mjs "task"
Integrate Friday Router into your own applications and workflows.
import { routeTask } from './scripts/route.mjs';
const result = await routeTask({
task: "Build a REST API",
context: "Node.js backend",
files: ["./server.js"]
});
console.log(result);
{
response: "...", // The actual response
metadata: {
complexity: "complex",
model: "zai/glm-5",
tokens: { input: 150, output: 1200 },
time: 8423,
retries: 0,
routing_path: ["triage", "orchestrator", "agent"]
}
}
Customize Friday Router behavior by editing config.json.
{
"complexity_thresholds": {
"simple": {
"max_tokens": 500,
"keywords": ["define", "what is", "quick"],
"max_steps": 1
},
"medium": {
"max_tokens": 2000,
"keywords": ["explain", "compare", "review"],
"max_steps": 3
},
"complex": {
"max_tokens": 4000,
"keywords": ["design", "implement", "architecture"],
"max_steps": 10
}
},
"routing": {
"max_retries": 3,
"timeout_ms": 60000,
"fallback_model": "zhipu/glm-4-flash"
}
}
# Required
OPENROUTER_API_KEY=sk-or-v1-...
# Optional
FRIDAY_LOG_LEVEL=debug # Logging level
FRIDAY_TIMEOUT=30000 # Override timeout (ms)
See how Friday Router classifies and routes different types of tasks.
$ node scripts/route.mjs "Define API"
Response: "API stands for Application Programming Interface..."
Metadata: {
complexity: "simple",
model: "zhipu/glm-4-flash",
tokens: { input: 12, output: 45 },
time: 823
}
$ node scripts/route.mjs "Compare REST vs GraphQL"
Response: "REST and GraphQL are both API design approaches..."
Metadata: {
complexity: "medium",
model: "zhipu/glm-4",
tokens: { input: 18, output: 890 },
time: 3241
}
$ node scripts/route.mjs "Design a microservices architecture for e-commerce"
Response: "For an e-commerce microservices architecture..."
Metadata: {
complexity: "complex",
model: "zai/glm-5",
tokens: { input: 24, output: 2100 },
time: 8934
}
Friday Router includes robust error handling to ensure reliable responses.
Built-in optimizations ensure fast, efficient routing at scale.
Friday Router works seamlessly with other skills in the ghost malone ecosystem.
Planned improvements to make Friday Router even more powerful.
Start with simple tasks to test the routing. The triage stage learns from patterns, so the more you use it, the better it gets at classifying your specific use cases.