> ## Documentation Index
> Fetch the complete documentation index at: https://docs.budecosystem.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Designing a routing graph

> Build a custom routing graph from signals, decisions, algorithms and plugins.

## Design a custom routing graph

**Who:** the router's owner · custom routers only

**Where:** Router → open the router

1. Open the router. Drag actions from the **Actions** palette onto the canvas, or click them.
2. Build the graph from left to right: **signals** read the request, a **decision** combines signals into a route, an **algorithm** chooses among the route's deployments, and **plugins** change the request or the answer. Wire a step to the one it depends on. A signal or projection connects to the start; an algorithm or plugin must connect to a decision.
3. Click a node to name it and set its **Parameters**. Use **Auto Layout**, **Vertical Layout**, **Horizontal Layout** and **Fit View** to tidy the canvas.
4. Click **Save**. This validates the graph, makes the router *active* and returns you to the list ("Router saved"). Errors name the step that failed.

> [!WARNING]
>
> **Always include a default route.** A request that matches no route is refused with HTTP 503, type `router_resolution_failed`, code `no_decision_matched` ("No rule in router '...' matched this request. Add a fallback rule in the router editor, or broaden one of the existing rules"). Give the last decision a low priority and a rule that matches everything.

## The building blocks

### Signals: what to look at in the request

| Signal | It fires when |
| - | - |
| **Keyword Signal** | The request contains given words or phrases. Exact, fuzzy and similarity matching. |
| **Embedding Signal** | The request is close in meaning to example phrases you list, whatever the wording. |
| **Domain Signal** | The request falls in one of 14 subject areas (law, business, biology, computer science, maths, health and others). |
| **Language Signal** | The request is in a given language. |
| **Geography Signal** | The caller's country (from their IP address) is in your list of ISO country codes. Use it for data-residency rules. |
| **Context Length Signal** | The request is between a minimum and maximum number of tokens. |
| **Complexity Signal** | The request looks easy or hard, scored against example hard and easy requests. |
| **Structure Signal** | The request has a given shape: number of questions, code blocks, step lists, formatting density. |
| **Conversation Signal** | The conversation has a given shape: turn count, tool calls, role mix, agentic loops. |
| **Reask Signal** | The user is repeating themselves across recent turns, a sign the last answer missed. |
| **User Feedback Signal** | The user is reacting to the last answer: wrong, unclear, or wants another style. |
| **Preference Signal** | The user prefers a style of answer: short, detailed, bulleted. |
| **Knowledge Base Signal** | The request matches labels in a curated knowledge base, such as privacy categories. |

### Decisions and projections: how signals become a route

| Step | What it does |
| - | - |
| **Decision** | A routing rule. It combines signals with AND, OR and NOT, and routes matching requests to a list of deployments. **Priority**: higher numbers are checked first (default 0). **Rule Tree**: when it fires. **Endpoints**: the deployments it routes to; with several, the attached algorithm picks one, and with no algorithm the first is used. Optional **Tier** (for your own grouping) and **Output Contract** (an instruction on the answer's shape for looping algorithms). |
| **Partition Projection** | Groups related signals into named buckets and picks one per request, with an optional default. |
| **Score Projection** | Combines several signals into one weighted score. |
| **Mapping Projection** | Turns a score into named bands such as low, medium and high, which decisions can reference. |

### Algorithms: how a route picks a deployment

| Algorithm | Behaviour |
| - | - |
| **Static Selection** | Always the first deployment. Deterministic. |
| **Weighted Random** | A weighted share of traffic to each deployment, for example 90 and 10. Weights are relative, so they need not total 100. Use it for canary and A/B rollouts. |
| **Random** | Uniformly at random. |
| **Round-Robin** | Rotates through the deployments in order. |
| **Least Busy** | The deployment with the fewest requests in flight right now. |
| **Latency-Aware** | A deployment that meets your latency targets. |
| **Router-DC** | The deployment whose description best matches the request, using a trained ranker. |
| **Hybrid Selection** | Balances description match, cost-aware escalation and per-token cost in one score. |
| **AutoMix** | Cheap model first; escalates to the strong one only if a verification check fails. |
| **Confidence Looper** | Tries models in turn and returns the first answer whose confidence passes the **Threshold** (0 to 1, default 0.7). **Confidence Method**: Hybrid (default), Entropy or Logprob. **Escalation Order**: Small to Large (default, cost-saving) or Large to Small. **On Error**: Skip and continue (default) or Escalate to next. |
| **Ratings Looper** | Runs candidates in parallel and returns the highest-rated answer. Quality over cost. |
| **ReMoM (Reasoning Mixture)** | Several rounds with narrowing breadth, then one synthesised answer. For hard reasoning. |
| **Panel Fusion** | A panel of models answers, a judge model rates them, and one fused answer is produced. |
| **Plan-Patch-Verify Workflow** | A planner, worker models in roles such as patcher and verifier, and a finalizer, for multi-stage agentic tasks. |

### Plugins: change the request or the answer

| Plugin | What it does |
| - | - |
| **Semantic Cache** | Reuses answers to similar past requests, matched by meaning rather than exact text. |
| **System Prompt** | Replaces or extends the system prompt on this route. |
| **Request Params** | Sanitises request parameters: strips dangerous fields, caps token budgets, drops unknown parameters. |
| **Fast Response** | Returns a fixed message without calling a model. For maintenance windows or deliberate refusals. |

## Two recipes

### Canary: 90/10

1. Create a **Decision** whose rule matches the requests you want to split.
2. Set its **Endpoints** to the stable and the new deployment.
3. Attach **Weighted Random**, with weights 90 and 10.
4. Save and publish. To widen the rollout or roll back, change the weights and save again.

### Cascade: cheap first

1. Create a **Decision** whose rule matches the requests to cascade.
2. Set its **Endpoints**: the cheap model first, the strong one last.
3. Attach **Confidence Looper** with Small to Large and a threshold such as 0.7.
4. Raise the threshold for more quality, lower it for more savings.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.