基于输入类型动态选择模型
中级
这是一个Engineering、AI Chatbot领域的自动化工作流,包含 12 个节点。主要使用 Agent、ChainLlm、ChatTrigger、LmChatOpenAi、ModelSelector 等节点。 智能 AI 路由:根据内容类型将查询定向至 GPT、Claude、Gemini 或 Perplexity
前置要求
- •OpenAI API Key
- •Anthropic API Key
- •Google Gemini API Key
使用的节点 (12 个)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "abSdfsaYgkssXX7g",
"meta": {
"instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462",
"templateCredsSetupCompleted": true
},
"name": "基于输入类型动态选择模型",
"tags": [],
"nodes": [
{
"id": "daf34daa-19e5-42a8-b820-5aa3d78c29a4",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-528,
-112
],
"webhookId": "56b65a7f-0698-4e99-81eb-fd87e0cb5bfa",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "85be9290-50ac-457e-9fa1-0c00a88667da",
"name": "AI 代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
160,
-112
],
"parameters": {
"text": "={{ $('When chat message received').item.json.chatInput }}",
"options": {
"returnIntermediateSteps": true
},
"promptType": "define"
},
"typeVersion": 2.1
},
{
"id": "0721d812-2dc6-4069-87e6-844b8f94214b",
"name": "模型选择器",
"type": "@n8n/n8n-nodes-langchain.modelSelector",
"position": [
80,
128
],
"parameters": {
"rules": {
"rule": [
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "976d83bb-7e9e-4aab-9722-25a9e238164f",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.request_type }}",
"rightValue": "coding"
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1e68688d-73fe-47c1-9b35-a1e226220bcd",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.request_type }}",
"rightValue": "reasoning"
}
]
},
"modelIndex": 2
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "61d58197-db59-4cd7-bc41-bbeaf5e7b069",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.request_type }}",
"rightValue": "general"
}
]
},
"modelIndex": 3
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "fca2ec99-fd1d-458f-9919-73bfbba55c4f",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.request_type }}",
"rightValue": "search"
}
]
},
"modelIndex": 4
}
]
},
"numberInputs": 4
},
"typeVersion": 1
},
{
"id": "449b0bae-3749-493d-b6f6-dad155537bc9",
"name": "多表:您可以连接多个表以实现有组织的数据结构",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-80,
32
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"request_type\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
},
"typeVersion": 1.3
},
{
"id": "03339701-3ed8-43c9-a490-3ebca30d39bb",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
400,
128
],
"parameters": {
"sessionKey": "={{ $('When chat message received').item.json.sessionId }}",
"sessionIdType": "customKey"
},
"typeVersion": 1.3
},
{
"id": "1d86d306-bbdd-45b0-9b96-fce0cbcdc0a0",
"name": "请求类型",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
-288,
-112
],
"parameters": {
"batching": {},
"messages": {
"messageValues": [
{
"message": "=Your task is to classify the type of request you receive as input.\nYou must provide the following output:\n- general: if it is a general request\n- reasoning: if it is a reasoning request\n- coding: if it is a request related to code development\n- google: if it is a request that involves the use of Google tools"
}
]
},
"hasOutputParser": true
},
"typeVersion": 1.7
},
{
"id": "f49883cd-fc48-4c26-8596-6267beb74c3d",
"name": "Opus 4",
"type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
"position": [
-64,
352
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "claude-sonnet-4-20250514",
"cachedResultName": "Claude 4 Sonnet"
},
"options": {}
},
"credentials": {
"anthropicApi": {
"id": "NNTZAD0Gmf7lcniq",
"name": "Anthropic account"
}
},
"typeVersion": 1.3
},
{
"id": "0f19c20b-298b-45d8-b855-3a92c0dac675",
"name": "Gemini Thinking Pro",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
80,
352
],
"parameters": {
"options": {},
"modelName": "models/gemini-2.0-flash-thinking-exp"
},
"credentials": {
"googlePalmApi": {
"id": "AaNPKXAphyMzRgfA",
"name": "Google Gemini(PaLM) (Eure)"
}
},
"typeVersion": 1
},
{
"id": "d2676326-64f2-47db-84f4-17fbf194d31b",
"name": "GPT 4.1 mini",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
224,
352
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "TefveNaDaMERl1hY",
"name": "OpenAi account (Eure)"
}
},
"typeVersion": 1.2
},
{
"id": "1f8d38d9-0298-4588-a763-7fac0132edf5",
"name": "Perplexity",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
352,
352
],
"parameters": {
"model": "perplexity/sonar",
"options": {}
},
"credentials": {
"openRouterApi": {
"id": "pb06rfB4xmxzVe3Q",
"name": "OpenRouter"
}
},
"typeVersion": 1
},
{
"id": "fc7a67be-d46a-4fec-b1d2-9f8ce3b86462",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-320,
48
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "TefveNaDaMERl1hY",
"name": "OpenAi account (Eure)"
}
},
"typeVersion": 1.2
},
{
"id": "de2fc53a-bf97-475a-b978-0cde88483ee0",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-528,
-416
],
"parameters": {
"width": 624,
"height": 256,
"content": "## AI 编排器:基于输入类型动态选择模型"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "d852ebdf-2860-4611-a58e-e58c8cd4cc35",
"connections": {
"Opus 4": {
"ai_languageModel": [
[
{
"node": "Model Selector",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Perplexity": {
"ai_languageModel": [
[
{
"node": "Model Selector",
"type": "ai_languageModel",
"index": 3
}
]
]
},
"GPT 4.1 mini": {
"ai_languageModel": [
[
{
"node": "Model Selector",
"type": "ai_languageModel",
"index": 2
}
]
]
},
"Request Type": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Model Selector": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Request Type",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Gemini Thinking Pro": {
"ai_languageModel": [
[
{
"node": "Model Selector",
"type": "ai_languageModel",
"index": 1
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Request Type",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Request Type",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个中级难度的工作流,适用于Engineering、AI Chatbot等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
代理 AI Anthropic Opus 4 和 Sonnet 4
Anthropic AI 代理:Claude Sonnet 4 和 Opus 4,具备思考和网络搜索工具
Agent
Http Request Tool
Tool Think
+6
11 节点Davide
Engineering
Pipedream 的 MCP 服务器
使用GPT-4和Pipedream构建可扩展AI聊天机器人:集成Calendly和Gmail
Agent
Chat Trigger
Lm Chat Open Ai
+3
8 节点Davide
Support Chatbot
使用OpenRouter的自动化AI路由
通过OpenRouter实现查询优化的动态AI模型路由
Agent
Chat Trigger
Lm Chat Open Router
+2
7 节点Davide
Engineering
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
Other
使用Claude Opus 4从自然语言生成完整工作流
使用Claude Opus 4从自然语言生成完整工作流
N8n
Set
Google Drive
+9
17 节点Electrabot
Engineering
从非结构化数据到结构化数据
行动计划:使用OpenAI模型处理邮件源和数据表
Data Table
Gmail Trigger
Data Table Tool
+8
16 节点Davide
Document Extraction
工作流信息
难度等级
中级
节点数量12
分类2
节点类型11
作者
Davide
@n3witaliaFull-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at info@n3w.it or add me on Linkedin.com/in/davideboizza
外部链接
在 n8n.io 上查看 →
分享此工作流