Skip to content

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.

Rust
5.1 KB
Raw Blame

Switchyard

NVIDIA NeMo Switchyard

License: Apache-2.0 Latest GitHub release PyPI: nemo-switchyard crates.io: switchyard-libsy crates.io: switchyard-server GitHub contributors

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

  1. Configure the models your application can use and choose a routing algorithm.
  2. The algorithm examines the request or the agent's recent tool activity. Some algorithms call a model to judge the task.
  3. 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