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
1from openai import OpenAI
2import os
3
4client = OpenAI(
5 base_url="https://api.relayswitch.io/v1",
6 api_key=os.environ["RELAYSWITCH_API_KEY"],
7)
8
9reply = 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 frontier
13 extra_headers={"x-session-id": "agent-run-42"}, # same model all run
14)
15print(reply.model) # the model the router chose; billed at its price
Anthropic SDK: fallbacks and throughput
python
1import anthropic
2import os
3
4client = anthropic.Anthropic(
5 base_url="https://api.relayswitch.io/v1",
6 api_key=os.environ["RELAYSWITCH_API_KEY"],
7)
8
9reply = 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 fails
15 "routing": "throughput", # fastest output first
16 },
17)
18print(reply.model)
curl: a preset
bash
1# Save the agent's model, fallbacks, defaults and system prompt once (admin key).
2curl 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.
15curl 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.
2curl 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.

TierModelInputOutput
fastClaude Haiku 5.5$0.06$0.15
fastGLM 5.3 Flash$0.09$0.15
fastGPT-6 Luna$0.0625$0.20
fastMiniMax M3$0.09$0.36
fastDeepSeek V4.1 Flash$0.06$0.18
balancedClaude Sonnet 5.5$1.20$3.00
balancedGPT-6.1 Sol$0.60$3.00
balancedGemini 4 Argon$0.60$3.00
balancedKimi K3$0.90$4.50
balancedGLM 5.3$0.3276$1.0296
frontierClaude Opus 5.5$2.80$10.00
frontierGPT-6 Astra$3.00$15.00
frontierClaude Fable 5.1$6.00$30.00
frontierGemini 3.1 Pro Preview$1.20$7.20
frontierClaude Opus 5$1.80$7.50
FAQs

Questions

For agent builders.

Open the console

A key in under a minute

Get a key

Or email hello@relayswitch.io

Route your agents by the request

One model id that picks the tier, a backup list, and the price of the model that answered.