TOML Schema
The native deployment file defines the LLM clients, targets, and routes that a
Switchyard server serves. It is read by switchyard-server --config.
Validate a file without starting the server:
Minimal Example
schema_version must be 1. Table names under llm_clients, targets, and
routes are local references; clients send the route’s id as the model name.
The optional top-level fallback_client names an entry under [llm_clients]. When set, any HTTP
method and path not implemented by Switchyard is forwarded through that client without translating
the path, query string, body, response, or model identifier. The fallback client does not need a
target. Only its base_url is used: caller end-to-end headers are forwarded, hop-by-hop headers are
removed, and configured API keys, extra headers, format, and retries are not applied. When omitted,
unmatched paths return 404.
schema_version, [targets], and [routes] must all be present, even when a
route reaches no upstream. A file without a [targets] table is rejected with
missing field targets; an empty [targets] table satisfies it.
[llm_clients] defaults to empty and may be omitted.
[llm_clients.<name>]
For openai_responses, responses_reasoning controls replay of reasoning
history. Most configurations should leave it unset. The values are:
"auto"(default): choose per request from the target that serves it, including fallback targets. Targets onapi.openai.comor*.openai.azure.comuse"preserve_encrypted". On other hosts, such as a shared gateway or proxy, the choice comes from the last/-separated part of the targetid. Names that start withgpt-(exceptgpt-oss) orcodex-, and o-series names such aso3oro4-mini, use"preserve_encrypted". All other targets use"preserve_plaintext"."preserve_encrypted": keep reasoning items with non-emptyencrypted_contentor a stored reasoningid, and empty theircontent. ID-only reasoning is removed when the request setsstore: false. Switchyard’s translated Anthropic reasoning and plaintext-only reasoning are removed. OpenAI needs this."preserve_plaintext": keepsummaryandcontenttext unchanged and in place, for anystorevalue. Remove non-emptyencrypted_content, because Switchyard cannot tell which provider issued it. An item left with no text is removed. An ID-only item is kept unless the request setsstore: false."drop": remove all reasoning items. Use it for a backend, such as llama.cpp, that rejects reasoning from other providers.
All modes keep messages, tool calls and tool results. Set an explicit value when
"auto" picks the wrong mode, for example an Azure OpenAI deployment with a custom
name behind a gateway. The setting is rejected on other client formats, even
when no target uses the client.
The TOML never contains the secret itself. api_key_env names a variable that
must exist and be non-empty when the server loads.
Cooldown is enabled by default for 5 seconds. Set failure_cooldown_ms = 0 to disable it.
The cooldown starts after retries are exhausted.
failure_cooldown_ms tracks transport failures, timeouts, HTTP 408/429, and 5xx
responses after retries. State is shared across callers per model within the client,
including callers using forwarded credentials. With forward_auth = true, HTTP 429
triggers request-local retries and, by default, fallback; other callers keep trying the model.
For shared credentials, HTTP 429 also triggers cooldown by default. During cooldown,
ordered fallback tries the next candidate. A terminal cooldown error returns HTTP
503. Calls resume together after expiry. Auxiliary calls and errors after a stream
is returned leave cooldown state unchanged.
When retries are exhausted, Switchyard returns the upstream error with its
Retry-After, retry-after-ms, and x-should-retry headers from the last attempt.
With fallback_on_rate_limit = false, HTTP 429 does not start cooldown, so later
requests can receive the upstream response too. Retry budgets and deadlines still
apply. Other errors keep their existing fallback and cooldown behavior. This option
controls completion candidates; judge and advisor error recovery is unchanged.
timeout_ms applies separately to every call through the client, including judge
verdicts and answers. To give a judge a short deadline without limiting the
answering models, put the judge on its own [llm_clients] entry; two entries may
share a base_url. When an answer deadline expires, the server returns 504.
If the final answer has already started streaming, the
server sends a framed error and ends the stream without a success marker.
The Rust runner collects streams used during routing before the algorithm
continues, preserving provider events for replay. After the configured retries,
an HTTP client failure stops routing unless the call enables recovery.
Capability classifiers, direct classifiers, and advisor gates default to
fail_open = true. A capability classifier routes to the capable tier on judge
failures, including deadlines. A direct classifier routes to its
default_target. An advisor returns the buffered executor turn when its consult
fails.
Set fail_open = false to stop the request on these failures.
Answer calls keep their usual error behavior.
Set forward_auth = true to use each caller’s credential instead of a
server-owned key:
forward_auth cannot be combined with api_key_env. OpenAI clients forward
authorization, chatgpt-account-id, and x-openai-fedramp. Anthropic clients
forward authorization or x-api-key; for Claude subscription OAuth, they also
forward oauth-* values from anthropic-beta and remove all other inbound beta
values.
This setting gives base_url the caller’s login. Enable it only when that
upstream should receive the credential, and use HTTPS unless the upstream runs
on loopback. Other application headers are preserved and may contain
provider-specific credentials. Forwarding clients do not follow HTTP redirects.
A forwarded credential belongs to the service that issued it. A ChatGPT login,
for example, must never reach Anthropic. So all forwarding clients in a route,
including classifier and judge targets, must use one credential family: OpenAI
(openai_chat and openai_responses clients, which serve Chat Completions and
Responses callers) or Anthropic (anthropic_messages clients, which serve
Messages callers).
The exception is one host that serves both formats, such as an LLM gateway that
accepts each caller’s gateway key on its OpenAI and Anthropic endpoints. A route
may mix the two families when all of its forwarding clients use the same scheme,
host, and port in base_url; the path may differ:
Such a route serves Chat Completions and Responses callers and forwards the
caller’s bearer token to every forwarding client. The server returns 400 without
calling an upstream when a caller uses an API that the route does not serve.
These limits apply only to forwarded credentials. A client with api_key_env
sends the server’s own key, so a route can mix formats and providers through
such clients.
[targets.<name>]
Switchyard routes on target names, so several targets may share one id. Each target keeps its
own llm_client, system_prompt, extra_body, omit_body_fields, reasoning_effort, and media. For
example, one route can run the same model at two efforts:
Responses, the x-model-router-selected-model header, and the routing log model field name the
target’s id. Existing model metric labels and the models keys in /v1/stats and
/v1/routing/session-stats also use provider IDs. Targets sharing a provider model contribute
to one model aggregate.
Both stats endpoints add a separate targets breakdown keyed by TOML target name. Each entry
includes model, configured reasoning_effort (or null), and that target’s counters. The
process stats also include classifier.targets for routing-time calls. Totals count each call
once; the model and target breakdowns are two views of those calls. Routing log rows retain
model and target, and include reasoning_effort when configured. Older rows without a
target still contribute to model totals.
Each selected or fallback target is prepared from the routed request independently. A prompt configured for one target is therefore not carried into another target’s fallback request. Judge-only, classifier-only, and reviewer-only targets are not completion destinations and do not receive this prompt.
Escalation’s weak target and Advisor’s executor produce a candidate response while routing, so their target prompt is applied to that call. A prompted target in either role cannot also be that route’s judge or reviewer; Switchyard rejects that configuration when it loads. Token-count requests do not apply target system prompts.
[decision_clients.<name>]
Decision clients serve typed judgments for routing classifiers.
For OpenAI Decisions:
Each decision_targets entry pairs an upstream model id with a decision_client.
Both formats receive the conversation messages, the question instructions, and
the choice descriptions.
[routes.<name>]
Every route takes the common keys below, plus the keys for its type.
Optional infrastructure check
A capability llm_classifier route without escalation may include [routes.<name>.infra]. Both tiers must have one model; each model may have
multiple workers. A host applies the policy explicitly with Route::apply_infra
after Route::decide, using periodically collected model-pool metrics and local in-flight
counts. Plain decide and execute retain task routing. Sub-agent routing is unchanged.
All keys are required. Limits must be positive. Missing or stale observations retain the task decision. See the Dynamo PreProc example for collection and capacity safeguards.
noop
Returns a buffered assistant response containing OK without calling an
upstream model. Use it for local smoke tests.
A noop-only deployment reaches no upstream but still needs the [targets]
table, which can be empty:
passthrough
Sends parent requests to one target. It can also route delegated sub-agent work; see Sub-Agent-Aware Routing.
random
Splits traffic across targets. See Random Routing.
plan_execute
This route type has been removed. Use stage_router with
picker = "capable_first", confidence_threshold = 0.0,
capable_hold_turns = 0, efficient_hold_turns = -1, and a
capable_system_prompt. See the recipe in
Plan/Execute with Stage.
prefill_router
Experimental in v0.3.0
Switchyard v0.3.0 does not provide or support a router checkpoint, an exporter, or compatible encoder assets. You must obtain or train a compatible checkpoint and obtain its encoder and tokenizer yourself. There is no supported end-to-end checkpoint export and compatibility contract. The example below shows configuration syntax, not a ready-to-run deployment.
Routes the latest non-empty user message with a checkpoint-backed prefill classifier. Build
switchyard-server with --features prefill-router and make the prefill router’s Python
dependencies available in the active virtual environment.
llm_classifier
Runs one of four modes: capability, escalation, custom, or direct.
max_output_tokens and judge_deadline_ms apply to LLM judges.
Capability mode classifies before serving. See LLM Classifier Routing.
Escalation mode serves the weak target first and judges the completed turn. See Escalation-Router Routing.
Existing configurations that contain escalation but omit mode remain valid.
Custom mode validates the judge’s JSON against response_schema, resolves the
policy selector, and routes to a runtime model group. A verdict names a group and
the first model in it serves the turn. An eligible non-timeout failure tries the
rest of that group, then any remaining models in models.any. A timeout stops
the request without trying another model. A connection that times out before it
is established counts as a connection failure, not a timeout, so it tries the
next model.
The [routes.<name>.models] table takes any group name you choose. any and
judge are reserved and required; capable and efficient are reserved for the
tier meaning the other algorithms give them. Every other key is yours, which is
how one route chooses between more than two models.
The selected JSON label must name a configured group. A label naming a target
rather than a group, or a group you did not configure, falls back to
default_target. judge is not routable.
Classifier prompts must not contain {{RESPONSE_SCHEMA}}. Switchyard supplies
the schema automatically: through the structured-output request in json_schema
mode, or in the prompt in json_object mode.
Direct mode asks a decision target to select one model group. See
Direct selection.
classify_trigger and message_hash_fallback work as in custom mode.
stage_router
Scores tool signals to pick a tier per turn. See Stage-Router Routing for how the signals work and for tuning.
handoff_notes keys
classifier keys
The judge runs when the signals are ambiguous or the request has no tool history. It runs as a step inside the stage cascade, not as a standalone route, so it is consulted on every ambiguous turn and never retains a verdict.
classifier.response_schema, classifier.policy, and any classifier.mode
other than capability are rejected on a stage_router route with
custom classifier settings require composite with mode = custom.
classifier.mode = "capability" is accepted and changes nothing. Use a
composite route for a custom judge.
auto
auto is a preset. It builds a stage_router route with fixed settings and no
classifier. Use it when you want the recommended starting point without tuning.
See Auto for what the preset does and
when it does not route.
auto accepts no other keys. Adding one is a configuration error. For example,
adding confidence_threshold = 0.5 to an auto route fails --dry-run with:
An auto route behaves the same as this stage_router route. It has no
classifier, no handoff notes, and no per-tier system prompts:
To tune the preset, replace the auto route with this block and edit the keys.
The stage_router table lists every key. See
Stage-Router Routing for
tuning guidance and the model selection guide
for choosing the two targets.
composite
Composes other algorithms, letting one set another’s configuration. Today a classifier selects the stage router’s starting tier and confidence threshold. Tool signals still drive escalation and recovery. See Composite Routing.
The capable-first profile uses a planning prompt by default. Shared or profile
capable_system_prompt overrides it. An empty string disables it.
Optional efficient and capable tables provide independent stage
settings and prompts. See independent stage profiles.
For decision classifier configuration, see
Decision model classifier.
The same decision settings are accepted by the optional stage_router classifier.
The tier is retained per session. A deployment that sends no session ID needs
classifier.message_hash_fallback = true, which keys on the first user message
instead. The outer [routes.<name>.classifier] table is required. The nested
[routes.<name>.stage] table accepts neither picker nor a second classifier.
The outer classifier supplies the default tier. A turn the classifier cannot
reach falls open to the efficient tier.
advisor
Serves every client-visible turn from the executor and has a stronger advisor review terminal turns before the caller sees them: APPROVE releases the buffered turn, REDO discards it and sends the executor back to work with the advisor’s plan. See Advisor-Gate Routing.
vgr
Generates an efficient candidate and verifies it before serving a final answer. See Verification-Gated Routing for the verification policy, tool turns, handoff behavior, and serving modes.
Start with the route configuration or the complete local-server example.
Validation Errors
--dry-run prefixes configuration failures with
invalid server config <path>:. Within that wrapper, TOML deserialization
errors start with failed to parse TOML:, while errors from validating the
built configuration retain their inner message unchanged.