A dynamic input-based LLM routing AI-agent built with n8n. It selects the most suitable language model:
- Sonar (Perplexity)
- GPT o3-mini-high (OpenAI)
- Claude 3.5 Sonnet (Anthropic)
based on user queries, and uses the selected model to answer, solve, or address the input accordingly.
The workflow above contains the following nodes:
-
Chat Trigger
(Chat Input) -
AI Agent
(Routing Agent, Agent Output) -
OpenRouter Chat Model
(gpt-4o-mini, Dynamic Model) -
Simple Memory
(Memory 1, Memory 2) -
Structured Output Parser
1. Make sure to have the following requirements:
- n8n account (Click here to create an account.)
- OpenRouter account + enough credits (Click here to create an account.)
- Docker Desktop (Optional for local hosting. Download here.)
2. Clone this repository.
Run this command in your terminal:
git clone https://github.com/m3mentomor1/Input-based-LLM-Routing-Agent.git
(Optional: You can also Fork
this repository.)
3. Go to the repository's main directory.
Run this command in your terminal:
cd Input-based-LLM-Routing-Agent
4. Import workflow into n8n.
- Create a new workflow or open an existing one (n8n website or local via docker).
- Click the ••• menu in the top-right corner.
- Select Import from File...
- Choose workflow.json from this repository.