Routing
Routing finds a cheaper model for each agent, proven on its own traffic. It works per agent, in one of two modes:
| Shadow | Semantic | |
|---|---|---|
| What it does | Watches the agent's real calls, tests cheaper models side by side, and recommends one | Picks a model for each call from a fixed list you confirm, and serves it |
| Changes what is served | Only after an admin approves the switch | Yes, as soon as you turn it on |
| Use it to | Find the right base model for an agent, with evidence | Send each call to the model that fits its task, from models you already allow |
An agent runs one mode at a time. For retries and fallbacks when a provider is down, see Gateway.
Permissions: routing:view to open Routing; routing:evaluate or
agents:write to start or stop a Shadow window. Semantic, limits and the
routing budget are admin-only.
The Routing page
The Agents and Decisions tabs are available to members with Routing access. Recommend and Benchmarks appear only in workspaces enabled for them by the deployment.
| Tab | What it shows |
|---|---|
| Agents | Every agent's routing state. Click a row to open that agent's routing page. |
| Impact | One report per agent: what routing changed over the last 30 days, measured against the model the agent was built on. See Impact. |
| Decisions | The recommender applied to real traffic. For each governed call, what routing would have picked and what that would have cost at the same token counts. The call is still served by the model the caller asked for. Open a call to see its candidates. |
| Recommend | A ranked catalog for a prompt you paste, with evidence. It does not execute the recommended task. The UI uses a governed classifier call, which can be billed. |
Filter agents by Ready, In progress, Needs attention or Idle. Start opens the start dialog; New route profile creates a route profile.

Agent states
| State | Meaning |
|---|---|
| Off | No window running, not on Semantic. |
| Observing | A Shadow window is collecting evidence. |
| Checking the judge | The quality judge's checks haven't passed yet. See The quality judge. |
| Ready | A cheaper model qualified. Request approval to switch. |
| No change | Nothing cheaper held quality. The agent keeps its model. |
| Not enough traffic | Too few calls to compare anything. |
| Held back | A candidate looked good but was blocked. The page says why. |
| Awaiting approval | A switch request is with an admin. |
| Canary | The switch is live and being watched for errors. |
| Switched | The canary passed. The new model stays. |
| Rolled back | Errors rose after the switch, so it went back to the previous model. |
| Reverted: not enough traffic | The canary saw too few calls to confirm the switch, so it was undone. |
| Reverted: a key rejected the model | One of the agent's keys isn't allowed to call the new model, so the switch was undone. |
| Changed manually | Someone changed the agent's model during the canary, so routing stopped watching. |
Impact
Impact shows what routing changed for each agent that had Smart-routed calls in the last 30 days. Everything is measured against the agent's intended model, the model it was built on.
Each row shows the intended model, the day routing started, the cost per session before and after (for example, $0.42 → $0.31), a quality result and what to do next:
| Quality | Meaning |
|---|---|
| Held | Enough answers were judged, and the judge did not prefer the intended model. |
| N worse | The judge preferred the intended model N times. The next step is Send back. |
| N judged | Too few judged comparisons so far to call it. |
| Not judged | The judge hasn't compared any of this agent's answers yet. |
| Next | Meaning |
|---|---|
| Keep routing | Cost fell and quality held. Leave routing on. |
| Keep watching | There isn't enough evidence yet. Read the report again later. |
| Send back | The judge preferred the intended model in these comparisons. Turn routing off for the agent so it runs on its intended model again. |
Open an agent's row for its report. The cover gives the recommendation and the models routing used. The report then covers cost per session, median call time, the judged comparison, where the work went by model, and Sessions worth reading, the judge's most recent clear calls either way. How this was measured explains each figure. A figure that can't be measured, such as cost when no call had a price for the intended model, is shown as unavailable and isn't estimated.
You need a signed-in member identity to open Impact, because the report is about whose calls these were. A key with no identity sees a message saying so.
Shadow routing
Start observing
On the agent's routing page, choose Start observing, keep Routing mode on Shadow, and set:
- Profile: a saved routing profile. It fills the fields below, and you can still change any of them. Shown only when a profile exists. An agent's default profile is picked for you.
- Objective: Cost first, Quality first, Latency first or Balanced. With Balanced, set Weights for cost, quality and speed.
- How long: 7, 14 or 30 days, or Custom from 1 to 60.
- Stop after N calls: optional, 10 to 10,000. The window ends at this many calls or when time runs out, whichever comes first.
- Test on: 5%, 10% or 25% of calls. These are re-sent to candidate models in the background as side-by-side tests.
- Models to test: the candidates.
- Quality judge: the model that grades the side-by-side answers.
Evaluation intersects the agent's routing limits and credential policy. The registration model pin is treated as bookkeeping for Shadow replay; an explicitly configured allowlist remains a restriction.
Evidence builds up
Real calls are served as normal. The judge grades each sampled candidate answer against the current model's. Users never see candidate answers.
Read the result
Overview shows the decision: calls observed, models compared, what a switch would save per 30 days, the speed change, and the judge's tally ("29 of 30 at least as good"). Evidence lists every side-by-side test. Preview result computes the recommendation from what has been seen so far; Finish now, in the ⋯ menu, ends the window early.
The Recommendation card lists the top three models that passed every check, best first for the window's objective, each with its cost, quality and speed change. Show all qualifying lists the rest.
Request approval
Choose Request approval on the model you want. Each model has its own button, and any listed model can be requested. An admin approves the change, then it goes live as a canary. To end the window with no change, choose Keep current model. You can add a reason.

Side-by-side tests and the judge are real, billed calls. They are paid from the agent's routing budget, never its spend cap.
The bars a switch has to clear
A candidate is recommended only if it clears all of these:
| Bar | Value |
|---|---|
| Capability | No more than 5% worse than the current model on its worst task class, not its average. |
| Quality on real answers | A fixed horizon of assigned trials, 30 by default and saved when the window starts. Benchmark mode requires a 95% Wilson lower bound of at least 80% "at least as good". Blended or learned mode uses a non-inferiority probability gate instead. |
| Saving | At least 10% and $0.10, after the window's own test and judge spend. |
| Errors | A candidate failing more than 15% of its side-by-side tests (over 22 or more) is dropped. |
These are deployment defaults; the window's stored settings determine its gate. Finishing early does not bypass the fixed trial horizon.
Confidence is Low below 30 calls, Medium from 30, and High from 200 by default. With no quality judge, no candidate can pass.
The quality judge
The judge's verdicts count once it has passed its checks. The automatic check decides: the judge must see no difference between identical answers, and must not favour one side on pairs that should be equal.
You can also check the judge yourself, and it's optional. In Checking the judge, use Label next test to say which of two answers you prefer, up to 30 tests, shown in a fixed random order. The judge's calls are compared with yours. If your answers often differ from the judge's, you're told to keep checking or try another judge. Your deployment can require this check before a recommendation. Until the required checks pass, candidates show "no change".
The canary
After approval the agent switches to the new model, and Forgebench watches its real calls for 24 hours:
- More than 10% failed calls (over at least 20): it rolls back to the previous model on its own.
- Too few calls: the watch is extended once, then the switch is reverted.
- A key that can't call the new model: the switch is reverted.
Routing profiles
A routing profile saves the settings of a test so you can reuse them. Open Routing profiles at the top of the Routing page. These only shape tests. They don't serve calls, and they are not the route profiles below.
An admin or owner can create, edit and delete profiles. Everyone else can read them. Each profile sets:
| Field | What it does |
|---|---|
| Name, Description | The name is required. |
| Models to test | The models a test may use. Empty means any model the agent's key and workspace allow. |
| Providers | The providers a test may use. Empty means any. |
| Objective, Weights | Cost first, Quality first, Latency first or Balanced. Weights apply to Balanced and may use any scale: 50/30/20 is the same as 5/3/2. |
| Test on | 5%, 10% or 25% of calls. |
| Stop after N calls | Optional, 10 to 10,000. |
| How long | Optional: Default, 7, 14 or 30 days, or Custom from 1 to 60. |
| Quality judge, Backup judge | Optional. With none, a test uses the agent's strongest eligible judge. The backup is used only if the judge fails or gives no verdict. |
Starting a test from a profile copies its values onto that test, so editing or deleting the profile later doesn't change a test that is running. On an agent's routing page, an admin can set a default Routing profile. It is used when a test starts without one.
Semantic routing
Semantic sends each call to the model that best fits its task, from a list you confirm. The usual fallbacks apply.
Choose Semantic
On the agent's routing page, choose Start observing and set Routing mode to Semantic.
Pick the models
Start from a Saved route profile, or pick Models to route across yourself. Models the agent can't use are left out and named.
Confirm and turn it on
Confirm the list, including the agent's current model. The agent's key must allow every model in it. Semantic routing requires model switching to be enabled for the deployment. Otherwise the API returns
422 model_switching_disabled.
The agent's model becomes profile:<name>. Turn Semantic routing off
returns it to its previous model.
If the profile breaks (a model is removed, or a key no longer allows it),
calls are refused with 409 rather than sent to another model.
Route profiles
A model profile is a named list of provider/model candidates with failover.
An admin manages it through POST /v1/routing/profiles and
PATCH /v1/routing/profiles/{profile_id}. Assign profiles with routing rules
or the agent's Semantic action before selecting model="profile:<name>".
Creating a profile alone does not grant every key access to it.
The old /v1/route-profiles and /v1/smart-routing APIs return
410 route_profiles_consolidated.
A profile's strategy decides how it picks among its models: for example
priority (in order, failing over), weighted (split by the weights you
give), or round-robin. Additional strategies such as cost-optimized,
auto, semantic, and smart depend on deployment settings. Read
GET /v1/routing/strategies?kind=chat for the offered strategies. Voice profiles
have separate transcription and speech kinds and cannot be assigned to chat
rules.
One model on several provider keys
A profile can list the same model more than once, each step on a different
key for the same provider. With weighted it splits traffic between the
keys (for example 50/50); with priority it fails over from one to the
next. A 429 on one key cools down only that key, and the others keep
serving.
Each provider has one default key. An admin adds more keys under a label, with the API:
import os
import httpx
r = httpx.put(
f"{os.environ['FORGEBENCH_BASE_URL']}/v1/secrets/providers",
headers={"Authorization": f"Bearer {os.environ['FORGEBENCH_ADMIN_KEY']}"},
json={"provider": "openrouter", "api_key": "sk-or-...", "label": "org-b"},
)
r.raise_for_status()const r = await fetch(`${process.env.FORGEBENCH_BASE_URL}/v1/secrets/providers`, {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.FORGEBENCH_ADMIN_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ provider: "openrouter", api_key: "sk-or-...", label: "org-b" }),
});
if (!r.ok) throw new Error(`HTTP ${r.status}: ${await r.text()}`);import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;
String body = new ObjectMapper().writeValueAsString(Map.of(
"provider", "openrouter",
"api_key", "sk-or-...",
"label", "org-b"));
HttpResponse<String> r = HttpClient.newHttpClient().send(
HttpRequest.newBuilder(URI.create(System.getenv("FORGEBENCH_BASE_URL") + "/v1/secrets/providers"))
.header("Authorization", "Bearer " + System.getenv("FORGEBENCH_ADMIN_KEY"))
.header("Content-Type", "application/json")
.PUT(HttpRequest.BodyPublishers.ofString(body))
.build(),
HttpResponse.BodyHandlers.ofString());
if (r.statusCode() / 100 != 2) throw new IllegalStateException("HTTP " + r.statusCode() + ": " + r.body());curl -X PUT "$FORGEBENCH_BASE_URL/v1/secrets/providers" \
-H "Authorization: Bearer $FORGEBENCH_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"provider": "openrouter", "api_key": "sk-or-...", "label": "org-b"}'Then create the profile with a candidates list. Each entry has provider,
model, and an optional key label. Omitting key uses the provider's
default credential. The weights align with the candidates:
import os
import httpx
r = httpx.post(
f"{os.environ['FORGEBENCH_BASE_URL']}/v1/routing/profiles",
headers={"Authorization": f"Bearer {os.environ['FORGEBENCH_ADMIN_KEY']}"},
json={
"name": "gpt5-two-keys",
"strategy": "weighted",
"candidates": [
{"provider": "openrouter", "model": "openrouter-gpt-5"},
{"provider": "openrouter", "model": "openrouter-gpt-5", "key": "org-b"},
],
"weights": [50, 50],
},
)
r.raise_for_status()const r = await fetch(`${process.env.FORGEBENCH_BASE_URL}/v1/routing/profiles`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FORGEBENCH_ADMIN_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "gpt5-two-keys",
strategy: "weighted",
candidates: [
{ provider: "openrouter", model: "openrouter-gpt-5" },
{ provider: "openrouter", model: "openrouter-gpt-5", key: "org-b" },
],
weights: [50, 50],
}),
});
if (!r.ok) throw new Error(`HTTP ${r.status}: ${await r.text()}`);import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.Map;
String body = new ObjectMapper().writeValueAsString(Map.of(
"name", "gpt5-two-keys",
"strategy", "weighted",
"candidates", List.of(
Map.of("provider", "openrouter", "model", "openrouter-gpt-5"),
Map.of("provider", "openrouter", "model", "openrouter-gpt-5", "key", "org-b")),
"weights", List.of(50, 50)));
HttpResponse<String> r = HttpClient.newHttpClient().send(
HttpRequest.newBuilder(URI.create(System.getenv("FORGEBENCH_BASE_URL") + "/v1/routing/profiles"))
.header("Authorization", "Bearer " + System.getenv("FORGEBENCH_ADMIN_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build(),
HttpResponse.BodyHandlers.ofString());
if (r.statusCode() / 100 != 2) throw new IllegalStateException("HTTP " + r.statusCode() + ": " + r.body());curl -X POST "$FORGEBENCH_BASE_URL/v1/routing/profiles" \
-H "Authorization: Bearer $FORGEBENCH_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "gpt5-two-keys",
"strategy": "weighted",
"candidates": [
{"provider": "openrouter", "model": "openrouter-gpt-5"},
{"provider": "openrouter", "model": "openrouter-gpt-5", "key": "org-b"}
],
"weights": [50, 50]
}'Labels are 1 to 64 letters, digits, _, . or -. You can't delete a
labelled key while a profile uses it.
Routing limits
Limits narrow what routing may choose; they never widen what a key allows. Set Allowed providers for the workspace on the Routing page, and Allowed models and Allowed providers per agent on its routing page. Empty means no restriction.
Routing budget
Each agent has a Routing budget for side-by-side tests and the judge, separate from its spend cap. It never affects production traffic.
| Setting | What it does |
|---|---|
| Monthly cap (USD) | Empty uses the default. 0 means no evaluation. |
| Raise the cap for this month | Replaces the cap for the current month only. |
| Bill evaluation to | The agent's own key by default, or another Forgebench key, so that key's limits and pool apply. |
| Budget pool (optional) | Evaluation also stops when this pool's budget is used up. |
| When the budget is used up | Pause evaluation (default) or warn only. |
| Warn at | Percentage of the cap. Default 80%. |
| Pause evaluation | Stops tests and the judge now, whatever the budget. |
Recommend a model
Paste a prompt and pick what to optimise for (capability, cost, speed or a balanced default). You get a ranked shortlist from the whole catalog, with the task type, difficulty and the benchmark scores behind the pick. Models your workspace can't reach are marked, not hidden.

Multi-step apps
Shadow routing treats one key as one agent, so the hardest step of an app blocks savings on the rest. Register each step as its own agent with a workflow.

