---
title: "Auto router, fallbacks and presets for agents"
canonical: https://relayswitch.io/features/routing
generated: 2026-11-02T10:14:57.615Z
source: https://api.relayswitch.io/v1/catalog
base_url: https://api.relayswitch.io/v1
---

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.

[Get an agent key](https://app.relayswitch.io/console)[Code](#example)

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 OpenAI`

2`import os`

3

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 frontier`

13 `extra_headers={"x-session-id": "agent-run-42"}, # same model all run`

14`)`

15`print(reply.model) # the model the router chose; billed at its price`

Anthropic SDK: fallbacks and throughput

python

1`import anthropic`

2`import os`

3

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 fails`

15 `"routing": "throughput", # fastest output first`

16 `},`

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](https://relayswitch.io/models/claude-haiku-5-5) | $0.06 | $0.15 |
| fast | [GLM 5.3 Flash](https://relayswitch.io/models/glm-5.3-flash) | $0.09 | $0.15 |
| fast | [GPT-6 Luna](https://relayswitch.io/models/gpt-6-luna) | $0.0625 | $0.20 |
| fast | [MiniMax M3](https://relayswitch.io/models/minimax-m3) | $0.09 | $0.36 |
| fast | [DeepSeek V4.1 Flash](https://relayswitch.io/models/deepseek-v4.1-flash) | $0.06 | $0.18 |
| balanced | [Claude Sonnet 5.5](https://relayswitch.io/models/claude-sonnet-5-5) | $1.20 | $3.00 |
| balanced | [GPT-6.1 Sol](https://relayswitch.io/models/gpt-6.1-sol) | $0.60 | $3.00 |
| balanced | [Gemini 4 Argon](https://relayswitch.io/models/gemini-4-argon) | $0.60 | $3.00 |
| balanced | [Kimi K3](https://relayswitch.io/models/kimi-k3) | $0.90 | $4.50 |
| balanced | [GLM 5.3](https://relayswitch.io/models/glm-5.3) | $0.3276 | $1.0296 |
| frontier | [Claude Opus 5.5](https://relayswitch.io/models/claude-opus-5-5) | $2.80 | $10.00 |
| frontier | [GPT-6 Astra](https://relayswitch.io/models/gpt-6-astra) | $3.00 | $15.00 |
| frontier | [Claude Fable 5.1](https://relayswitch.io/models/claude-fable-5.1) | $6.00 | $30.00 |
| frontier | [Gemini 3.1 Pro Preview](https://relayswitch.io/models/gemini-3.1-pro-preview) | $1.20 | $7.20 |
| frontier | [Claude Opus 5](https://relayswitch.io/models/claude-opus-5) | $1.80 | $7.50 |

Agent setup guides

-   [OpenClaw](https://relayswitch.io/guides/openclaw)
-   [Hermes Agent](https://relayswitch.io/guides/hermes-agent)
-   [OpenCode](https://relayswitch.io/guides/opencode)
-   [Claude Code](https://relayswitch.io/guides/claude-code)
-   [n8n](https://relayswitch.io/guides/n8n)

More features

-   [Agent tools](https://relayswitch.io/features/agent-tools)
-   [Files and redaction](https://relayswitch.io/features/files)
-   [Caching and compression](https://relayswitch.io/features/caching)
-   [Guardrails and sign-in](https://relayswitch.io/features/guardrails)
-   [MCP gateway](https://relayswitch.io/features/mcp-gateway)
-   [Endpoints](https://relayswitch.io/features/endpoints)
-   [Key budgets](https://relayswitch.io/features/key-budgets)
-   [Observability](https://relayswitch.io/features/observability)
-   [Hosted agents](https://relayswitch.io/agents)
-   [Workflows](https://relayswitch.io/workflows)
-   [Docs](https://relayswitch.io/docs)

FAQs

## Questions

For agent builders.

Open the console

A key in under a minute

[Get a key](https://app.relayswitch.io/console)

Or email [hello@relayswitch.io](mailto: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.

[All features](https://relayswitch.io/features)[Get an agent key](https://app.relayswitch.io/console)

