> 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.

# Custom classifiers

> Create a complexity classifier from your own labeled prompts, import them as JSON or CSV, and use it as the complexity scorer in a Build Your Own Router config.

A custom classifier teaches Gateway what "simple" and "complex" mean for your workload, from prompts you label, and replaces the built-in complexity scorer in a [Build Your Own Router](/merge-gateway/routing/build-your-own-router) config. Use one when the built-in signal misreads your traffic, such as a one-line support message that is really a hard reconciliation task.

## How it works

You supply `{prompt, complexity}` examples, `0` (trivial) to `1` (complex). Gateway splits them at `0.5`, embeds every prompt, and averages each side into a centroid, with no eval run or judge model. Each request is embedded and scored by how much closer it sits to the complex centroid than the simple one.

The classifier scores complexity only, which BYOR uses to [tilt model scores](/merge-gateway/routing/build-your-own-router#how-it-works). Per-model scores come from your benchmarks, and categories such as code or math from BYOR's capability classifier.

## Prepare training data

Score prompts by difficulty for your workload, not length. You need at least 3 examples below `0.5` and 3 at `0.5` or above; more per side gives a steadier score.

**`training-data.json`**

```json title="training-data.json"
[
  {"prompt": "Reconcile these two conflicting invoices for customer_abc and explain every discrepancy", "complexity": 0.9},
  {"prompt": "A customer's OAuth token refresh fails intermittently across three regions, trace the root cause", "complexity": 0.95},
  {"prompt": "Draft a migration plan to move our webhook consumers off the deprecated v1 endpoint", "complexity": 0.85},
  {"prompt": "Change the billing email on account customer_abc", "complexity": 0.15},
  {"prompt": "Reset the password for alice@acme.com", "complexity": 0.1},
  {"prompt": "What are your support hours?", "complexity": 0.05}
]
```

`prompt` must be a non-empty string and `complexity` a number from `0` to `1`; errors name the 1-based item number. For a spreadsheet, choose **Import from CSV**: one example per row, score in the last column. A header row is skipped, and commas inside the prompt are kept.

## Create a classifier

1. In [**Routing policies → Prompt classifiers**](https://gateway.merge.dev/routing-policies/prompt-classifiers), select **Add classifier**
2. Enter a name (unique in your organization) and optional description
3. Paste the JSON into **Scored prompts (JSON)**, or import a CSV
4. Select **Add classifier**. The button stays disabled until each side has 3 examples

Creating or editing needs **Manage routing**; viewing needs **View routing**.

## Use it in a BYOR config

In the BYOR config editor under [**Routing policies → Policies**](https://gateway.merge.dev/routing-policies), pick your classifier in **Classifier** and save, or leave **Default** for the built-in scorer. A classifier edited below 3 examples per side has no scorer and disappears from the selector. Intelligent policies can't use classifiers.

## Edit or delete

Editing examples rebuilds the classifier, and configs using it pick up the change on the next request. Deleting it detaches it, and those configs fall back to the built-in scorer instead of failing.

## Next steps

#### [Build Your Own Router](/merge-gateway/routing/build-your-own-router)

Configure benchmarks and attach your classifier

#### [Routing policies](/merge-gateway/routing/overview)

See how BYOR fits with the other strategies

#### [Roles and permissions](/merge-gateway/security/roles-and-permissions)

Manage who can create and edit classifiers