# How Switchyard Determines Which Upstream Format (OpenAI vs. Anthropic) to Use for a Target

> Learn how Switchyard selects upstream formats like OpenAI or Anthropic based on the wire api field in your provider configuration. Optimize your API integrations today.

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

---

**Switchyard selects the upstream wire format based on the `wire_api` field declared in a provider's configuration, where `wire_api="responses"` routes to OpenAI‑compatible encoding and `wire_api="messages"` routes to Anthropic‑compatible encoding.**

When deploying large language model (LLM) inference through NVIDIA's Switchyard, the system must translate between its internal request representation and the specific JSON schema that upstream providers expect. This translation is not hardcoded per model type; instead, it is driven by a configuration property called the **wire API**. Understanding how Switchyard makes this determination is essential for operators who need to proxy requests to different backend providers without maintaining separate infrastructure stacks.

## The `wire_api` Configuration Field Controls Format Selection

Every provider definition in Switchyard includes a `wire_api` attribute that explicitly declares which serialization format the target endpoint speaks. The native server reads this value at request time and passes it to the translation layer to select the appropriate codec.

The two supported values are:

- **`wire_api="responses"`** — Selects the **OpenAI‑compatible wire format**, which expects and returns JSON structures matching OpenAI's ChatCompletion response schema.
- **`wire_api="messages"`** — Selects the **Anthropic‑compatible wire format**, which uses Anthropic's messages‑based request and response structure.

This configuration is typically supplied through TOML deployment files or programmatically by Python launchers that spin up transient provider configurations for local model instances.

## How Python Launchers Set the Wire API

Switchyard's CLI launchers are responsible for constructing provider configurations on behalf of users who run models locally. These launchers explicitly set `wire_api` to match the protocol that their proxied backend expects.

### Codex Launcher: OpenAI Format via `wire_api="responses"`

The Codex launcher, which proxies to OpenAI‑compatible local endpoints, constructs provider overrides that specify the responses wire format:

```python

# switchyard/cli/launchers/codex_cli_launcher.py

_provider_id = "codex"
provider_overrides = [
    f'model_providers.{_provider_id}.wire_api="responses"',  # OpenAI format

    f'model_providers.{_provider_id}.base_url="http://localhost:4000"',
    # ... additional provider configuration ...

]

```

This override ensures that all requests routed through the Codex provider are serialized using OpenAI's response schema before being forwarded to the local proxy.

### OpenClaw Launcher: Anthropic Format via `wire_api="messages"`

Conversely, the OpenClaw launcher, which targets Anthropic‑compatible backends, declares the messages wire format in its provider configuration:

```python

# switchyard/cli/launchers/openclaw_launcher.py

_provider_cfg = {
    "wire_api": "messages",          # Anthropic format

    "base_url": "http://localhost:4000",
    "requires_openai_auth": False,
    # ... additional provider configuration ...

}

```

By setting `wire_api="messages"`, the launcher instructs Switchyard to use Anthropic's native message serialization when communicating with the proxied Claude instance.

## Translation Layer Routing Based on `wire_api`

Once a request reaches the native server, the **translation crate** (`crates/switchyard-translation`) performs the actual encoding and decoding. The translation layer extracts the `wire_api` value from the provider configuration associated with the target model and dispatches to the appropriate codec implementation.

The routing logic follows this pattern:

1. **Request ingress** — The native server identifies the target provider from request metadata or routing headers.
2. **Provider lookup** — The server retrieves the provider's configuration, including the `wire_api` enum value.
3. **Codec selection** — The translation layer switches on `wire_api`:
   - `responses` → `switchyard-translation::openai` codec
   - `messages` → `switchyard-translation::anthropic` codec
4. **Serialization** — The selected codec transforms the internal request representation into the provider‑specific wire format, or vice versa for responses.

This architecture allows Switchyard to add support for new provider wire formats by implementing additional codecs and extending the `wire_api` enumeration, without modifying the core routing or server logic.

## Default Behavior and Fallback Handling

If a provider configuration does **not** explicitly declare a `wire_api` field, Switchyard defaults to `wire_api="responses"`. This default aligns with the OpenAI format being the most common denominator across the bundled launchers and many third‑party inference servers that implement OpenAI‑compatible APIs.

Operators should explicitly set `wire_api` in production deployments to avoid unintended format mismatches, particularly when integrating with Anthropic endpoints or other non‑OpenAI providers.

## Summary

- **Configuration‑driven selection**: Switchyard uses the `wire_api` provider attribute to determine upstream format, not model name or endpoint URL.
- **`responses` = OpenAI**, **`messages` = Anthropic**: These two enum values map directly to their respective serialization codecs.
- **Launcher responsibility**: Python launchers ([`codex_cli_launcher.py`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/codex_cli_launcher.py), [`openclaw_launcher.py`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/openclaw_launcher.py)) set `wire_api` to match their proxied backend's protocol.
- **Translation crate routing**: The Rust translation layer (`crates/switchyard-translation`) switches codecs based on `wire_api` at request time.
- **OpenAI default**: Unspecified `wire_api` values fall back to OpenAI‑compatible responses format.

## Frequently Asked Questions

### What happens if I specify the wrong `wire_api` for my target provider?

Switchyard will serialize requests using the incorrect schema, causing the upstream provider to return parsing errors or malformed responses. For example, sending Anthropic‑formatted `messages` requests to an OpenAI endpoint expecting `responses` will result in 400‑level validation errors. Always verify your backend's native protocol and set `wire_api` accordingly.

### Can I override `wire_api` without modifying launcher code?

Yes. When using the Switchyard native server directly or through custom deployment TOML files, you can declare the `wire_api` field in the `model_providers` table. The launchers are convenience wrappers that generate these TOML overrides programmatically; equivalent configuration can be supplied through static files or API calls to the configuration service.

### Does `wire_api` affect authentication headers or routing behavior?

No. The `wire_api` field controls **only** the request and response body serialization format. Authentication mechanisms (bearer tokens, API key headers) and network routing (base URLs, retry policies) are configured through separate provider attributes such as `requires_openai_auth` and `base_url`. These operate independently of format selection.