Skip to content

Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.

Rust
1.8 KB
Raw Blame
schema_version = 1

[llm_clients.chatgpt_backend]
format = "openai_responses"
base_url = "https://chatgpt.com/backend-api/codex"
forward_auth = true

[targets.capable]
id = "gpt-6-sol"
llm_client = "chatgpt_backend"

[targets.efficient]
id = "gpt-6-luna"
llm_client = "chatgpt_backend"
extra_body = { store = false, stream = true }
omit_body_fields = ["max_output_tokens"]

# chatgpt.com/backend-api/codex is Codex CLI's own private endpoint, not the
# public OpenAI Responses API. It 400s unless store=false and stream=true are
# set explicitly, and it rejects max_output_tokens outright, so the
# classifier's own token cap has to be dropped before the request goes out.
[targets.terra]
id = "gpt-6-luna"
llm_client = "chatgpt_backend"
extra_body = { store = false, stream = true }
omit_body_fields = ["max_output_tokens"]

[routes.switchyard]
id = "composite-gpt-6-sol-gpt-6-luna"
type = "composite"
# Codex lists both gpt-6-sol and gpt-6-luna with a 272,000-token window. The installer
# copies this value into the Codex profile so Codex compacts at the right size.
context_window = 272000

[routes.switchyard.classifier]
target = "terra"
base_threshold = 0.5
classify_trigger = "user_turn"

[routes.switchyard.stage]
capable_target = "capable"
efficient_target = "efficient"
confidence_threshold = 0.5

# With "Approve for me" on, Codex sends each review request to the model
# codex-auto-review, unless Codex is logged in with an OpenAI API key. This
# route forwards those requests unchanged to codex-auto-review on the ChatGPT
# backend. To review with another model, point `target` at a small, fast
# model; Codex waits for each review and asks for low reasoning effort.
[targets.reviewer]
id = "codex-auto-review"
llm_client = "chatgpt_backend"

[routes.codex_auto_review]
id = "codex-auto-review"
type = "passthrough"
target = "reviewer"