model-router

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Model 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
undefined
bash
undefined

List 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"
undefined

Routing Rules

路由规则

Routing can be based on:
  • Task type (coding, research, creative, reasoning)
  • Token count
  • Model capability
  • Provider availability
  • Cost optimization
路由可基于以下维度:
  • 任务类型(编码、研究、创意创作、推理)
  • Token数量
  • 模型能力
  • 提供商可用性
  • 成本优化

Examples

示例

TaskCommand
List providers
model-router.js --command list
Config coding
model-router.js --config --task coding --provider anthropic --model opus
Set fallback
model-router.js --fallback --provider anthropic --fallback openai,groq
Check status
model-router.js --status
Route request
model-router.js --route --task summarize --file article.txt
任务命令
列出提供商
model-router.js --command list
配置编码任务
model-router.js --config --task coding --provider anthropic --model opus
设置回退
model-router.js --fallback --provider anthropic --fallback openai,groq
检查状态
model-router.js --status
路由请求
model-router.js --route --task summarize --file article.txt

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等
  • 自动故障转移至回退提供商
  • 基于成本与质量优化的路由
  • 提供商健康状态检查