发布日期:2026-08-13 | 分类:AI工具教程
NeMo Switchyard是英伟达2026年8月11日开源的智能模型路由库。根据任务类型自动将请求路由到最优模型,无需修改现有应用代码。内部测试显示成本降至全用Claude Opus 4.8的1/3。
pip install nemo-switchyard
# 或从源码安装
git clone https://github.com/NVIDIA/NeMo-Switchyard.git
cd NeMo-Switchyard
pip install -e .
# config.yaml
models:
- name: claude-opus
provider: anthropic
api_key: ${ANTHROPIC_API_KEY}
model: claude-opus-4-8
max_tokens: 8192
cost_per_1k: 0.075
- name: nemotron-lightning
provider: vllm
base_url: http://localhost:8000/v1
model: nvidia/Nemotron-3.5-Lightning
max_tokens: 4096
cost_per_1k: 0.002
- name: deepseek-flash
provider: openai
api_key: ${DEEPSEEK_API_KEY}
base_url: https://api.deepseek.com/v1
model: deepseek-v4-flash
max_tokens: 4096
cost_per_1k: 0.001
# routing.yaml
strategy: cost_optimized # 或 quality_first, balanced
rules:
- condition: "task_type == 'coding'"
model: nemotron-lightning
- condition: "task_type == 'reasoning' and complexity > 0.8"
model: claude-opus
- condition: "task_type == 'simple_qa'"
model: deepseek-flash
- default: true
model: nemotron-lightning
from nemo_switchyard import Router
router = Router(config="config.yaml", routing="routing.yaml")
# 启动OpenAI兼容API
router.serve(host="0.0.0.0", port=8080)
# 现有Agent只需将API地址改为 http://localhost:8080/v1
# 无需修改Agent代码,只需更换API地址
from openai import OpenAI
# 原来直接调用模型
# client = OpenAI(base_url="https://api.anthropic.com/v1", api_key=...)
# 现在通过Switchyard路由
client = OpenAI(base_url="http://localhost:8080/v1", api_key="switchyard")
response = client.chat.completions.create(
model="auto", # Switchyard自动路由
messages=[{"role": "user", "content": "帮我写一个REST API"}]
)
| 方案 | 月成本(100万请求) | 说明 |
|---|---|---|
| 全用Claude Opus | $75,000 | 质量最高但极贵 |
| Switchyard路由 | $25,000 | 简单任务用便宜模型,节省67% |
| 全用DeepSeek Flash | $1,000 | 最便宜但复杂任务质量不足 |
长时间运行的AI Agent应用、多模型混合调度、成本敏感的企业Agent部署。
NeMo Switchyard是英伟达2026年8月11日开源的智能模型路由库。根据任务类型自动将请求路由到最优模型,无需修改现有应用代码。内部测试显示成本降至全用Claude Opus 4.8的1/3。
Nemotron 3.5 Lightning部署教程