AI Orchestrator: dynamically Selects Models Based on Input Type
VerifiedRoutes chat queries to optimal LLMs based on request classification.
What this workflow does
This n8n workflow classifies incoming chat requests and dynamically routes them to the most suitable LLM among Anthropic, OpenAI, Gemini, or OpenRouter models before generating a response through the AI Agent.
It is intended for developers and teams building scalable AI chat applications that need cost-efficient model selection and session-aware memory without manual routing logic.
Who is this for?
AI engineers and product teams running chat interfaces who need to balance cost, speed, and quality across multiple LLMs without manual routing.
What problem it solves
Teams waste money and latency by sending every query to the same heavy model; this workflow classifies requests first then routes them automatically to the right model.
Live workflow preview
Interactive canvas of every node and connection — scroll and click to explore. Powered by n8n's preview.
Open the template on n8n to import and run it. View source template →
What it automates
Customer support chatbot
Routes simple FAQs to Gemini Flash while sending complex troubleshooting to Claude Opus.
Internal dev assistant
Sends code questions to the coding-optimized model and general questions to a cheaper fast model.
Research agent interface
Classifies reasoning-heavy prompts and forwards them to Gemini Thinking while keeping general queries on GPT-4.1-mini.
How the workflow works
The 9 nodes in this automation, in order.
- 1AI Agent@n8n/n8n-nodes-langchain.agent
- 2Basic LLM Chain@n8n/n8n-nodes-langchain.chainLlm
- 3Anthropic Chat Model@n8n/n8n-nodes-langchain.lmChatAnthropic
- 4OpenAI Chat Model@n8n/n8n-nodes-langchain.lmChatOpenAi
- 5Simple Memory@n8n/n8n-nodes-langchain.memoryBufferWindow
- 6Structured Output Parser@n8n/n8n-nodes-langchain.outputParserStructured
- 7Google Gemini Chat Model@n8n/n8n-nodes-langchain.lmChatGoogleGemini
- 8OpenRouter Chat Model@n8n/n8n-nodes-langchain.lmChatOpenRouter
- 9Model Selector@n8n/n8n-nodes-langchain.modelSelector
Apps & integrations used
How to set up AI Orchestrator: dynamically Selects Models Based on Input Type
- 1Add When chat message received trigger and connect chatInput + sessionId.
- 2Insert Request Type node using OpenAI Chat Model (gpt-4.1-mini) plus Structured Output Parser for the four categories.
- 3Wire the classification output into Model Selector node.
- 4Connect Model Selector branches to the matching chat models (Anthropic, Gemini, OpenRouter).
- 5Attach Simple Memory using sessionId for conversation history.
- 6Wrap final execution in Basic LLM Chain or AI Agent node.
How to customize this workflow
- →Swap the classifier model or add new request categories in the Structured Output Parser.
- →Replace any downstream model via OpenRouter or direct provider credentials.
- →Change trigger from chat message to webhook or form submission.
- →Insert an extra AI Agent step before model execution for tool use.
AI Orchestrator: dynamically Selects Models Based on Input Type: pros & cons
Pros
- +Reduces spend by matching model size to task
- +Clear separation of classification and execution logic
- +Easy to extend with new models or categories
- +Supports per-session memory out of the box
Cons
- –Requires API keys from multiple providers
- –Classification errors can send queries to the wrong model
- –Adds one extra LLM call before the final response
Frequently asked questions
It classifies incoming chat messages and routes each to the most suitable LLM among the connected models.
User reviews
Verified reviews from the community shape this listing's rating.
Loading reviews…