Skip to main content

Switchyard

Switchyard

Switchyard is a Rust proxy and library for LLM traffic. It routes requests across providers, translates between OpenAI and Anthropic APIs, records operational metrics, and provides typed, composable routing algorithms.

Why Switchyard? Point a coding agent such as Claude Code or Codex at an open-source model. Switchyard translates between the OpenAI Chat, Anthropic Messages, and OpenAI Responses formats, so the agent keeps speaking its native API while the request is served by vLLM, NVIDIA NIM, Ollama, or any OpenAI-compatible endpoint. The same proxy can spread traffic across several models for A/B benchmarking, apply signal-driven stage routing, or run a custom algorithm you write yourself.

Features

  • Protocol Translation: convert between OpenAI Chat, Anthropic Messages, and OpenAI Responses formats
  • Multi-Backend Routing: random routing, LLM-as-classifier routing, signal-driven stage-router, or your own algorithm
  • Operational Metrics: Prometheus metrics cover requests, errors, latency, tokens, and routing overhead

Quick Start

Choose the launcher path to run Claude Code, Codex CLI, or OpenClaw through Switchyard. Choose the server path to run Switchyard as a standalone proxy. Choose the library path to embed routing in your own Rust application.

Launcher Path

Install uv if it is not already available, then install the published Switchyard tool:

curl -LsSf https://astral.sh/uv/install.sh | sh
source "$HOME/.local/bin/env"
uv tool install --python 3.12 "nemo-switchyard[cli,server]"

The coding agent you launch must also be installed and on your PATH. This does not install the standalone switchyard-server binary; use the Server Path for that.

Set an OpenRouter key and launch against the packaged deployment:

export OPENROUTER_API_KEY="your-openrouter-key"  # pragma: allowlist secret
switchyard launch claude --model switchyard
switchyard launch codex --model switchyard
switchyard launch openclaw --model switchyard

To use your own native TOML deployment, pass its route ID and configuration:

switchyard launch claude --model my-route --config routes.toml

Server Path

Use this path to install and run the standalone Rust proxy. Install Rust with Cargo, then install the published binary:

cargo install --locked switchyard-server
switchyard-server --help

Cargo builds the release binary and installs it into ~/.cargo/bin by default.

Create routes.toml using the Getting Started guide, then validate it and start the server:

export OPENROUTER_API_KEY="your-openrouter-key"  # pragma: allowlist secret
switchyard-server --config routes.toml --dry-run
switchyard-server --config routes.toml --host 127.0.0.1 --port 4000

Verify the proxy in another terminal:

curl http://localhost:4000/health

For a complete configuration and a test request, follow Getting Started.

Library Path

switchyard-libsy embeds the routing algorithms in your own Rust application. It never calls a model itself: an algorithm decides which target to use and hands every model call back to you, so it drops into an existing proxy, gateway, or agent runtime without owning an HTTP stack. Pair it with switchyard-llm-client when you want the calls made for you.

[dependencies]
switchyard-libsy = { git = "https://github.com/NVIDIA-NeMo/Switchyard.git" }
switchyard-protocol = { git = "https://github.com/NVIDIA-NeMo/Switchyard.git" }

See Getting Started for setup and the algorithm list, or the switchyard-libsy crate docs.

Routing Strategies

Strategy Use it when Route type
LLM Classifier Request content should decide whether a turn needs the weak or strong tier. llm_classifier
Stage Router Signals already in the conversation, such as tool results and errors, should route most turns without an extra model call. stage_router
Escalation Router Every turn runs on the weak tier first, and a judge reads that answer to decide whether to send the same request to the strong tier. llm_classifier with mode = "escalation"
Random You need a fixed traffic split for A/B tests, baselines, or cost experiments. random

A passthrough route registers one target under one model ID with no routing decision. See the Routing Overview for the common route shape and self-hosted targets.

Architecture

flowchart LR
    clients["Clients"]
    switchyard["Switchyard<br/>routing · translation · fallback"]
    backends["Model backends"]

    clients -->|"OpenAI / Anthropic API"| switchyard
    switchyard -->|"provider-native format"| backends

Clients keep their native OpenAI or Anthropic API format. Switchyard picks a configured backend, forwards the request in that backend's own format, and translates the response back into the shape the client expects. The server accepts OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages. Each configured LLM client selects one upstream format.

Documentation

Community

License

Apache 2.0 License. Copyright NVIDIA Corporation.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nemo_switchyard-0.2.0.tar.gz (644.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nemo_switchyard-0.2.0-cp312-abi3-win_arm64.whl (7.6 MB view details)

Uploaded CPython 3.12+Windows ARM64

nemo_switchyard-0.2.0-cp312-abi3-win_amd64.whl (8.0 MB view details)

Uploaded CPython 3.12+Windows x86-64

nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.5 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

nemo_switchyard-0.2.0-cp312-abi3-macosx_11_0_arm64.whl (8.7 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

nemo_switchyard-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl (9.1 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file nemo_switchyard-0.2.0.tar.gz.

File metadata

  • Download URL: nemo_switchyard-0.2.0.tar.gz
  • Upload date:
  • Size: 644.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nemo_switchyard-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da76a59ea88563d12828a439ae51475b4ffef2f231a6f44bde47eb2eda5e3648
MD5 cff016747dc4faf6459361e435f07742
BLAKE2b-256 4b4ceb1a95385482bff5b7c3f7fd1eceac81dc23b307ed4516cf813bee70a70c

See more details on using hashes here.

File details

Details for the file nemo_switchyard-0.2.0-cp312-abi3-win_arm64.whl.

File metadata

  • Download URL: nemo_switchyard-0.2.0-cp312-abi3-win_arm64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.12+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nemo_switchyard-0.2.0-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 5ea9e65a751da540e7231d39f28ecf66af06e90ffccec36a05ca755875430c05
MD5 144f83bec58d3e74f7c267e2b4bd7c24
BLAKE2b-256 489674d281167bc1d0ab43b0f620dcd9e2d616612a83cd9f79ad58cb65778a7b

See more details on using hashes here.

File details

Details for the file nemo_switchyard-0.2.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: nemo_switchyard-0.2.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 8.0 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nemo_switchyard-0.2.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4641d19c6e7fd6d64d05bd8354f409e9f6a80a1472f7f0518a5ecc9c4347dbb1
MD5 20a4aa4143547878d6fbc1953a8f94b8
BLAKE2b-256 f2ff0b8768d5301738ba0cbee76040d9ff8b761a3e0d18588b713718ea9b0c17

See more details on using hashes here.

File details

Details for the file nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.5 MB
  • Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5691b5df6573ac21a2f2fb76050d957e99340536b0536a1c85278892a5808e76
MD5 878006254b84a24d73e1374c236debd6
BLAKE2b-256 7826032cbf416191affb9aba17bd23c45a1c71b492ae18243707c29823db3fc1

See more details on using hashes here.

File details

Details for the file nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 9.4 MB
  • Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nemo_switchyard-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 18ec104d044161a15979f562cfdc4a132543e882d051ed80d052219d78333378
MD5 f6f67fc870709b23b501ca00a140772e
BLAKE2b-256 df7aaff8f78e7bde4e570bb23e17708df3e3b136538be4f793fea8ef4599146e

See more details on using hashes here.

File details

Details for the file nemo_switchyard-0.2.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: nemo_switchyard-0.2.0-cp312-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 8.7 MB
  • Tags: CPython 3.12+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nemo_switchyard-0.2.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46afd9b3df91cdc91b8544572cf3ec7106a0d5c75a785ee0677f0e45ac2461f1
MD5 910e2887bbba60c2b8690db66aa6fe31
BLAKE2b-256 18ad04cf19af4f3c45a39b99790aaea2ee385f9ebda493f9ce044489ffb6de82

See more details on using hashes here.

File details

Details for the file nemo_switchyard-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: nemo_switchyard-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 9.1 MB
  • Tags: CPython 3.12+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nemo_switchyard-0.2.0-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 746d4307011a29e1b0a8126b3e615cea2d1c1493dbd0c5fcf36db4538c737203
MD5 f07c2858cf18130a9ec1b39fe0e4ce84
BLAKE2b-256 fe81c3d406fb179aab2e346e0adc439cd52555c2dea26d36a5fd5e27990a88fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page