# How a Passthrough Route in Switchyard Registers a Single Target Model ID Without Making a Routing Decision

> Learn how Switchyard's passthrough route registers a single target model ID, bypassing routing decisions. Optimize your NLU pipeline by forwarding requests directly.

- Repository: [NVIDIA-NeMo/Switchyard](https://github.com/NVIDIA-NeMo/Switchyard)
- Tags: how-to-guide
- Published: 2026-09-13

---

**A passthrough route in Switchyard forwards every request to exactly one pre-registered model by configuring a single `target` in the route definition and selecting the first (and only) available model from the driver, bypassing all scoring and selection logic.**

The Switchyard inference router supports multiple routing algorithms, including a **passthrough** mode designed for scenarios requiring direct proxying without intelligent load balancing. This mode registers a solitary target under a specific model ID and returns it unconditionally, effectively eliminating routing decisions entirely. According to the NVIDIA-NeMo/Switchyard source code, the implementation relies on a simple configuration field and a deterministic algorithm that always selects the first available model from the driver's registry.

## Configuration: Defining the Single Target

In [`crates/switchyard-runner/src/config.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/switchyard-runner/src/config.rs), a passthrough route is declared in the TOML configuration with the `type = "passthrough"` field and a `target` parameter that references a globally defined target entry. For example:

```toml
[routes.passthrough]
id = "switchyard/passthrough"
type = "passthrough"
target = "weak"

```

The `target = "weak"` value refers to a corresponding entry under `[targets.weak]` which contains the concrete model ID, such as `id = "weak/model"`. This configuration binds the route to exactly one model without defining a fallback list or selection criteria. The configuration parser validates this structure during initialization, ensuring the `target` field resolves to a defined target name before the runner starts accepting requests.

## Algorithm Implementation: Selecting the First Model

The passthrough logic resides in [`crates/libsy/src/algorithms/passthrough.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/libsy/src/algorithms/passthrough.rs), where the `Passthrough` struct implements the `Algorithm` trait. The `route` method obtains the list of models matching the generic `Category::Any` from the driver, selects the first entry using `models.next()`, and returns it immediately (lines 22-33):

```rust
fn route(&self, request: &Request, models: &mut dyn Iterator<Item = Model>) -> Result<Model, Error> {
    models.next().ok_or(Error::NoModelsAvailable)
}

```

This implementation performs no scoring, capacity checks, or comparison logic. It simply extracts the first (and typically only) model from the iterator provided by the driver. As implemented in NVIDIA-NeMo/Switchyard, this guarantees that every request routed through this algorithm reaches the same target model ID without evaluating alternatives.

## Target Registration: How the Runner Discovers the Model

During initialization, the runner calls `routing_target_names()` on each algorithm to discover which targets a route expects. In [`crates/switchyard-runner/src/algorithm.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/switchyard-runner/src/algorithm.rs), the passthrough implementation returns the single target name supplied in the configuration (line 284):

```rust
fn routing_target_names(&self) -> Vec<String> {
    vec![self.target.clone()]
}

```

The runner then resolves this name against the `[targets]` section of the configuration to retrieve the concrete model ID. This resolution happens once at startup, registering the specific model ID (`weak/model` in the example) under the route's namespace. Because the algorithm explicitly returns only one target name, the routing table contains exactly one entry for this route, preventing any ambiguity or decision-making during request processing.

## Why No Routing Decision Occurs

A **routing decision** typically involves evaluating multiple candidate models against request criteria, capacity limits, or performance scores. The passthrough route eliminates this process by design:

- **Deterministic selection**: The algorithm always chooses the first model in the iterator, which corresponds to the single registered target.
- **No fallback logic**: Unlike weighted or round-robin algorithms, there is no secondary model to consult if the primary is unavailable.
- **Transparent proxying**: The route acts as a thin proxy, making it ideal for health checks, diagnostics, or situations where the caller has predetermined the target model.

This behavior is verified in the unit tests located at [`crates/libsy/src/algorithms/passthrough.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/libsy/src/algorithms/passthrough.rs) (lines 46-68), where a route configured with a single model ID (`testing/passthrough`) consistently returns responses from that exact model, confirming the absence of intermediate routing logic.

## Practical Implementation Examples

**Defining the configuration:**

```toml
[targets.weak]
id = "weak/model"
llm_client = "anthropic"

[routes.passthrough]
id = "switchyard/passthrough"
type = "passthrough"
target = "weak"

```

**Using the route from Rust:**

```rust
use switchyard_runner::Runner;
use switchyard_protocol::{Request, text_request};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize runner from TOML configuration
    let runner = Runner::from_toml_path("config.toml").await?;
    
    // Construct a request
    let request = Request {
        llm_request: text_request(Some("auto".into()), "Hello world!"),
        raw_request: None,
        metadata: None,
    };
    
    // Execute through the passthrough route
    let (model_id, response) = runner
        .run_route("switchyard/passthrough", request)
        .await?;
    
    assert_eq!(model_id, "weak/model");
    Ok(())
}

```

The `run_route` method in [`crates/switchyard-runner/src/runner.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/switchyard-runner/src/runner.rs) builds the routing table using the single target registered during initialization, ensuring the request flows directly to `weak/model` without intermediate routing calculations.

## Summary

- A passthrough route binds to exactly one target through the `target` configuration field in TOML.
- The `Passthrough` algorithm in [`passthrough.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/passthrough.rs) selects the first model from the driver’s iterator, implementing no selection logic.
- The `routing_target_names` method returns a vector containing only the configured target name, limiting the route to a single model ID.
- This architecture eliminates routing decisions entirely, making the route suitable for direct proxying, diagnostics, and health checks.
- The runner resolves the target name to a concrete model ID at startup, registering it permanently for the route’s lifetime.

## Frequently Asked Questions

### How do I configure a passthrough route to point to a specific model?

Define a target entry in your TOML configuration with a unique `id`, then reference that target name in the `routes.passthrough` section using the `target` field. The runner resolves this reference at startup and registers the corresponding model ID as the sole destination for that route.

### Does the passthrough algorithm support multiple targets or fallback models?

No. The passthrough algorithm is explicitly designed for single-target scenarios. The `routing_target_names` method returns exactly one name, and the `route` method selects only the first model from the driver. If you require fallback logic or load distribution across multiple models, use a different algorithm such as round-robin or least-loaded.

### What happens if the registered target model is unavailable?

Since the passthrough route makes no routing decisions, it does not implement automatic failover. If the single registered target becomes unavailable, the route will fail to return a model and typically return an error indicating no models are available. For high-availability requirements, configure health checks at the infrastructure level or switch to a multi-target routing algorithm.

### When should I use a passthrough route instead of other algorithms?

Use a passthrough route when you need Switchyard to act as a transparent proxy to a specific model, such as during integration testing, model-specific debugging, or when the upstream caller has already determined the target and you want to avoid routing overhead. It eliminates computational overhead from scoring or selection logic, providing predictable, deterministic request forwarding.