Evaluate Routing Locally
Use the standalone server to try routing configurations with your own model pool. It is for demos, evaluation, and personal use on single-user machines. It is not a supported production deployment path. To add routing to your gateway or application, use the libsy quickstart.
Install the server
You need Rust 1.96.1+, a native build toolchain, curl, and an OpenRouter API key. Install Rust using the official instructions and check platform requirements.
Install the released server:
For unreleased features, build from main. Keep your configuration and binary on compatible versions.
Configure your model pool
Create routes.toml:
This uses the same Auto preset as the first libsy example: Stage routing with efficient_first, a confidence threshold of 0.5, and no classifier call. The model pool also appears in our Terminal-Bench 2.1 results. This small Auto example is not the benchmark configuration; use the linked benchmark profiles to reproduce their settings.
To use your own pool:
Keep credentials in environment variables. For provider options, credential forwarding, and route types, see the TOML reference and model selection guide.
Run the server
Set OPENROUTER_API_KEY in your environment with access to the configured models. Then validate and run the configuration:
The standalone binary binds to 127.0.0.1 by default. For remote clients,
pass --host 0.0.0.0 explicitly and secure access to the server. The provided
Docker image and dev-server/switchyard.service set this option to preserve
network access. A later --host argument overrides the image’s default.
The dry run prints server OK: switchyard. It checks configuration and credential lookup, not whether the provider accepts the key.
In a second terminal, check local readiness:
The model listing includes switchyard. These local checks make no provider requests.
Verify routing is active
The next two requests call your providers and may incur charges. Start with a fresh server, or clear its counters before this sequence:
First, send a request without tool history:
The response header identifies the efficient model:
Next, save as escalate.json:
Send it:
The critical error forces the capable model:
Read the counters with jq installed:
After exactly these two successful completions, expect one call per model:
The decision counters show one fall_open choice and one override. Here, fall_open means the request had no usable signals and used the efficient-first default. override means a hard error forced the capable tier. Additional requests change the totals. Counters reset on server restart or POST /v1/stats/reset.
For per-request records, restart with --routing-log-file routing.jsonl. Each record includes the selected model and token usage. Decision reasons are reported by the stats endpoint. These checks confirm routing behavior, not task quality or savings.
With an unreleased build from main, GET /v1/routing/session-stats?session_id=... includes judge selections under outcomes[].judgments, with their targets, categories and available score evidence. Later Stage decisions leave these selections intact.
Forwarded response headers
The server forwards these upstream response headers to the caller, on success and on upstream errors:
baggage,traceparent,tracestateopenai-processing-msrequest-id,x-request-idretry-after,retry-after-ms,x-should-retryx-litellm-response-cost- any header that starts with
anthropic-ratelimit-,x-ratelimit-, orx-upstream-
On an upstream error, the headers come from the last upstream attempt. Callers can use
retry-after to decide how long to wait before they retry.
Switchyard’s own headers, such as x-model-router-selected-model, always win over an
upstream header with the same name.
Compare configurations
- Benchmark results link to model pools, results, and runnable profiles. For Terminal-Bench 2.1, the escalation profile includes its judge and reasoning settings. Its comments explain the endpoint differences from the measured runs.
- Benchmark setup explains how to compare routing against single-model baselines on the same tasks.
- Tuning explains how to define an objective, compare candidate configurations on calibration tasks, and validate the selected one on held-out tasks.
- Routing overview explains Auto, Task, Execution, and Composite. A TOML file can expose multiple routes through different route IDs.
- Server reference covers configuration, TLS, logging, and metrics.
Troubleshooting
Stop the server with Ctrl+C when finished.