> This page is for Gateway.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Build Your Own Router

> Configure a weighted blend of published, eval-derived, or uploaded benchmarks, and Gateway routes each request to the highest-scoring model. Covers scoring, benchmark sources, score overrides, fallback, and permissions.

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](https://gateway.merge.dev/routing-policies), has no request fields, and is reached through the policy's [model alias](/merge-gateway/routing/model-aliases).

## 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](/merge-gateway/routing/custom-classifiers) 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**](https://gateway.merge.dev/routing-policies/benchmarks) groups benchmarks under **Your benchmarks** and **Published** (maintained by Merge, read-only). Select **Add benchmark** to create your own.

| Method                    | What you provide                                                                                                                                                                                                                                             |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Run evaluations**       | Prompts (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 scores** | A 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**](https://gateway.merge.dev/routing-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

| Action                               | Permissions                                                                   |
| ------------------------------------ | ----------------------------------------------------------------------------- |
| Create, edit, or delete BYOR configs | **Manage Custom routing**                                                     |
| View BYOR configs                    | **View Custom routing**                                                       |
| Attach a BYOR config to a policy     | **Manage 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](/merge-gateway/security/roles-and-permissions).

## Next steps

#### [Custom classifiers](/merge-gateway/routing/custom-classifiers)

Score complexity on your own definition of a hard request

#### [Intelligent routing](/merge-gateway/routing/intelligent)

Complexity-based routing with no benchmark setup

#### [Model aliases](/merge-gateway/routing/model-aliases)

Send requests to your BYOR policy by name