Skip to content

That's just a taste — their profile full of gems!

Visit profile
User avatar
Kenneth Mendoza
December 40

LLM routing in n8n

I’m a big fan of not overengineering agent systems, and this is one of those patterns that feels genuinely useful.

Instead of hardwiring one model into an n8n workflow and hoping it performs well on every task, I’d rather add a small decider agent in front of the answering agent and let it route the request based on the job.

That means:

  • web/live info → one model
  • reasoning-heavy work → another model
  • coding → a different one

That setup is clean, modular, and honestly the biggest win is that I can drop it into almost any existing agent workflow without rebuilding the whole thing.

What I liked most is the use of OpenRouter inside n8n. Once that’s connected, I’m not stuck choosing from one provider. I can dynamically pass the model ID selected by the router and let the second agent answer with that model.

That’s the unlock.

The actual build is pretty straightforward:

First, I’d create a decider agent whose only job is to classify the user’s request and return structured JSON with two fields:

  • the original user query
  • the selected model ID

Then I’d give it a short list of candidate models, plus the strengths of each one. Not vague descriptions either — I’d make them practical.

If I want Perplexity for live web results, Claude for coding, and o3-mini-high for reasoning, I’d say exactly that in the prompt and include examples. The key move is using the exact OpenRouter model IDs, so the next node can map them dynamically without guesswork.

After that, I’d force a structured output parser so the router always returns the same schema. No messy parsing. No brittle regex hacks. Just predictable JSON.

Then the second agent becomes the execution layer: it receives the query from the router, maps the chosen model dynamically, and answers using the best-fit model for that request.

That pattern is simple, but it’s powerful because it separates:

decision-making from response generation

I like that a lot. It’s a cleaner design than trying to make one mega-agent do all the thinking and all the execution at once.

One thing I’d absolutely keep in mind: this works best when the router is choosing from a small set of models.

If I’m routing across 3 to 10 models, great.
If I’m trying to route across 25 models, I’m asking for confusion.

At that point, I’d break it into layers:

First classify the request into a category like coding, research, reasoning, or content. Then inside that category, use a more specialized router to pick the best model from a smaller pool.

That’s a much better architecture than dumping every model into one prompt and hoping the agent stays sharp.

What I really take from this is that good AI automation is usually about smart orchestration, not just smarter prompts.

The model matters, sure.
But the routing logic matters just as much.

And in n8n, this is the kind of workflow that feels very shippable. I could build it fast, test it in chat, and then plug it into Slack, Telegram, forms, or any other trigger once it’s working.

Elegant integration beats unnecessary complexity every time.

If I were implementing this myself, I’d keep the first version extremely lean: one router, three models, structured output, dynamic model mapping, done.

Then I’d expand only after seeing real usage.

That’s usually the move.

#automation#llm#aiagents#workflows#n8n#openrouter
Like
Dislike

Add a comment...