Routing
The right model per request, and a backup when it fails.
Send relayswitch/auto and the router picks a fast, balanced or frontier model for each call. Name fallbacks, save presets, route by throughput. Every answer says which model it was and bills at that model's price.
Auto router, live
- Model id
- relayswitch/auto
- Fast tier
- 5 models
- Balanced tier
- 5 models
- Frontier tier
- 5 models
- Fallbacks per request
- up to 5
- Session stickiness
- 30 minutes
What it does for an agent
- Auto router
- relayswitch/auto classifies the request on the API and picks a tier. No extra model call, no added fee.
- Sticky per session
- With x-session-id the agent keeps one model for the whole run, so its context and tool habits stay put.
- Fallback lists
- models: [...] names up to 5 backups. A key can carry fallback_models for every request that names none.
- Saved presets
- Model, fallbacks, params, system prompt and tools under one name, called as @preset/<name>. Change the preset, not the agent.
- Throughput routing
- routing: throughput tries the route with the most tokens per second first; latency, the quickest first token. Same price.
- Spend and concurrency per key
- Daily, weekly or monthly spend limits and a cap on requests in flight, so a runaway agent stops at its own line.
Copy, paste, run
OpenAI SDK: auto router
python
1
from openai import OpenAI2
import os3
4
client = OpenAI(5
base_url="https://api.relayswitch.io/v1",6
api_key=os.environ["RELAYSWITCH_API_KEY"],7
)8
9
reply = client.chat.completions.create(10
model="relayswitch/auto",11
messages=[{"role": "user", "content": "Refactor this function to async."}],12
extra_body={"auto": {"tier_max": "balanced"}}, # never frontier13
extra_headers={"x-session-id": "agent-run-42"}, # same model all run14
)15
print(reply.model) # the model the router chose; billed at its priceAnthropic SDK: fallbacks and throughput
python
1
import anthropic2
import os3
4
client = anthropic.Anthropic(5
base_url="https://api.relayswitch.io/v1",6
api_key=os.environ["RELAYSWITCH_API_KEY"],7
)8
9
reply = client.messages.create(10
model="claude-sonnet-5-5",11
max_tokens=1024,12
messages=[{"role": "user", "content": "Plan the migration."}],13
extra_body={14
"models": ["gpt-6.1-sol", "kimi-k3"], # tried in order if claude-sonnet-5-5 fails15
"routing": "throughput", # fastest output first16
},17
)18
print(reply.model)curl: a preset
bash
1
# Save the agent's model, fallbacks, defaults and system prompt once (admin key).2
curl https://api.relayswitch.io/v1/presets \3
-H "Authorization: Bearer $ADMIN_KEY" \4
-H "Content-Type: application/json" \5
-d '{6
"name": "coder",7
"model": "claude-sonnet-5-5",8
"models": ["gpt-6.1-sol"],9
"params": {"temperature": 0.2, "max_tokens": 4096},10
"system_prompt": "You are a careful senior engineer.",11
"description": "Coding agent defaults"12
}'13
14
# Then any agent calls it by name.15
curl https://api.relayswitch.io/v1/chat/completions \16
-H "Authorization: Bearer $RELAYSWITCH_API_KEY" -H "Content-Type: application/json" \17
-d '{"model": "@preset/coder", "messages": [{"role": "user", "content": "Fix the failing test."}]}'Key API: limits and default fallbacks
bash
1
# An agent key with a daily spend limit, 8 requests in flight and fallbacks.2
curl https://api.relayswitch.io/v1/keys \3
-H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \4
-d '{"name": "nightly-agent", "monthly_cap_usd": 5, "spend_limit_period": "daily",5
"concurrency": 8, "routing": "throughput",6
"fallback_models": ["gpt-6.1-sol", "kimi-k3"]}'The auto router’s tiers today
From GET /v1/catalog auto_router, priced live in USD per million tokens.
| Tier | Model | Input | Output |
|---|---|---|---|
| fast | Claude Haiku 5.5 | $0.06 | $0.15 |
| fast | GLM 5.3 Flash | $0.09 | $0.15 |
| fast | GPT-6 Luna | $0.0625 | $0.20 |
| fast | MiniMax M3 | $0.09 | $0.36 |
| fast | DeepSeek V4.1 Flash | $0.06 | $0.18 |
| balanced | Claude Sonnet 5.5 | $1.20 | $3.00 |
| balanced | GPT-6.1 Sol | $0.60 | $3.00 |
| balanced | Gemini 4 Argon | $0.60 | $3.00 |
| balanced | Kimi K3 | $0.90 | $4.50 |
| balanced | GLM 5.3 | $0.3276 | $1.0296 |
| frontier | Claude Opus 5.5 | $2.80 | $10.00 |
| frontier | GPT-6 Astra | $3.00 | $15.00 |
| frontier | Claude Fable 5.1 | $6.00 | $30.00 |
| frontier | Gemini 3.1 Pro Preview | $1.20 | $7.20 |
| frontier | Claude Opus 5 | $1.80 | $7.50 |
Agent setup guides
FAQs
Questions
For agent builders.
Route your agents by the request
One model id that picks the tier, a backup list, and the price of the model that answered.