Lesson 4 of 4 Optimizing and Operationalizing Generative AI

Routing Requests Across Models and Rules Engines

This lesson explains how production systems route requests to the right model, escalate when needed and keep deterministic decisions in rules, using model router, cascades, routing flows, hybrid designs and an AI gateway.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how model router and cascades choose a model per request.
  • Design a routing flow that sends each request to a suitable flow.
  • Divide work between an LLM and a rules engine.

Model router and cascades

Requests to a production application vary widely in difficulty. Many are simple, such as rephrasing a sentence or answering a lookup question, and a small model handles them well at a fraction of the cost and latency. A minority need a large or reasoning model. Sending every request to the largest model wastes money on the simple majority, while sending every request to a small model fails on the difficult minority. Multi-model orchestration matches each request to a model that can handle it, and it can be done by the platform or by the application.

Model router is deployed in Foundry like a model. For each request it evaluates the prompt's complexity and chooses among a set of underlying models, sending simple requests to smaller, cheaper models and complex ones to larger or reasoning models; the response reports which model answered. It reduces cost with minimal application change. A cascade is built by the application: a small model answers first, a check (schema validation, a confidence estimate, an evaluator or a rule) decides whether the answer is acceptable, and failures are escalated to a larger model.

The following diagram compares the two approaches.

Model router compared with a cascade. Model router is one deployment that judges each prompt's complexity and sends it to a smaller, larger or reasoning model, and the response reports which model answered. A cascade is built in the application: a small model answers first, a check accepts the answer or escalates it to a larger model.
Model router needs only a deployment change; a cascade needs application code but lets the team define exactly when an answer is good enough.
Sort into groups

Router or cascade?

Exam skills 2.3.4

Tell apart model router and an application-built cascade.

Log in to try this activity Interactive activities are free with an account.

Routing flows

A router classifies requests and sends each to the flow that suits it: a code model for programming questions, a RAG flow for policy questions, an agent for account actions, a canned response for greetings. Classification can use a small model, an embedding similarity against example requests, or rules for obvious cases. Routing decisions are logged so that misroutes can be analyzed.

Hybrid LLM and rules engines

A rules engine is a component that applies explicit business rules, such as coverage limits or approval thresholds, to structured data and always returns the same result for the same input. It can be a dedicated product, a decision table or ordinary application code. LLMs are good at understanding language but are not deterministic, cannot guarantee that a rule is applied exactly, and cannot easily show which rule produced a decision. In a hybrid design, the LLM therefore handles language and the rules engine handles decisions. The following table shows a typical division for an insurance claim.

StepComponentReason
Extract claim details from the emailLLM with structured outputsUnstructured language
Check coverage and limitsRules engine or codeDeterministic, auditable, regulated
Detect missing informationRules over extracted fieldsSimple completeness checks
Write the decision letterLLM grounded in the decisionNatural language generation

This makes decisions repeatable and explainable while keeping the flexibility of language models. An AI gateway in Azure API Management sits in front of model deployments and adds load balancing across backends, circuit breakers, token rate limits per consumer, token metrics and semantic caching of similar prompts.

Worked example

Reducing cost with minimal changes

A company's internal assistant sends every request to a large reasoning model. Analysis shows that 70% of requests are simple lookups or rephrasings. The team wants to cut cost with the fewest code changes.

Deploying model router and pointing the application's deployment name at it sends simple requests to smaller models automatically, with no routing code. A custom cascade would also work but requires building and maintaining the escalation logic.

Check yourself

Which decisions belong in a rules engine rather than an LLM?

Show answer

Deterministic, auditable decisions. The LLM extracts information and explains decisions, while rules make them.

Exam Tips

Remember for the exam

  • Automatic per-request model selection with minimal code changes: model router.
  • Cascades need a reliable check to decide when to escalate.
  • Deterministic, auditable decisions belong in rules; LLMs extract and explain.