Skip to main content

🔧 Providers

Each provider is a [[providers]] block in your Switchboard configuration, declaring where requests go, which wire format to speak, how to authenticate, and what they cost. Configured blocks are grouped by vendor:

  • OpenAI — the ChatGPT subscription via the Codex API, and platform API keys
  • OpenCode — the Zen gateway, serving several model families across three wire formats
  • Ollama — local models, no credentials

Field-by-field documentation for every key in a provider block lives in the configuration reference.

Mutation scripts​

Providers can attach mutation scripts that rewrite every outbound request — headers and body — just before it is forwarded.

// scripts/custom-header.rhai
fn mutate(request) {
request.headers["x-custom-header"] = "custom-value";
request
}
mutations = ["scripts/custom-header.rhai"]

This is useful when a provider expects something your client does not send — for example, OpenCode's Zen gateway requires an x-opencode-session header shaped like a session id before it will serve -free models. See the OpenCode provider page for a full configuration.

Scripts run in declaration order, in a sandbox, before the provider credential is injected. An invalid header or a script error fails the request: nothing is forwarded unmutated.

Starting the proxy​

switchboard --config switchboard.toml

The HTTP server starts on 127.0.0.1:3812 by default. The session database is created at ~/.switchboard/sessions.db.

Checking it works​

curl http://127.0.0.1:3812/openai/v1/models

This returns provider-qualified model ids plus combined bare aliases where the shape is unambiguous. Once you see models, you're ready to configure your agent to point at Switchboard.