Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.
NVIDIA NeMo Switchyard
Switchyard is an open-source library that helps an AI agent choose which model handles each request. It combines efficient models with more capable models so you can balance task success, cost, and latency on your workload.
Use Switchyard through a gateway integration, try it with a local proxy, or embed it in your own harness. You choose the model pool. Switchyard supplies the routing decision. Your gateway or application owns the surrounding service.
How it works
- Configure the models your application can use and choose a routing algorithm.
- The algorithm examines the request or the agent's recent tool activity. Some algorithms call a model to judge the task.
- Your gateway or application sends the request to the selected model. Routing can change as the agent continues its work.
Evaluate the complete agent, model pool, and routing configuration against your single-model baseline. A cheaper model call does not guarantee a cheaper successfully completed task.
Embed the library in your harness
Refer to the embedding example.
Routing algorithms
Start with Auto. Choose Task, Execution, or Composite when you need more control. These names describe routing choices.
| Choice | How it chooses |
|---|---|
| Auto | Uses the current default: Execution (Stage), efficient-first, with a confidence threshold of 0.5 and no classifier call. |
| Task | A model judges whether the efficient model can handle the task. |
| Execution | Uses recent tool activity and outcome signals to choose a model as the agent runs. |
| Composite | Combines Task and Execution: a classifier sets the default model tier when execution signals are uncertain. |
The routing overview lists all strategies, including the Plan/Execute configuration for Stage, escalation, advisor, sub-agent, and random.
Prefill routing is designed for fast, efficient model selection using a model's prefill activations and a classifier trained on your own evaluation data.
Evaluation and reference
Compare benchmark results and configs for Terminal-Bench 2.1 and DeepSWE. For latency and routing overhead testing, see Soak Testing.
Further reading
- Benchmark setup and profiles: run your own baseline and routing comparisons.
- Mechanics of Libsy: steps, model calls, and routing outcomes.
- TOML schema: configuration fields and defaults.
- Rust crate reference: core and optional integration crates.
- Installation: package and platform requirements.