model-router
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseModel Router
模型路由器
Configure routing between LLM providers and models with fallback support.
配置LLM提供商与模型之间的路由,支持回退机制。
Features
功能特性
- config: Set up routing rules per task type
- list: Show available providers and models
- route: Route requests to appropriate model
- fallback: Configure fallback providers
- weights: Set model usage weights
- status: Check provider health
- config:按任务类型设置路由规则
- list:显示可用的提供商和模型
- route:将请求路由至合适的模型
- fallback:配置回退提供商
- weights:设置模型使用权重
- status:检查提供商健康状态
Usage
使用方法
bash
undefinedbash
undefinedList available providers
列出可用提供商
./scripts/model-router.js --command list
./scripts/model-router.js --command list
Configure routing
配置路由
./scripts/model-router.js --command config --task coding --provider anthropic --model claude-sonnet-4
./scripts/model-router.js --command config --task coding --provider anthropic --model claude-sonnet-4
Set fallback
设置回退
./scripts/model-router.js --command fallback --primary anthropic --fallback openai,groq
./scripts/model-router.js --command fallback --primary anthropic --fallback openai,groq
Check status
检查状态
./scripts/model-router.js --command status
./scripts/model-router.js --command status
Route a request
路由请求
./scripts/model-router.js --command route --task research --prompt "Explain quantum computing"
undefined./scripts/model-router.js --command route --task research --prompt "Explain quantum computing"
undefinedRouting Rules
路由规则
Routing can be based on:
- Task type (coding, research, creative, reasoning)
- Token count
- Model capability
- Provider availability
- Cost optimization
路由可基于以下维度:
- 任务类型(编码、研究、创意创作、推理)
- Token数量
- 模型能力
- 提供商可用性
- 成本优化
Examples
示例
| Task | Command |
|---|---|
| List providers | |
| Config coding | |
| Set fallback | |
| Check status | |
| Route request | |
| 任务 | 命令 |
|---|---|
| 列出提供商 | |
| 配置编码任务 | |
| 设置回退 | |
| 检查状态 | |
| 路由请求 | |
Notes
注意事项
- Supports major providers: OpenAI, Anthropic, Groq, etc.
- Automatic failover to fallback providers
- Cost and quality optimized routing
- Health checks on providers
- 支持主流提供商:OpenAI、Anthropic、Groq等
- 自动故障转移至回退提供商
- 基于成本与质量优化的路由
- 提供商健康状态检查