Skip to navigation

Build Your Own Router

Route each request to the model that scores highest on benchmarks you choose

Build Your Own Router (BYOR) scores candidate models on a weighted blend of benchmarks you pick and routes each request to the top scorer. Use it when the right model depends on evaluations you trust, such as your own judge-graded prompts, rather than a generic cost or quality curve. BYOR is configured in the dashboard, has no request fields, and is reached through the policy’s model alias.

How it works

  1. Candidates. Only models scored in at least one of the config’s benchmarks are considered (an unscored model never routes), filtered by your organization’s zero data retention, credential, region, and capability requirements.
  2. Weighted score. Benchmark scores are normalized to 0 to 1, and a model’s score is the weighted average across its benchmarks. Each benchmark’s Missing coverage setting handles a missing score: Median (default) ranks it at the median, Exclude removes the model, and Zero scores it 0.
  3. Capability boost. Gateway classifies the prompt (code or math, for example). Benchmarks tagged with the matching capability get up to 1.6 times their weight, then weights are renormalized.
  4. Complexity tilt. On complex prompts, models above the candidate average gain up to 40%; simple prompts favor lower-scoring models; mid-range prompts get no tilt. A custom classifier can replace the built-in complexity scorer.
  5. Pick. The highest score wins. Ties go to the model with more real (not filled-in) benchmark scores.

If no model qualifies, the config’s fallback model serves the request. With no usable fallback, it fails with 503 byor_no_qualifying_model.

Build your benchmark library

Routing policies → Benchmarks groups benchmarks under Your benchmarks and Published (maintained by Merge, read-only). Select Add benchmark to create your own.

MethodWhat you provide
Run evaluationsPrompts (your own or from the prompt library), a capability tag, and a judge model with traits (coding accuracy, logical reasoning, general quality, factual knowledge, creative writing) or a custom rubric. Gateway grades each model and saves the scores
Enter existing scoresA JSON map of "provider/model" to score, a Score scale (0 to 100, 0 to 10, or 0 to 1), a Missing coverage setting, and an optional capability tag. Out-of-range scores are rejected

Capability tags are Code, Math, Reasoning, Knowledge, Instruction, Creative, Finance, and General. Untagged benchmarks never get the capability boost.

Create a BYOR policy

  1. In Routing policies → Policies, create or edit a policy and choose the Build Your Own Router strategy
  2. Pick a config from Saved configs, or choose New configuration
  3. Name the config and add weighted benchmarks. Weights must total 100%; Normalize to 100% appears when they don’t
  4. Optionally choose a Classifier and a Fallback model (optional)
  5. Save. The config applies from the next request

BYOR isn’t available on customer routing policies.

Score overrides

To correct one model’s score on one benchmark (Published or your own), select the pencil icon on its row in the config editor. The override replaces the score on the normalized 0 to 1 scale without changing the benchmark. Clear the field and save to remove it.

Permissions

ActionPermissions
Create, edit, or delete BYOR configsManage Custom routing
View BYOR configsView Custom routing
Attach a BYOR config to a policyManage routing, plus Manage Custom routing or View Custom routing

Admin and Developer include both Custom routing permissions; Security and Read Only include View Custom routing. See Roles and permissions.

Next steps