Skip to content
Docs

Llm Model Router

Llm Model Router asks a small classifier model which of your candidate models should serve an Agent request. You give each candidate a label such as coding or summary; the classifier reads the request, returns one label, and the agent runs on the matching model. Use it when the right model depends on what the request is about and a size threshold is not enough. You find it on the node picker’s AI shelf.

The node has a single output handle, Model. Connect it to the Agent’s Model handle. An agent reads one model node, so this node and the other model providers are alternatives rather than a stack.

Each candidate row can name its own API key secret: a secret holding the key for that row’s provider. A row takes a secret, never a saved connection; name a connection on the Agent’s own credential field instead. A row without a secret uses the workspace key for its provider (see AI models), with the server’s key as the final fallback. The classifier call itself takes no credential field; it authenticates with the server’s key for the router provider, so pick a router provider the server holds a key for.

The Llm Model Router node's settings form, with the fields described below
The Llm Model Router node's settings form, with the fields described below
FieldTypeDefaultDescription
Router provider (routerProvider)one of openai, anthropic, gemini, ollama, mistral, groq, xai, voyageai, openrouter, typesafe, eleven, openai-compatible, soniox ✦ (required) — The provider that runs the small classifier model deciding which candidate answers each request.
Router model (routerModel)string ✦ (required) — The classifier model used to make the routing decision; pick a cheap, fast model since it runs on every routed request.
Candidates (candidates)list (required) — The candidate models the classifier chooses between, each with a label and its provider+model.
Label (candidates[].label)string (required) —
Provider (candidates[].provider)string (required) —
Model (candidates[].model)string (required) —
API key (candidates[].apiKey)string (optional) —
Base URL (candidates[].baseUri)string (optional) —
Temperature (candidates[].temperature)number (optional) —
Max tokens (candidates[].maxTokens)integer (optional) —
Routing prompt (routingPrompt)string ✦ (optional) — Extra guidance prepended to the classifier prompt to steer how it routes between candidates.

Fields marked ✦ accept expressions.

Keep routerModel small and cheap: the classifier runs before the real request, so its price and latency are added to every uncached decision. A custom routingPrompt steers the decision but never replaces the request content and candidate list the classifier sees.

Each candidate row also carries optional temperature and maxTokens overrides that apply when that candidate is chosen.

The classifier’s answer is cached for up to six hours, so repeated requests do not pay for a second classifier call. In a conversation (for example a channel agent answering messages) the answer is cached per conversation and reused across turns. Outside a conversation it is cached per run and per prompt.

What the cache stores is the chosen label, and the set of labels is part of the cache key. Adding or renaming a label therefore starts a fresh decision, while changing the provider or model behind an existing label takes effect at once. When the classifier returns a label you did not define, the first candidate is used.

The node emits no output of its own and never runs as a step in the flow. It hands the agent one provider and model: the candidate whose label the classifier returned. The agent asks for it once when a run starts, which is when the classifier call happens unless a cached answer covers the request.

Route simple requests to a cheap model and hard ones to a stronger model (this mirrors the “Smoke / Model routing — LLM router” flow template):

  1. Add an Llm Model Router node and connect its Model handle to the Agent’s Model handle.
  2. Set routerProvider to openai and routerModel to gpt-4o-mini.
  3. Add a candidate labeled cheap with provider = openai, model = gpt-4o-mini.
  4. Add a candidate labeled smart with provider = openai, model = gpt-4o.

The classifier reads each request, answers cheap or smart, and the agent runs on that candidate’s model.

  • The classifier call spends tokens on the router model for every uncached decision. For a free, deterministic decision, use Rule Model Router or Cost Model Router.
  • Two identical requests can classify differently; the cache masks this within a conversation or run, not across them.
  • Labels must be distinct and descriptive, since they are all the classifier has to choose by.