> This page is for version Latest (v0.4.0) (default).
> For other versions, use one of these documentation indexes:
> - Latest (v0.4.0) (default): https://docs.nvidia.com/nemo/switchyard/latest/llms.txt
> - Dev: https://docs.nvidia.com/nemo/switchyard/dev/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/switchyard/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/switchyard/_mcp/server.

# Use Switchyard with NeMo Relay

The [Switchyard native plugin](https://github.com/NVIDIA-NeMo/Switchyard/blob/v0.4.0/crates/switchyard-nemo-relay-plugin/README.md)
loads Switchyard into an existing
[NeMo Relay runtime](https://docs.nvidia.com/nemo/relay/about-nemo-relay/overview)
deployment through Relay's
[native dynamic plugin system](https://docs.nvidia.com/nemo/relay/build-plugins/native/about).

## Upstream Error Compatibility \[#upstream-error-compatibility]

Relay 0.8.x and 0.9.0 have a native-plugin error propagation issue. Enabling the
Switchyard plugin can change an upstream 401 or 403 into a generic 400 for a
non-streaming request. A streaming request can receive HTTP 200 followed by an
aborted body. This is not a successful response or an authentication bypass.

This also affects **unmanaged models**: requested model names that do not match
a configured Switchyard route. For example, if the route is `switchyard/core`
and its target is `azure/openai/gpt-5.5`, requesting the target name directly
still delegates the request to Relay.

This plugin build uses `nemo-relay-plugin` 0.10.1 and requires Relay
`>=0.10.1, <1.0.0`. Relay 0.10 changed the native callback layout; 0.10.1 adds
the HTTP-error status handling used by this build. If you use an older plugin
build on Relay 0.8.x or 0.9.0, send unmanaged traffic through a separate Relay
instance with the plugin disabled. Upgrading Switchyard alone does not upgrade
the Relay host.

For managed routes, known upstream HTTP errors retain their status through
Relay's HTTP-error API. The client receives the generic message
`Switchyard route execution failed`; provider error bodies remain private.
Failures without a known HTTP error status keep Relay's existing error handling.

This preserves the HTTP status for buffered responses. Relay's streaming path
can send HTTP 200 before route execution finishes, so later failures cannot
change that status and retain the existing stream-error behavior.

## Why Use Switchyard with NeMo Relay? \[#why-use-switchyard-with-nemo-relay]

Switchyard's routing algorithms select a model for each LLM request or step in
an agent trajectory, balancing cost and performance. The NeMo Relay integration
makes those algorithms available to coding agent harnesses supported by Relay.
The integration is not tied to one routing algorithm. It supports passthrough,
random, Stage, composite, advisor, and LLM classifier routes, including
capability, escalation, and custom modes.

The plugin reports the selected and served models, fallback use, routing
latency, and token use through Relay telemetry. Use it to answer:

* How often did the lower-cost model handle the work?
* How often did Switchyard fall back to another model?
* How much time and token use did routing add?
* Did the routed workload cost less than using one model for every request?

The plugin runs inside Relay, so the agent does not need to change and
Switchyard does not need to run as a separate service.

Requests for models that Switchyard does not manage are passed to Relay.
See the [upstream error compatibility note](#upstream-error-compatibility) before
using older Relay versions.

Routing does not require Relay. You can instead run the
[standalone server](/nemo/switchyard/local-demo/run-the-reference-server) or embed
[`switchyard-libsy`](https://github.com/NVIDIA-NeMo/Switchyard/blob/v0.4.0/crates/libsy/README.md) directly.

### Measure the Cost of Routing \[#measure-the-cost-of-routing]

A routed request can spend tokens choosing a model and generating the answer.
Some routes call a judge or classifier first. The selected model, or a fallback,
then answers the request.

Relay records the request and answer seen by the agent. It can record a
provider-reported cost or estimate one when model pricing is configured.
Switchyard separately records model calls, available token usage and timing,
fallbacks, and failures.

The integration does not calculate a combined cost or savings figure. Relay can
price the answer returned to the agent, while Switchyard reports internal
routing usage separately. To estimate the observed cost for a workload, use:

```text
Relay answer cost + cost of Switchyard tokens where call_role = "routing"
```

Apply the price of each `target_model` to those routing tokens. Do not add
`call_role = "answer"` again because Relay already counted that answer. Do not
sum every `token_type`; `total` is a rollup, and cache or reasoning values may
already be included in broader counts.

Relay does not copy request identity into exported metric attributes. Use this
calculation for a workload or time window, not to reconcile one trace.

Relay does not include a model-price catalog. Follow its
[model-pricing guide](https://docs.nvidia.com/nemo/relay/configure-plugins/model-pricing)
to supply and validate model rates. Run the same representative workload once
with a fixed model and once with routing. Compare cost, latency, fallback rate,
and task success. Missing usage, failed attempts, internal HTTP retries, and
incomplete streams can leave some cost unknown. An absent value means unknown,
not zero.

## How Requests Flow \[#how-requests-flow]

Relay loads the plugin into its own process. For each supported model request,
the plugin checks whether the requested model matches a configured Switchyard
route. Matching requests go through Switchyard. Other requests are left
unchanged by Switchyard and passed to the next Relay handler. The plugin uses
Relay's
[execution intercepts](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/middleware#execution-intercepts)
for non-streaming requests and
[stream execution intercepts](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/middleware#stream-execution-intercepts)
for streaming requests.

```mermaid
flowchart TB
    caller["Agent or SDK"]

    subgraph relay_process["NeMo Relay process"]
        relay["Relay LLM execution"]
        relay --> match{"Model matches a<br />Switchyard route ID?"}
        match -->|"No"| next["Next Relay handler"]
        match -->|"Yes"| plugin["Native Switchyard plugin<br />decode, route, translate, and call"]
        next --> relay_out
        plugin -.->|"Routing observations"| telemetry["Relay marks and metrics"]
        plugin -->|"Translated output"| relay_out["Relay returns response or stream"]
    end

    target["Configured model provider"]
    caller --> relay
    plugin <-->|"Target call"| target
```

For a matching request, Switchyard performs model selection, provider calls,
retries, and fallback itself. Model calls used to make a routing decision, as
well as calls to the selected or fallback answer model, do not run through
Relay's LLM middleware again. This avoids treating a router's judge call or
fallback attempt as another application request.

Relay records the
[LLM call](https://docs.nvidia.com/nemo/relay/instrument-applications/instrument-llm-call#integration-pattern)
made by the application. Switchyard reports its internal routing work through
Relay
[marks](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/events#mark)
and metrics.

| Owner          | Responsibilities                                                                                             |
| -------------- | ------------------------------------------------------------------------------------------------------------ |
| Relay          | Receives the caller's request, runs Relay middleware, returns the response or stream, and exports telemetry. |
| Switchyard     | Chooses a target, translates formats, calls the provider, and handles configured retries and fallback.       |
| Model provider | Runs the model and returns its response, stream, and available usage.                                        |

For more detail, see Relay's
[managed execution pipeline](https://docs.nvidia.com/nemo/relay/about-nemo-relay/architecture#managed-execution-pipeline)
and
[plugin delivery models](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/plugins#plugin-delivery-models).

## Set Up the Plugin \[#set-up-the-plugin]

For Switchyard `0.3.0`, select a matching published `switchyard-plugin` bundle
from the
[NeMo Relay Plugins releases](https://github.com/NVIDIA/NeMo-Relay-Plugins/releases).
Confirm its Switchyard source commit in the release metadata. Plugin versions
are managed separately and can match the Switchyard version. The bundle
includes the native library, completed manifest, schema, and license notices;
no separate plugin crate installation is needed.

The repository currently requires NVIDIA GitHub repository access and
organization SSO/SAML authorization where required. An HTTP 404 can indicate
missing access. A Switchyard release does not guarantee that a matching plugin
bundle has been published.

Follow the
[bundle installation steps](https://github.com/NVIDIA-NeMo/Switchyard/blob/v0.4.0/crates/switchyard-nemo-relay-plugin/README.md#install-a-released-bundle)
to download the archive and sidecars, verify the checksum, and extract the
bundle. If a matching published bundle is unavailable or you need a custom
build, follow
[Build from source](https://github.com/NVIDIA-NeMo/Switchyard/blob/v0.4.0/crates/switchyard-nemo-relay-plugin/README.md#build-from-source).
Then register the manifest, configure the deployment and trust policy, enable
the plugin, and restart Relay. Relay documents how to
[add and enable a discoverable plugin](https://docs.nvidia.com/nemo/relay/configure-plugins/discoverable-plugins#add-and-enable-a-plugin)
and how it
[validates the package before loading code](https://docs.nvidia.com/nemo/relay/configure-plugins/discoverable-plugins#validate-before-loading-code).

> **Note**
>
> **Relay compatibility**
>
> The plugin requires `relay = ">=0.10.1, <1.0.0"` and native plugin API `1`.
> The packaged
> [`relay-plugin.toml`](https://github.com/NVIDIA-NeMo/Switchyard/blob/v0.4.0/crates/switchyard-nemo-relay-plugin/relay-plugin.toml)
> is the source of truth.

Configure exactly one Switchyard deployment source: either
`switchyard_config_path`, which points to the TOML used by `switchyard-server`,
or an inline version-1 deployment under `switchyard_config`. Both use the
[Switchyard TOML schema](/nemo/switchyard/reference/runner-configuration-toml).

The plugin reuses the deployment's routes, targets, and LLM clients. It does not
use Switchyard's `fallback_client` for an unmatched model. Relay's next handler
decides what happens to that request.

The `id` of each configured Switchyard route becomes a model name that callers
can send through Relay. No additional Relay route table is required for those
model names.

## Request Handling \[#request-handling]

The plugin handles these Relay LLM calls:

* OpenAI Chat Completions (`openai.chat_completions`)
* OpenAI Responses (`openai.responses`)
* Anthropic Messages (`anthropic.messages`)

Only requests whose `model` is a string matching a Switchyard route ID are
routed. Other call types, missing or non-string model values, and unconfigured
model names are left unchanged by Switchyard and passed to Relay's next handler.

The caller and selected target may use different supported API formats:
`openai_chat`, `openai_responses`, or `anthropic_messages`. Switchyard translates
the request into the selected target's configured format and returns buffered
or streaming responses in the caller's original format. With server-owned
credentials, one route targeting an `openai_chat` client can serve all three
caller formats. Separate targets and routes are not required solely for format
translation.

The native Relay plugin rejects routes that use `forward_auth = true` during
configuration validation and activation. This includes routing-model calls and
alternate targets. Relay does not provide caller credentials to the plugin's
provider calls. Secure forwarding support is tracked in
[NeMo Relay #1108](https://github.com/NVIDIA/NeMo-Relay/issues/1108).

For deployment-owned credentials, remove `forward_auth` or set it to `false`
and configure `api_key_env` on each authenticated client. The two options cannot
be enabled together. If each caller must use its own provider credential, use
standalone `switchyard-server`. Standalone forwarding requires the caller and
target to use the same credential family: OpenAI-compatible (Chat Completions
and Responses) or Anthropic (Messages). A route may mix both families when all
of its forwarding clients use the same scheme, host, and port, such as one LLM
gateway; such a route serves Chat Completions and Responses callers.

Support for provider-specific fields depends on the source and target formats.
Test any fields that your application relies on before deploying a translated
route. The [native-plugin README](https://github.com/NVIDIA-NeMo/Switchyard/blob/v0.4.0/crates/switchyard-nemo-relay-plugin/README.md#request-handling)
describes the same format and credential rules.

### Header Forwarding \[#header-forwarding]

Caller headers are forwarded upstream except credentials and headers owned by
the HTTP client, such as connection and content headers. Authentication and
configured extra headers follow the selected client's settings in the
[TOML schema](/nemo/switchyard/reference/runner-configuration-toml).

### Streaming \[#streaming]

For streaming requests, Switchyard returns a translated stream that Relay
consumes lazily. Relay drives delivery and cancellation and records when the
stream starts and ends. Switchyard continues to translate chunks and record
late usage or errors as Relay consumes them.

* Initial routing marks are available when the stream opens.
* An answer-call result of `ok` means the provider opened the stream. It does
  not guarantee that the full stream completed.
* For a streamed upstream response, answer token metrics appear
  only if the provider reports usage and the stream reaches its final event. A
  canceled or dropped stream may have no answer-token metrics.
* Later provider failures can emit `switchyard.routing.error`. Some failures
  before routing or while encoding Relay output have no Switchyard mark, so the
  marks are not a complete request-failure log.
* If Relay rejects a telemetry event, the plugin writes the error to standard
  error and still returns the model response.

## State and Identity \[#state-and-identity]

The plugin keeps request and response data in memory only while handling the
call. For a stream, that data remains until the stream finishes or the caller
drops it. The plugin does not store these payloads on disk.

The plugin creates one Switchyard runner when Relay activates it and shares the
runner across requests until the plugin is deactivated. Some routing algorithms
keep in-memory state there, such as session affinity or an escalation decision.
State behavior and expiry depend on the algorithm. The state is not shared
between Relay processes and is lost when a process restarts. See Relay's
documentation on
[plugin ownership](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/plugins#ownership-and-scope)
and
[runtime state](https://docs.nvidia.com/nemo/relay/about-nemo-relay/architecture#where-runtime-state-lives).

The plugin adds these fields to each routing mark, including metric marks.
Missing values are `null`:

* `session_id`
* `agent_id`
* `parent_agent_id`
* `task_id`
* `turn_id`
* `correlation_id`

Subscribers and log or trace exporters can read them, but Relay does not copy
them into exported metric attributes.

These values come from request headers rather than Relay's active scope. Relay's
[session and subagent headers](https://docs.nvidia.com/nemo/relay/nemo-relay-cli/basic-usage#runtime-mapping)
can populate them for correlation. They do not by themselves mark a request as
delegated work for Switchyard's
[`subagents` router](/nemo/switchyard/routing/algorithms/sub-agent-aware-routing). For algorithms
that keep per-session state, reuse a stable ID across turns. The plugin accepts
`x-nemo-relay-session-id`; `x-switchyard-session-id` overrides it. If neither
provides a value, the Switchyard session ID remains unset.

## Routing Telemetry \[#routing-telemetry]

Relay records one outer LLM lifecycle for the request made by the agent.
Switchyard also reports internal client-call scopes, routing marks, and metrics.
Existing Relay
[subscribers](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/subscribers#how-subscribers-relate-to-events)
can receive these records, but each output format presents them differently.

### ATIF and OpenTelemetry Show Different Views \[#atif-and-opentelemetry-show-different-views]

| Output                                        | What the current integration shows                                                                                                                                                                                                                                                                               |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ATIF                                          | Relay's trajectory projection. With Relay 0.11.1, internal Switchyard LLM scopes can become additional steps and contribute usage to `final_metrics`. The answer can appear in both an internal scope and the outer request. Relay-managed ATIF files may also retain raw records under `extra.observed_events`. |
| OpenTelemetry traces, including OpenInference | Relay's outer LLM span, nested `libsy.client_call`, `libsy.upstream_attempt`, and `libsy.decision_client_call` duration scopes, plus eligible routing marks.                                                                                                                                                     |
| OpenTelemetry metrics                         | Switchyard request, routing-call, latency, token, and failure measurements. Combine the reported routing usage with Relay's answer cost to estimate the observed routed cost.                                                                                                                                    |
| OTLP logs                                     | Non-metric Switchyard marks that meet the configured severity threshold.                                                                                                                                                                                                                                         |

ATIF projection is controlled by the Relay host version. Do not treat
`final_metrics` as answer-only usage or deduplicated provider consumption. Inspect
the outer response usage and individual call scopes before calculating totals;
repeated usage in an export does not imply additional provider requests or charges.

The plugin captures existing Switchyard spans. Each routing or answer LLM
call becomes a `libsy.client_call` scope. Physical HTTP attempts and retries
become `libsy.upstream_attempt` child scopes. Buffered calls close with the response;
streaming calls close when the stream finishes, fails, or is dropped. Typed
decision calls become `libsy.decision_client_call` scopes. The
projection contains allowlisted routing metadata by default. Optional
[routing payload capture](#inspect-classifier-and-judge-payloads) adds the final
classifier/judge request and successful buffered response.

`switchyard.call_phase` records when Switchyard issued a client call:
`routing` while the algorithm was still deciding, or `completion` after a
target was selected. A routing-phase response can later become the final
answer, so this is intentionally different from the `call_role` on
`switchyard.routing.llm_call` marks, which records the post-outcome
classification as `routing` or `answer`.

| Switchyard signal                               | Relay record                         | Parent                         | Lifetime                                                                                        |
| ----------------------------------------------- | ------------------------------------ | ------------------------------ | ----------------------------------------------------------------------------------------------- |
| Routing or answer model call                    | `libsy.client_call` scope            | Relay's managed request scope  | Starts with the Switchyard call and closes with the buffered response or terminal stream event. |
| Physical provider request or retry              | `libsy.upstream_attempt` scope       | Its `libsy.client_call` scope  | Starts before the HTTP attempt and closes on response, error, or cancellation.                  |
| System One or OpenAI Decisions call             | `libsy.decision_client_call` scope   | Relay's managed request scope  | Starts with the decision call and closes on response, error, or cancellation.                   |
| Routing request, decision, overhead, or failure | Existing `switchyard.routing.*` mark | Active Relay scope at emission | Point-in-time mark using the existing outcome fields.                                           |

### Inspect Classifier and Judge Payloads \[#inspect-classifier-and-judge-payloads]

Routing payload capture is available through the native NeMo Relay plugin and
is disabled by default. It is not a standalone Switchyard configuration option.
Use it to inspect the final classifier/judge request, including its system
prompt, task context, output schema, resolved model, and target body settings,
plus its successful buffered response. This helps distinguish a poor verdict
from missing task context. System One and OpenAI Decisions requests and
successful buffered responses are supported too.

Add these options to the existing `plugins.dynamic.config` table in your Relay
`plugins.toml`, then restart the host:

```toml
[plugins.dynamic.config]
switchyard_config_path = "/etc/switchyard/routes.toml"
capture_routing_payloads = true
```

`max_routing_payload_bytes` defaults to 262144 encoded bytes (256 KiB) per
request or response body, per attempt, before sanitization. It must be positive.
Larger bodies are omitted entirely, not retained as a prefix:

```json
{"body": null, "truncated": true}
```

The full request still reaches the model. The capture limit does not change
which messages the classifier receives; see
[classifier context selection](/nemo/switchyard/routing/algorithms/task-llm-classifier#tuning-options).

For a debugging session that needs larger bodies, set an override in the same
`plugins.dynamic.config` table and restart the host. For example, allow up to
2 MiB per body:

```toml
max_routing_payload_bytes = 2097152
```

This is a per-body limit, not a total memory budget. Larger limits increase
memory use and export volume, especially with concurrent calls or retries.
Exporters and their backends can impose smaller limits. After debugging, set
`capture_routing_payloads = false` and restart the host; remove the size override
to restore the default for later sessions.

Within the routed request's trace:

1. Find the `libsy.client_call` scope for the classifier/judge model, with
   `switchyard.call_phase = routing`.
2. Open its `libsy.upstream_attempt` child. The request is the scope input;
   its successful buffered response is the scope output. Retries have separate
   attempt scopes. Retained payloads have a JSON string in `body` and
   `truncated = false`.
3. Inspect the `switchyard.routing.decision` mark on the same routed request
   for the selected and served model. The judge response contains the returned
   verdict; the decision mark records what Switchyard did with it.

For System One or OpenAI Decisions, inspect the input and output on
`libsy.decision_client_call` directly. The captured request uses the provider's
final `state` or `input` field and encoded questions.

For an [ATOF export](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/atof),
the request appears directly in the attempt start event's `data`, and the
response in the matching end event's `data`. Their `uuid` values match;
`parent_uuid` identifies the classifier call. For example, inspect complete
captured requests with:

```bash
jq 'select((.name == "libsy.upstream_attempt" or .name == "libsy.decision_client_call") and .scope_category == "start" and .data.body != null) | .data.body | fromjson' events.jsonl
```

Find omitted request or response bodies with:

```bash
jq 'select((.name == "libsy.upstream_attempt" or .name == "libsy.decision_client_call") and .data.truncated == true) | {uuid, scope_category}' events.jsonl
```

Capture follows routing-phase HTTP calls, which include LLM classifier/judge
calls, typed decision-client calls, and other model calls used while deciding a
route. It excludes completion-phase payloads, streamed response bodies, and
HTTP error bodies. This option belongs to the
native Relay plugin; enabling standalone Switchyard TRACE logging does not
enable payload capture.

Payloads can contain sensitive task data. To mask configured provider keys,
the plugin decodes the captured JSON, redacts it, and serializes the copy again.
JSON strings, such as classifier content and tool arguments, are decoded too.
Traversal is limited to 64 levels, including JSON encoded inside strings.
Whitespace and escape spellings may change. Ordinary bracketed prose is kept
and redacted as text. If JSON-looking text cannot be decoded and contains
backslash escapes, or the depth limit is exceeded, the body is omitted
(`body: null`). An invalid outer JSON body is also omitted when keys are configured.
Captured data passes through Relay's normal event
sanitizers and configured exporters. Personal data and other secrets require
suitable sanitizers; see Relay's
[PII redaction options](https://docs.nvidia.com/nemo/relay/configure-plugins/pii-redaction/about).

### How Routing Appears in Traces \[#how-routing-appears-in-traces]

In Relay's
[full and OpenInference trace projections](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/opentelemetry#trace-projections),
[`mark_projection`](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/opentelemetry#trace-endpoint-fields)
controls how marks appear. With `inherit` or `event`, a routing mark is an event
on its parent span while that span is open. Otherwise, Relay emits it as a
zero-duration span and retains its parent when possible. With `tool`, routing
marks are always visible zero-duration spans. The plugin does not nest these
marks under the LLM span. The
[`gen_ai` projection](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/opentelemetry#genai-projection)
omits marks. With `mark_projection = "tool"`, the trace has this shape:

```mermaid
flowchart LR
    agent["Relay agent scope"]
    llm["LLM call"]
    call["libsy.client_call<br />routing or completion"]
    attempt["libsy.upstream_attempt<br />one per HTTP attempt"]
    decision_call["libsy.decision_client_call<br />typed decision"]
    requested["mark:switchyard.routing.requested<br />zero duration"]
    calls["mark:switchyard.routing.llm_call<br />zero duration"]
    overhead["mark:switchyard.routing.overhead<br />zero duration"]
    decision["mark:switchyard.routing.decision<br />zero duration"]
    error["mark:switchyard.routing.error<br />zero duration"]
    agent --> llm
    llm --> call
    call --> attempt
    llm --> decision_call
    agent --> requested
    agent --> calls
    agent --> overhead
    agent --> decision
    agent -.->|"Failure"| error
```

When the LLM call has an agent scope as its parent, the marks use that same scope
and appear beside the call. Without an agent scope, a backend can display the
LLM span and marks as separate roots. The metadata field
`parent_agent_id` is a correlation value; it does not set Relay trace
parentage. See Relay's
[scope hierarchy](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/scopes#scope-hierarchy-and-ownership)
for the parentage rules.

### Mark Contract \[#mark-contract]

Dashboards and subscribers can use `data_schema` to identify the payload
contract. Each non-metric mark uses the mark name as its schema name and version
`1`. Consumers should accept additional fields and values within a version.
Removing or renaming a field, changing its type, or changing its meaning
requires a new version. Relay's
[event envelope](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/events#fields-common-to-every-event)
describes the surrounding event envelope.

| Mark                           | Severity | Data                                                                                                                                                                                      |
| ------------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `switchyard.routing.requested` | Info     | Routing `algorithm` for a managed request.                                                                                                                                                |
| `switchyard.routing.llm_call`  | Debug    | `call_index`, `selected_model`, `call_role` (`routing` or `answer`), `outcome`, and `latency_ms` for each observed model call.                                                            |
| `switchyard.routing.overhead`  | Info     | `latency_ms` spent producing the routing outcome, including routing-model calls. This is not the end-to-end request duration.                                                             |
| `switchyard.routing.decision`  | Info     | `algorithm`, optional `outcome_id`, initial `selected_model`, nullable final `served_model`, nullable `fallback_used`, and optional `evidence`.                                           |
| `switchyard.routing.error`     | Error    | Generic failures contain `failure_kind`. Route-execution failures also contain `category`, `phase`, nullable `upstream_status` and `target`, and may contain `outcome_id` and `evidence`. |

Call marks describe Switchyard observations, not every HTTP retry made inside a
client. `call_role` records whether Switchyard classified the call as routing
or answer work.

`switchyard.routing.llm_call` uses Debug severity. It still appears in the
supported trace projections, but Relay's OTLP logs default to Info. Set
`minimum_severity` to `debug` to include these call records in
[log export](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/opentelemetry#log-export).

Switchyard marks keep provider model IDs in `selected_model` and `served_model`.
Decision marks also include `selected_target`, `served_target`, and the served target's
configured `reasoning_effort`. Targets sharing one provider model remain distinguishable.
`fallback_used` compares target identities, so a fallback between two targets sharing a
provider model is still reported.
Relay request telemetry normally uses the Switchyard route ID, while response
telemetry can report the model that answered.

`fallback_used` is `true` when the final served model differs from the initial
selection and `false` when they match. It and `served_model` are `null` when the
response does not provide serving metadata. If route execution fails before a
response is available, the error mark describes the terminal failure instead.
`outcome_id` is present when the algorithm runner supplies outcome metadata.
When the algorithm supplies evidence, the plugin includes an object containing
supported string fields (`source`, `verdict`, `trigger`, and `reason_code`) and
numeric fields (`score`, `confidence`, `threshold`, `capable_score`, and
`capable_threshold`). Other fields and values
of the wrong type are omitted. String values longer than 64 bytes are also omitted
and should be stable, non-sensitive labels.

### Metrics \[#metrics]

| Metric                                 | Kind and unit           | Meaning and attributes                                                                                         |
| -------------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------- |
| `switchyard.routing.requests`          | Counter, events         | Managed requests, labeled by `algorithm`.                                                                      |
| `switchyard.routing.llm_calls`         | Counter, events         | Routing-model calls, labeled by `outcome`.                                                                     |
| `switchyard.routing.llm_call.duration` | Histogram, milliseconds | Routing-model call duration, labeled by `outcome`.                                                             |
| `switchyard.routing.overhead`          | Histogram, milliseconds | Time spent producing the routing outcome.                                                                      |
| `switchyard.routing.llm_tokens`        | Counter, tokens         | Normalized token values derived from provider usage, labeled by `call_role`, `target_model`, and `token_type`. |
| `switchyard.routing.failures`          | Counter, events         | Terminal failures, labeled by safe failure kind and available classification fields.                           |

`switchyard.routing.llm_calls` and `switchyard.routing.llm_call.duration` cover
routing-model calls only. Answer calls appear in the per-call marks and token
metrics.

Token metrics cover routing and answer calls when the provider reports usage.
The plugin does not synthesize zeroes for missing values. The supported token
types are `input`, `cached_input`, `cache_creation_input`, `output`,
`reasoning`, and `total`.

Configure delivery through Relay's
[OpenTelemetry metric export](https://docs.nvidia.com/nemo/relay/configure-plugins/observability/opentelemetry#metric-export).

## Data Handling \[#data-handling]

By default, Switchyard routing telemetry excludes request and response content.
Enabling [routing payload capture](#inspect-classifier-and-judge-payloads) adds
internal routing requests and successful buffered responses to
`libsy.upstream_attempt` and `libsy.decision_client_call` scopes. Routing marks
remain payload-free.
Relay's LLM events can capture request and response data according to Relay's
[input and output event semantics](https://docs.nvidia.com/nemo/relay/about-nemo-relay/concepts/events#input-and-output-payloads),
independently of these Switchyard marks.