AutomationFlowsAI & RAG › Generate and Evaluate AI Prompts with Gemini, Openrouter, Groq, Cohere and…

Generate and Evaluate AI Prompts with Gemini, Openrouter, Groq, Cohere and…

Original n8n title: Generate and Evaluate AI Prompts with Gemini, Openrouter, Groq, Cohere and Supabase

ByKanishka Shrivastava @kanishka-shrivastava on n8n.io

This workflow receives a goal via webhook, generates three prompt candidates using Google Gemini, OpenRouter, and Groq, has Cohere evaluate and select the best prompt, then returns the result to the caller and stores the goal and winning prompt in Supabase. Receives a POST…

Webhook trigger★★★★☆ complexityAI-powered20 nodesGoogle Gemini ChatOpenRouter ChatGroq ChatCohere ChatSupabaseAgent
AI & RAG Trigger: Webhook Nodes: 20 Complexity: ★★★★☆ AI nodes: yes Added:
Generate and Evaluate AI Prompts with Gemini, Openrouter, Groq, Cohere and… — n8n workflow card showing Google Gemini Chat, OpenRouter Chat, Groq Chat integration

This workflow corresponds to n8n.io template #16063 — we link there as the canonical source.

This workflow follows the Agent → Google Gemini Chat recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "naNY3MKwkrO4vLci",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Generate best AI prompt using multi-model evaluation and save to Supabase",
  "tags": [],
  "nodes": [
    {
      "id": "4abe0387-7838-42cf-a812-0d5f32751b6c",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -240,
        0
      ],
      "parameters": {
        "path": "e8c4d1a4-406e-4de7-bb22-b652d028c943",
        "options": {
          "allowedOrigins": "*",
          "responseHeaders": {
            "entries": [
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              },
              {
                "name": "Access-Control-Allow-Methods",
                "value": "POST, OPTIONS"
              },
              {
                "name": "Access-Control-Allow-Headers",
                "value": "Content-Type"
              }
            ]
          }
        },
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c43c2cdd-bcfc-4c2f-be0d-1e8379de35f7",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        336,
        -160
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6e63054e-a2ad-4466-9c87-ebf43056288a",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        336,
        192
      ],
      "parameters": {
        "model": "liquid/lfm-2.5-1.2b-instruct:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "bff3d33e-1fb4-4481-b304-e7ef432bf826",
      "name": "Groq Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        336,
        576
      ],
      "parameters": {
        "model": "llama-3.3-70b-versatile",
        "options": {}
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "576ee0a5-4c3e-4b4d-b43a-13980b6e9743",
      "name": "Cohere Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatCohere",
      "position": [
        1264,
        288
      ],
      "parameters": {
        "model": "c4ai-aya-expanse-32b",
        "options": {}
      },
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "68719c69-9e57-41ba-a222-2528f40e9d2d",
      "name": "Create a row",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1920,
        0
      ],
      "parameters": {
        "tableId": "prompts",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "goal",
              "fieldValue": "={{ $('Webhook').item.json.body.goal }}"
            },
            {
              "fieldId": "best_prompt",
              "fieldValue": "={{ $json.output }}"
            }
          ]
        }
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "56c7c9d1-b9fc-496a-a362-3f4df47c9fa4",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        768,
        -16
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "37b36d97-3b1b-46df-b729-2ffb8841e75f",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1680,
        0
      ],
      "parameters": {
        "options": {},
        "respondWith": "allIncomingItems"
      },
      "typeVersion": 1.5
    },
    {
      "id": "5413aef5-15b1-4ca7-8007-2d9d7c053cbb",
      "name": "Creative Prompt Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        336,
        -336
      ],
      "parameters": {
        "text": "={{$json.goal}}",
        "options": {
          "systemMessage": "You are a creative AI prompt engineer.\n\nFocus on:\n- storytelling\n- viral ideas\n- creativity\n\nGenerate the best prompt possible."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "d4728867-d16d-4374-a298-ff6148a12031",
      "name": "Marketing Prompt Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        336,
        0
      ],
      "parameters": {
        "text": "={{$json.goal}}",
        "options": {
          "systemMessage": "You are a marketing strategist.\n\nFocus on:\n- engagement\n- attention\n- conversions\n- audience retention"
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "fd23a0d3-f2b7-4a98-bf15-982656441cde",
      "name": "Technical Prompt Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        336,
        352
      ],
      "parameters": {
        "text": "={{$json.goal}}",
        "options": {
          "systemMessage": "You are an elite technical prompt engineer.\n\nFocus on:\n- precision\n- structure\n- AI optimization"
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "a33ca1f3-2e20-4df9-97a8-8a789be55b3e",
      "name": "Best Prompt Evaluator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1264,
        0
      ],
      "parameters": {
        "text": "=Creative: {{ $json.creative }}\nMarketing: {{ $json.marketing }}\nTechnical: {{ $json.technical }}",
        "options": {
          "systemMessage": "You are an elite AI evaluator.\n\nCompare all prompts carefully.\n\nChoose the BEST prompt.\n\nReturn JSON format:\n\n{\n  \"best_prompt\":\"\",\n  \"reason\":\"\"\n}"
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "22d19504-c9b2-4c08-a657-d04a4e333766",
      "name": "Extract Goal",
      "type": "n8n-nodes-base.code",
      "position": [
        16,
        0
      ],
      "parameters": {
        "jsCode": "const goal = $json.body.goal;\n\nreturn [\n  {\n    goal\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "4af45d4e-95a4-4821-8a79-4a762297b8ab",
      "name": "Combine Agent Outputs",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        0
      ],
      "parameters": {
        "jsCode": "const creative = $('Creative Prompt Agent').first().json.output;\nconst marketing = $('Marketing Prompt Agent').first().json.output;\nconst technical = $('Technical Prompt Agent').first().json.output;\n\nreturn [{ json: { creative, marketing, technical } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "a494d3e2-c627-4c95-8ca3-f13c32d11f6c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -656
      ],
      "parameters": {
        "color": 6,
        "width": 544,
        "height": 512,
        "content": "## \ud83e\udde0 AI Prompt Generator \n Multi-Model Evaluation\n\nThis workflow takes a user's goal and generates the best possible \nprompt by running it through 3 specialized AI agents in parallel, \nthen evaluating all outputs to pick the winner.\n\n**Flow:**\n1. Webhook receives a POST request with { \"goal\": \"...\" }\n2. Three agents process it simultaneously:\n   - Creative Agent (Gemini) \u2192 storytelling & viral ideas\n   - Marketing Agent (OpenRouter) \u2192 engagement & conversions\n   - Technical Agent (Groq) \u2192 precision & AI optimization\n3. All outputs are merged and sent to an Evaluator (Cohere)\n4. Best prompt is returned via webhook + saved to Supabase\n\n**Required credentials:**\n- Google Gemini API\n- OpenRouter API\n- Groq API\n- Cohere API\n- Supabase (table: prompts | columns: goal, best_prompt)"
      },
      "typeVersion": 1
    },
    {
      "id": "b1a4b870-8f95-4b2f-8d29-957a00403ce4",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -144
      ],
      "parameters": {
        "color": "#00332B",
        "width": 304,
        "height": 128,
        "content": "STEP 1 \n Entry Point\nSend a POST request with:\n{ \"goal\": \"your prompt goal here\" }"
      },
      "typeVersion": 1
    },
    {
      "id": "1538025d-9b75-4977-a2cf-7fa4ff36d533",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -480
      ],
      "parameters": {
        "color": "#00332B",
        "width": 368,
        "height": 128,
        "content": "STEP 2 \n Parallel Generation\nThree agents run simultaneously, each \nwith a different expert perspective."
      },
      "typeVersion": 1
    },
    {
      "id": "99afc24f-7346-44a8-85fd-b4c276dad220",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -176
      ],
      "parameters": {
        "color": "#00332B",
        "width": 352,
        "height": 144,
        "content": "STEP 3 \n Combine Outputs\nAll three responses are merged and \nstructured for evaluation."
      },
      "typeVersion": 1
    },
    {
      "id": "c01c55d9-2dcd-49b8-a361-34268d385e50",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        -176
      ],
      "parameters": {
        "color": "#00332B",
        "width": 352,
        "height": 144,
        "content": "STEP 4 \nEvaluation\nCohere compares all three prompts \nand picks the best one with a reason."
      },
      "typeVersion": 1
    },
    {
      "id": "f7e9d4a4-a95a-4a68-9432-62e2b4fcd749",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1648,
        -176
      ],
      "parameters": {
        "color": "#00332B",
        "width": 336,
        "height": 144,
        "content": "STEP 5 \nSave & Respond\nBest prompt is returned to the caller \nand stored in Supabase for future use."
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "binaryMode": "separate",
    "callerPolicy": "workflowsFromSameOwner",
    "timeSavedMode": "fixed",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "32e09501-56ec-472f-b826-752386891847",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Combine Agent Outputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract Goal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Goal": {
      "main": [
        [
          {
            "node": "Creative Prompt Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Marketing Prompt Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Technical Prompt Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Technical Prompt Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Cohere Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Best Prompt Evaluator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Respond to Webhook": {
      "main": [
        [
          {
            "node": "Create a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Best Prompt Evaluator": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Agent Outputs": {
      "main": [
        [
          {
            "node": "Best Prompt Evaluator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Creative Prompt Agent": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Marketing Prompt Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Marketing Prompt Agent": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Technical Prompt Agent": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Creative Prompt Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow receives a goal via webhook, generates three prompt candidates using Google Gemini, OpenRouter, and Groq, has Cohere evaluate and select the best prompt, then returns the result to the caller and stores the goal and winning prompt in Supabase. Receives a POST…

Source: https://n8n.io/workflows/16063/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

leads. Uses supabase, gmail, formTrigger, httpRequest. Webhook trigger; 62 nodes.

Supabase, Gmail, Form Trigger +13
AI & RAG

⏺ 🚀 How it works

Agent, Anthropic Chat, Output Parser Structured +6
AI & RAG

Arvifund - Supabase (Fixed v2). Uses httpRequest, telegram, googleSheets, telegramTrigger. Event-driven trigger; 90 nodes.

HTTP Request, Telegram, Google Sheets +9
AI & RAG

Arvifund - Supabase (Fixed v4). Uses httpRequest, telegram, googleSheets, telegramTrigger. Event-driven trigger; 90 nodes.

HTTP Request, Telegram, Google Sheets +9
AI & RAG

Arvifund - Supabase (Fixed v3). Uses httpRequest, telegram, googleSheets, telegramTrigger. Event-driven trigger; 90 nodes.

HTTP Request, Telegram, Google Sheets +9