# Supported API Formats for LLM Clients in Switchyard and Their Upstream Endpoints

> Discover Switchyard's supported API formats for LLM clients including OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages. Learn about their upstream endpoints.

- Repository: [NVIDIA-NeMo/Switchyard](https://github.com/NVIDIA-NeMo/Switchyard)
- Tags: api-reference
- Published: 2026-08-22

---

**Switchyard supports three wire formats for LLM clients—OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages—each mapped to specific upstream HTTP endpoints through a type-safe `Backend` enum.**

Switchyard, an open-source inference router maintained by NVIDIA-NeMo, normalizes access to large language model providers through a unified client interface. Understanding the supported API formats for LLM clients in Switchyard is essential for configuring correct upstream connections to OpenAI and Anthropic services. The system uses a `WireFormat` enum to abstract provider differences and a `Backend` enum to enforce valid endpoint combinations at compile time.

## The Three Wire Formats Supported by Switchyard

Switchyard defines all supported API formats in the `WireFormat` enum located in [`crates/protocol/src/format.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/protocol/src/format.rs). The framework currently recognizes three distinct wire format variants:

- **`OpenAiChat`**: Represents the OpenAI **Chat Completions** API
- **`OpenAiResponses`**: Represents the OpenAI **Responses** API  
- **`AnthropicMessages`**: Represents the **Anthropic Messages** API

Each variant corresponds to a specific provider protocol and determines the exact HTTP path used when forwarding requests upstream.

## Mapping Formats to Upstream Endpoints

The translation from abstract wire format to concrete URL occurs in [`crates/libsy-llm-client/src/backend.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/libsy-llm-client/src/backend.rs). This module declares the `Backend` enum, which implements the `url()` method to construct valid request URLs by combining a user-provided base URL with format-specific paths.

The `url()` method pattern matches on the `Backend` variant to select the correct endpoint:

```rust
pub fn url(&self) -> String {
    let base_url = self.config().base_url.trim_end_matches('/');
    match self {
        Backend::OpenAiChat(_) => openai_url(base_url, "/chat/completions"),
        Backend::OpenAiResponses(_) => openai_url(base_url, "/responses"),
        Backend::Anthropic(_) => anthropic_url(base_url),
    }
}

```

The helper functions append paths as follows:

- **`openai_url`**: Concatenates the base URL with the provided path segment
- **`anthropic_url`**: Automatically appends `"/v1/messages"` to the base URL

This architecture ensures that selecting a `Backend` variant automatically configures the correct **wire format**, **authentication scheme**, and **upstream endpoint path**, eliminating runtime misconfiguration errors.

## Client Configuration Examples

Below are complete Python configurations demonstrating how to instantiate Switchyard clients for each supported API format.

### OpenAI Chat Completions Format

Use `Backend.OpenAiChat` to route requests to the `/chat/completions` endpoint:

```python
import switchyard

client = switchyard.Client(
    backend=switchyard.Backend.OpenAiChat(
        base_url="https://api.openai.com/v1",
        api_key="sk-...",
    )
)

response = client.chat(messages=[{"role": "user", "content": "Hello"}])
print(response)

```

### OpenAI Responses Format

Use `Backend.OpenAiResponses` for the Responses API endpoint at `/responses`:

```python
client = switchyard.Client(
    backend=switchyard.Backend.OpenAiResponses(
        base_url="https://api.openai.com/v1",
        api_key="sk-...",
    )
)

response = client.responses(messages=[{"role": "user", "content": "Explain"}])
print(response)

```

### Anthropic Messages Format

Use `Backend.Anthropic` to connect to Anthropic's Messages API at `/v1/messages`:

```python
client = switchyard.Client(
    backend=switchyard.Backend.Anthropic(
        base_url="https://api.anthropic.com",
        api_key="sk-ant-...",
    )
)

response = client.messages(messages=[{"role": "user", "content": "Tell me a story"}])
print(response)

```

All three examples utilize the same high-level `switchyard.Client` interface. Only the `Backend` variant differs, which automatically selects the appropriate `WireFormat` and upstream path without manual URL construction.

## Key Implementation Files

Switchyard's API format abstraction relies on these critical source files:

- **[`crates/protocol/src/format.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/protocol/src/format.rs)**: Defines the `WireFormat` enum containing the three supported format variants.
- **[`crates/libsy-llm-client/src/backend.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/libsy-llm-client/src/backend.rs)**: Implements the `Backend` enum with `wire_format()` and `url()` methods that map each format to its specific upstream HTTP path.
- **[`crates/libsy-llm-client/src/client.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/libsy-llm-client/src/client.rs)**: Provides the Python bindings that expose `Backend` variants to user code.
- **[`crates/switchyard-server/src/config.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/switchyard-server/src/config.rs)**: Mirrors these formats server-side through the `ClientFormat` configuration, ensuring consistent routing across the entire stack.

## Summary

- Switchyard supports **three wire formats**: `OpenAiChat`, `OpenAiResponses`, and `AnthropicMessages`.
- Each format maps to a **specific upstream endpoint**: `/chat/completions`, `/responses`, and `/v1/messages` respectively.
- The `Backend` enum in [`crates/libsy-llm-client/src/backend.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/libsy-llm-client/src/backend.rs) enforces **compile-time safety** by coupling wire format, URL construction, and authentication.
- Python clients select formats by choosing the appropriate `Backend` variant, requiring no manual URL path configuration.

## Frequently Asked Questions

### What happens if I use the wrong Backend variant for my API provider?

Switchyard performs compile-time validation through the `Backend` and `WireFormat` enums. If you select `Backend.Anthropic` but attempt to use OpenAI-specific request structures, the type system will reject the mismatched wire format before runtime, preventing misrouted requests and authentication errors.

### Does Switchyard support custom endpoints or only the standard provider URLs?

While Switchyard fixes the relative paths (e.g., `/chat/completions`), you can configure any base URL via the `base_url` parameter in your `Backend` configuration. This allows routing to OpenAI-compatible proxies or self-hosted instances while maintaining the correct wire format serialization.

### How does the Responses API differ from Chat Completions in Switchyard?

The `OpenAiResponses` variant targets the `/responses` endpoint rather than `/chat/completions` and expects a different request/response schema defined by OpenAI's Responses API specification. Switchyard handles serialization differences internally through the `WireFormat` abstraction, exposing provider-specific methods like `client.responses()` rather than `client.chat()`.

### Where is the endpoint URL actually constructed in the source code?

The final URL construction occurs in the `url()` method of the `Backend` enum within [`crates/libsy-llm-client/src/backend.rs`](https://github.com/NVIDIA-NeMo/Switchyard/blob/main/crates/libsy-llm-client/src/backend.rs). This method trims trailing slashes from the base URL and appends the format-specific path segment, ensuring valid HTTP request formation for every supported LLM client API format in Switchyard.