{
  "id": "9tESvGqGhSgQFPjF",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "n8n AI Council",
  "tags": [
    {
      "id": "URH8Z7hv6LzKCKnt",
      "name": "AI",
      "createdAt": "2025-12-10T14:25:01.584Z",
      "updatedAt": "2025-12-10T14:25:01.584Z"
    },
    {
      "id": "u3AOoAbD80e3kNro",
      "name": "Multi-modal",
      "createdAt": "2025-12-10T14:25:04.916Z",
      "updatedAt": "2025-12-10T14:25:04.916Z"
    },
    {
      "id": "XxznXQwOfWXPBWjw",
      "name": "Peer review",
      "createdAt": "2025-12-10T14:25:26.009Z",
      "updatedAt": "2025-12-10T14:25:26.009Z"
    },
    {
      "id": "RdCDIqrxijzthfXN",
      "name": "OpenRouter",
      "createdAt": "2025-12-10T14:25:28.680Z",
      "updatedAt": "2025-12-10T14:25:28.680Z"
    }
  ],
  "nodes": [
    {
      "id": "chat-trigger",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        80,
        944
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.4
    },
    {
      "id": "model-gemini",
      "name": "Gemini Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        912,
        480
      ],
      "parameters": {
        "model": "google/gemini-2.0-flash-001",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "merge-answers",
      "name": "Merge Answers",
      "type": "n8n-nodes-base.merge",
      "position": [
        848,
        928
      ],
      "parameters": {
        "numberInputs": 4
      },
      "typeVersion": 3.2
    },
    {
      "id": "aggregate-answers",
      "name": "Aggregate Answers",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1008,
        960
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "allAnswers"
      },
      "typeVersion": 1
    },
    {
      "id": "merge-reviews",
      "name": "Merge Reviews",
      "type": "n8n-nodes-base.merge",
      "position": [
        1648,
        928
      ],
      "parameters": {
        "numberInputs": 4
      },
      "typeVersion": 3.2
    },
    {
      "id": "aggregate-reviews",
      "name": "Aggregate Reviews",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1872,
        960
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "allReviews"
      },
      "typeVersion": 1
    },
    {
      "id": "agent-final",
      "name": "Final Analysis Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2096,
        960
      ],
      "parameters": {
        "text": "=You are the final arbitrator for the AI Council. Based on all the peer reviews below, synthesize a comprehensive final answer that:\n\nProvides the shortest and best possible answer to the original question\n\nOriginal question: {{ $('Chat Trigger').item.json.chatInput }}\n\nOriginal answers:\n1) {{ $json.allAnswers[0].text }}\n2) {{ $json.allAnswers[1].text }}\n3) {{ $json.allAnswers[2].text }}\n4) {{ $json.allAnswers[3].text }}\n\nPeer Reviews:\n1) {{ $json.allReviews[0].text }}\n2) {{ $json.allReviews[1].text }}\n3) {{ $json.allReviews[2].text }}\n4) {{ $json.allReviews[3].text }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "2c74ce56-4ec9-44d9-bab2-cfc29d0c5b28",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        240
      ],
      "parameters": {
        "width": 384,
        "height": 1472,
        "content": "## Ask Question\nEnter your question as you would normally ask an LLM."
      },
      "typeVersion": 1
    },
    {
      "id": "3a1eb084-f416-43cd-94ba-3487393e26c8",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        832
      ],
      "parameters": {
        "color": 2,
        "width": 368,
        "height": 336,
        "content": "## Combine Answers\nPut all answers in a combined (anonymous) list.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "141ddd28-b2db-4a29-b62c-e8061d64b928",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        240
      ],
      "parameters": {
        "color": 3,
        "width": 384,
        "height": 1472,
        "content": "## Individual Model Answers\nEach model provides an answer to your question. You can have as many nodes as you want, do note that these are executed in sequence so overall duration will increase with each model."
      },
      "typeVersion": 1
    },
    {
      "id": "f61dc5e2-f7b0-48fd-b446-2fe0ec96faf9",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        256
      ],
      "parameters": {
        "color": 4,
        "width": 384,
        "height": 1456,
        "content": "## Peer Reviews\nEach model reviews all answers (including their own), without knowing where the answer comes from."
      },
      "typeVersion": 1
    },
    {
      "id": "d9443b31-9aef-4a7b-b1c0-818696a88a2f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        640
      ],
      "parameters": {
        "color": 5,
        "width": 784,
        "height": 752,
        "content": "## Analysis and Final Answer\nA final AI node that combines the reviews and provides you with a final answer.\n\nIt is currently configured to just provide the shortest answer to the original question, but you can also instruct it to provide the reasoning behind it, include the pros/cons of each variant etc."
      },
      "typeVersion": 1
    },
    {
      "id": "model-deepseek",
      "name": "Mistral Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        912,
        1584
      ],
      "parameters": {
        "model": "mistralai/mistral-nemo",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "model-claude",
      "name": "Gemma Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        912,
        1360
      ],
      "parameters": {
        "model": "google/gemma-3n-e4b-it",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "model-gpt4",
      "name": "Llama Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        912,
        688
      ],
      "parameters": {
        "model": "meta-llama/llama-3.2-1b-instruct",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c754839b-030a-441d-ad38-a62faa8d6c50",
      "name": "Answer Agent #4",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        432,
        1440
      ],
      "parameters": {
        "batching": {}
      },
      "typeVersion": 1.7
    },
    {
      "id": "5d9d0aa0-761e-4683-9f5e-d1116517e7a7",
      "name": "Answer Agent #3",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        432,
        1216
      ],
      "parameters": {
        "batching": {}
      },
      "typeVersion": 1.7
    },
    {
      "id": "b8d0be20-35d0-4cf4-b86e-80a5c5876af1",
      "name": "Answer Agent #2",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        416,
        624
      ],
      "parameters": {
        "batching": {}
      },
      "typeVersion": 1.7
    },
    {
      "id": "acf0f9d5-8f4b-4854-bdbd-014190d54f10",
      "name": "Answer Agent #1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        416,
        400
      ],
      "parameters": {
        "batching": {}
      },
      "typeVersion": 1.7
    },
    {
      "id": "fe7d0b5a-8b90-4cb5-a02c-6fa4570f9503",
      "name": "Review Agent #1",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1232,
        400
      ],
      "parameters": {
        "text": "=You are a critical peer reviewer. Review all the answers provided below and provide:\n1. Pros of each answer\n2. Cons of each answer\n3. Overall assessment\n\nOriginal question: {{ $('Chat Trigger').item.json.chatInput }}\n\nAnswers to review:\n1) {{ $json.allAnswers[0].text }}\n2) {{ $json.allAnswers[1].text }}\n3) {{ $json.allAnswers[2].text }}\n4) {{ $json.allAnswers[3].text }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "584948fb-9cb0-44c2-93f8-20e0ceaf630b",
      "name": "Review Agent #2",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1232,
        624
      ],
      "parameters": {
        "text": "=You are a critical peer reviewer. Review all the answers provided below and provide:\n1. Pros of each answer\n2. Cons of each answer\n3. Overall assessment\n\nOriginal question: {{ $('Chat Trigger').item.json.chatInput }}\n\nAnswers to review:\n1) {{ $json.allAnswers[0].text }}\n2) {{ $json.allAnswers[1].text }}\n3) {{ $json.allAnswers[2].text }}\n4) {{ $json.allAnswers[3].text }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "eb3a8ac1-7b88-4e7b-99ea-910fb1c9443e",
      "name": "Review Agent #3",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1248,
        1200
      ],
      "parameters": {
        "text": "=You are a critical peer reviewer. Review all the answers provided below and provide:\n1. Pros of each answer\n2. Cons of each answer\n3. Overall assessment\n\nOriginal question: {{ $('Chat Trigger').item.json.chatInput }}\n\nAnswers to review:\n1) {{ $json.allAnswers[0].text }}\n2) {{ $json.allAnswers[1].text }}\n3) {{ $json.allAnswers[2].text }}\n4) {{ $json.allAnswers[3].text }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "e2cd5192-d703-4382-99e6-19f4e6af41fe",
      "name": "Review Agent #4",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1248,
        1424
      ],
      "parameters": {
        "text": "=You are a critical peer reviewer. Review all the answers provided below and provide:\n1. Pros of each answer\n2. Cons of each answer\n3. Overall assessment\n\nOriginal question: {{ $('Chat Trigger').item.json.chatInput }}\n\nAnswers to review:\n1) {{ $json.allAnswers[0].text }}\n2) {{ $json.allAnswers[1].text }}\n3) {{ $json.allAnswers[2].text }}\n4) {{ $json.allAnswers[3].text }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "1a64df00-f262-4bff-a013-340125f61408",
      "name": "Deepseek R1 model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        2096,
        1232
      ],
      "parameters": {
        "model": "deepseek/deepseek-r1",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2cf3a499-df80-4872-b819-450346c84209",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 1472,
        "content": "## AI Council: Multi-Model Consensus with Peer Review\n\n**Inspired by [Andrej Karpathy's LLM Council](https://github.com/karpathy/llm-council)**\n\nThis workflow creates a \"council\" of AI models that independently answer your question, then peer-review each other's responses before a final arbiter synthesizes the best answer.\n\n---\n\n## Who is this for?\n\n- Researchers wanting more robust AI-generated answers\n- Developers exploring multi-model architectures\n- Anyone seeking higher-quality responses through AI consensus\n- Teams evaluating different LLM capabilities side-by-side\n\n---\n\n## How it works\n\n1. **Ask a Question** \u2014 Submit your query via the Chat Trigger\n2. **Individual Answers** \u2014 Four different models (Gemini, Llama, Gemma, Mistral) independently generate responses\n3. **Peer Review** \u2014 Each model reviews ALL answers, identifying pros, cons, and overall assessment\n4. **Final Synthesis** \u2014 DeepSeek R1 analyzes all peer reviews and produces a refined, consensus-based final answer\n\n---\n\n## Setup Instructions\n\n### Prerequisites\n- Access to an LLM (e.g. [OpenRouter](https://openrouter.ai/) account with API credits)\n\n### Steps\n1. **Create OpenRouter credentials** in n8n:\n   - Go to *Settings \u2192 Credentials \u2192 Add Credential*\n   - Select \"OpenRouter\" and paste your API key\n2. **Connect all model nodes** to your OpenRouter credential. In this example I used Gemini, Llama, Gemma, Mistral and Deepseek, but you can use whatever you want. You can also use the same models, but change their parameters. Play around to find out what suits you best.\n3. **Activate the workflow** and open the Chat interface to test\n\n---\n\n## Customization Ideas\n\n- Swap models via OpenRouter's model selector (e.g., use Claude, GPT-4, etc.)\n- Adjust the peer review prompt for domain-specific evaluation criteria\n- Add memory nodes for multi-turn conversations\n- Connect to Slack/Discord instead of the Chat Trigger\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "timezone": "Europe/Amsterdam",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false,
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true,
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all"
  },
  "versionId": "410b05ce-d9d9-45d1-83ff-00978f686ccd",
  "connections": {
    "Gemma Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer Agent #3",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Review Agent #3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Llama Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer Agent #2",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Review Agent #2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "Answer Agent #1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Answer Agent #2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Answer Agent #3",
            "type": "main",
            "index": 0
          },
          {
            "node": "Answer Agent #4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer Agent #1",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Review Agent #1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Merge Answers": {
      "main": [
        [
          {
            "node": "Aggregate Answers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Reviews": {
      "main": [
        [
          {
            "node": "Aggregate Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer Agent #4",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Review Agent #4",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Answer Agent #1": {
      "main": [
        [
          {
            "node": "Merge Answers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer Agent #2": {
      "main": [
        [
          {
            "node": "Merge Answers",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Answer Agent #3": {
      "main": [
        [
          {
            "node": "Merge Answers",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Answer Agent #4": {
      "main": [
        [
          {
            "node": "Merge Answers",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Review Agent #1": {
      "main": [
        [
          {
            "node": "Merge Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Review Agent #2": {
      "main": [
        [
          {
            "node": "Merge Reviews",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Review Agent #3": {
      "main": [
        [
          {
            "node": "Merge Reviews",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Review Agent #4": {
      "main": [
        [
          {
            "node": "Merge Reviews",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Aggregate Answers": {
      "main": [
        [
          {
            "node": "Review Agent #4",
            "type": "main",
            "index": 0
          },
          {
            "node": "Review Agent #3",
            "type": "main",
            "index": 0
          },
          {
            "node": "Review Agent #2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Review Agent #1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Reviews": {
      "main": [
        [
          {
            "node": "Final Analysis Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deepseek R1 model": {
      "ai_languageModel": [
        [
          {
            "node": "Final Analysis Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Final Analysis Agent": {
      "main": [
        []
      ]
    }
  }
}