Intent-based routing ​

Intent-based routing is an option for intelligent routes in Model Gateway. An intelligent route routes requests by either complexity or intent, and you can't combine complexity rules and intent rules in the same route. When an intelligent route routes requests by intent, Model Gateway classifies the intent of each prompt and sends it to the provider and model you mapped to that intent. You give each intent a name and a plain-language description, such as finance for Anything money related: invoices, budgets, payments, then map each intent to a target in an ordered list of rules.

FEATURE AVAILABILITY

Intent-based routing is available to select customers. Contact your Customer Success Representative to confirm whether it is available in your workspace.

Use intent-based routing to send simple requests to faster, lower-cost models, reserve premium models for the tasks that benefit from them, and keep sensitive categories, such as legal questions, on approved providers. Applications call one route and don't choose a model.

How intent-based routing works ​

Model Gateway handles each request to the route in the following order:

  1. Model Gateway compares the prompt against each intent description and selects the intent that best matches.
  2. Model Gateway evaluates the route's rules from top to bottom. The first rule that matches the selected intent sets the provider and model.
  3. If the prompt matches none of your intents, or no rule uses the selected intent, Model Gateway sends the request to the route's default target, shown on the canvas as the Else route to step. Refer to Change the default target.

Classification adds latency to every request the route handles.

Applications send requests to the route the same way as any other route, with the route ID as the model value. Refer to Test a route.

Policies that apply to the route also apply to requests that match an intent rule.

Intents ​

Each intent has a Name, which appears in the Value drop-down menu when you add a rule, and a Description, which tells Model Gateway when to select it. Editing a description changes which requests match the intent.

Renaming an intent updates the rules that use it.

Define intents ​

You must create an intelligent route and select Intent in the Routing criteria drop-down menu before you define intents. Refer to Create a route.

Complete the following steps to define the intents for a route:

1

Go to Model Gateway > Routes and click the route you plan to edit.

2

Click Edit to open the route builder.

3

Click the New LLM Call step on the canvas.

4

Enter a short name for the intent in the Name field in the Intents section, for example finance.

Define intentsDefine intents

5

Describe when Model Gateway should select the intent in the Description field, for example Anything money related: invoices, budgets, payments.

6

Click Add intent to add another intent, then enter its name and description. Repeat this step for each intent.

7

Optional. Click Delete next to an intent to remove it. You can't delete an intent that a rule uses. Change or delete that rule first.

8

Click Save.

Best practices for intent descriptions ​

Model Gateway uses each intent's description to decide which intent a prompt matches. Use the following practices to write clear descriptions:

  • Keep intents distinct. A prompt that fits two descriptions, such as finance and invoices, can go to either intent. Merge overlapping intents or narrow their descriptions so each prompt fits one.
  • List the topics or tasks an intent covers, for example Anything money related: invoices, budgets, payments, instead of a single word such as Finance.
  • Use the default target as the fallback instead of a catch-all intent. Prompts that match none of your intents go to the route's default target, so choose a general-purpose model for it.

Add an intent rule ​

Each rule maps one or more intents to a provider and model. Define intents first, because the rule's Value drop-down menu lists only the intents defined on the route.

Complete the following steps to add an intent rule:

1

Open the route you plan to edit, then click Edit to open the route builder.

2

Hover between the steps on the canvas where you plan to insert the rule, click the add icon (+), then click Rule.

3

Click the new rule step to open its configuration panel.

4

Use the Provider drop-down menu in the Model section to select the provider this rule routes to.

5

Select the model this rule routes to in the Model field. Choose a model from the list, or enter one manually.

6

Use the Value drop-down menu in the Conditions section to select the intent this rule matches. The Type is intent and the Condition is equals.

Add an intent ruleAdd an intent rule

7

Optional. Click OR to add another intent to the rule, then use its Value drop-down menu to select the intent. The rule matches when the request's intent equals any of the selected values.

8

Click Save.

Click Delete next to a condition to remove it from the rule.

Each intent can belong to only one rule. After you select an intent in a rule, it no longer appears in the Value drop-down menu for other rules.

Drag a rule to change its position, or use its ... (ellipsis) menu to copy or delete it. Refer to Reorder, copy, or delete a rule. A pasted copy of an intent rule doesn't keep the original intent, so check the Value field in the copy before you save.

View the route definition ​

Click the code icon in the route builder to view the route definition as JSON. Each rule in routing_rules lists its target provider connection and model, its when condition, and its priority. The priority value alone sets the evaluation order, and it matches the rule's position on the canvas.

Refer to View a route as JSON.

Monitor intent routing ​

Model Gateway records the routing result for each request in the audit logs.

Last updated: