【n8n系列教程3】Gemini Pro自由!实现真正的轮询API Key,多账户轮询,高并发

请先看完免费部署教程:

也可以使用官网的,但官网的仅14天试用,可以用临时邮箱薅

工作流展示

:wave:工作流JSON代码 (复制粘贴导入)

{
  "name": "Flux轮询",
  "nodes": [
    {
      "parameters": {
        "jsCode": "// 获取全局的静态数据对象\nconst workflowStaticData = $getWorkflowStaticData('global');\n\n// 读取或初始化当前索引\nlet currentIndex = workflowStaticData.currentIndex || 0;\n\n// 更新索引:如果达到16则重置为0,否则加1\ncurrentIndex = (currentIndex + 1) % 16;\n\n// 保存新的索引到全局静态数据\nworkflowStaticData.currentIndex = currentIndex;\n\n// 输出选中的API Key\nreturn {\n  json: {\n    currentIndex\n  }\n};\n"
      },
      "id": "0e226ee3-60e0-4d15-a987-d374bd99774f",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2560,
        2680
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "dfb52da7-0add-4346-9b1c-c33810cb54c1",
      "name": "SerpAPI",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1560,
        320
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "9068b8b0-665a-48b2-99b9-acbc5b0862ca",
      "name": "Gemini Chat",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1720,
        320
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "YFFWuO7oyYsy3sPI",
          "name": "Google Gemini(PaLM) Api account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "c9452245-9774-435a-a1a9-0121d100ed27",
      "name": "SerpAPI1",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1580,
        600
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "63f036d4-639d-4597-a866-dabfcb1ee7e3",
      "name": "Gemini Chat1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1740,
        600
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "vnGfDwgNjveLfGXc",
          "name": "Google Gemini(PaLM) Api account 2"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "103be00c-a063-47bf-9d5a-9f5b7a905bdf",
      "name": "SerpAPI2",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1580,
        900
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "324cd203-1407-4108-a1a5-cc741704c6c6",
      "name": "Gemini Chat2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1740,
        900
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "QuaJL85K3A1iWcYg",
          "name": "Google Gemini(PaLM) Api account 3"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "86575065-e6d6-429c-929b-d7833cc86482",
      "name": "SerpAPI3",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1560,
        1200
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "e56c916e-022d-4691-ba97-7d9eb4054935",
      "name": "Gemini Chat3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1720,
        1200
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "UfZRTL45gYb4TiMq",
          "name": "Google Gemini(PaLM) Api account 4"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "149023dd-972a-4a82-a5dc-4d327d767658",
      "name": "SerpAPI4",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1540,
        1520
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "2eb58763-d1a0-4a03-a025-e73bc5446f95",
      "name": "Gemini Chat4",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1700,
        1520
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "oCB6YXFphzw7uRHW",
          "name": "Google Gemini(PaLM) Api account 5"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "75375907-3d4f-4e20-bf56-f93853f11476",
      "name": "SerpAPI5",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1560,
        1820
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "5250690a-1ae1-4411-80de-79fa963d965b",
      "name": "Gemini Chat5",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1720,
        1820
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "64VtI8Qjw1oX6S0T",
          "name": "Google Gemini(PaLM) Api account 6"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "ce373784-0ef9-4795-99ec-ea3aaf422e34",
      "name": "SerpAPI6",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1580,
        2100
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "bb815c96-926a-483a-9c63-31befe5a0c7c",
      "name": "Gemini Chat6",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1740,
        2100
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "0rs2mNJDH9AV77ci",
          "name": "Google Gemini(PaLM) Api account 7"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "7d09fee6-4f6b-49e4-8655-624deca0208c",
      "name": "SerpAPI7",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1580,
        2400
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "6578b4f4-7fc9-4bd4-8e04-e8249abfb6ef",
      "name": "Gemini Chat7",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1740,
        2400
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "PBRj0QCfKeDgHjBC",
          "name": "Google Gemini(PaLM) Api account 8"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "ab344093-1936-4cee-9890-8cbe6f4e8ffc",
      "name": "SerpAPI8",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1560,
        2700
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "57aec6af-f3fe-48cf-b52f-418251e60801",
      "name": "Gemini Chat8",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1720,
        2700
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "sNdiFlXq6qx09QnC",
          "name": "Google Gemini(PaLM) Api account 9"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "be546413-cb65-4a8a-bc30-96a1566a627b",
      "name": "SerpAPI9",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1540,
        3020
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "07bcd561-23f9-4bb0-ae2c-bd4b79a2b8af",
      "name": "Gemini Chat9",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1700,
        3020
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "3tv3c4GMaR4o0yHP",
          "name": "Google Gemini(PaLM) Api account 10"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "334a8abb-f2b6-4759-8a35-138f212dcf77",
      "name": "SerpAPI10",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1540,
        3320
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "e4c4452e-3b0a-46cc-9d96-126eb2e15cfc",
      "name": "Gemini Chat10",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1700,
        3320
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "DiFTha03ZOcs8aKy",
          "name": "Google Gemini(PaLM) Api account 11"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "5ff3b3b3-ba10-4310-8518-1986227ad524",
      "name": "SerpAPI11",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1560,
        3600
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "07ea9997-e829-4e06-8de3-c529161f8937",
      "name": "Gemini Chat11",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1720,
        3600
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "AgfU7vzQO3gsxjw7",
          "name": "Google Gemini(PaLM) Api account 12"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "eaa7d6d4-b91d-49ce-8c47-4f8662d8777b",
      "name": "SerpAPI12",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1560,
        3900
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "33acfc20-ec63-48c6-8f29-b58bc95ff257",
      "name": "Gemini Chat12",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1720,
        3900
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "xK1gRMLEVbO3axpM",
          "name": "Google Gemini(PaLM) Api account 13"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "ec09c74c-bbcd-4d56-a94e-eae30c2c4a3b",
      "name": "SerpAPI13",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1540,
        4200
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "b085bdcf-8245-4ab5-bba9-0fe91a27765e",
      "name": "Gemini Chat13",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1700,
        4200
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "UJY6Cp7d7XPPcvbe",
          "name": "Google Gemini(PaLM) Api account 14"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "3a692e6f-550d-416f-89a5-14a47db06767",
      "name": "SerpAPI14",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1520,
        4520
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "e4c83702-8c76-4e67-8278-338cbad991d3",
      "name": "Gemini Chat14",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1680,
        4520
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "8HGiAi95Ldj7a6zy",
          "name": "Google Gemini(PaLM) Api account 15"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "7a8ea998-682c-4241-92e6-ee51bb7e2ab0",
      "name": "SerpAPI15",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "position": [
        -1520,
        4840
      ],
      "typeVersion": 1,
      "credentials": {
        "serpApi": {
          "id": "3Wi19nMgSjvuUBS5",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {
        "modelName": "models/gemini-1.5-pro-002",
        "options": {}
      },
      "id": "9a4b307c-d788-4642-9dfa-64290ab55fc0",
      "name": "Gemini Chat15",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -1680,
        4840
      ],
      "credentials": {
        "googlePalmApi": {
          "id": "VgsOF9L88RsAdPPP",
          "name": "Google Gemini(PaLM) Api account 16"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const output = $json.output.replace(/\\r?\\n/g, '\\\\n');\n\n// 输出选中的API Key和修改后的文本\nreturn {\n  json: {\n    output\n  }\n};"
      },
      "id": "da3e162b-768d-46d8-bd50-7dc380599aad",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -580,
        2620
      ],
      "executeOnce": false
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n    \"id\": \"\",\n    \"model\": \"\",\n    \"usage\": {\n        \"prompt_tokens\": 1,\n        \"completion_tokens\": 1,\n        \"total_tokens\": 1\n    },\n    \"choices\": [\n        {\n            \"message\": {\n                \"role\": \"assistant\",\n                \"content\": \"{{ $json.output }}\"\n            },\n            \"finish_reason\": \"stop\",\n            \"index\": 0\n        }\n    ]\n}",
        "options": {}
      },
      "id": "be9b6f9c-b17a-4e64-b261-08aa1c87c0f0",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        -360,
        2620
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "310ccdb8-e5a3-4619-90e2-cda6934b9a3f",
      "name": "Gemini AI轮询",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1740,
        160
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "b257ddd3-7386-4cac-a3fc-51640e35377a",
      "name": "Gemini AI轮询1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1760,
        440
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "504c89ab-7b25-45a5-9235-28db809a3b94",
      "name": "Gemini AI轮询2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1760,
        740
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "12b0fc84-35bd-488e-bbbd-5d2382edcd96",
      "name": "Gemini AI轮询3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1740,
        1040
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "2859a54e-5363-4e9f-8a60-c51724ff2fb6",
      "name": "Gemini AI轮询4",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1720,
        1360
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "d46d9ace-1e84-4708-bc8a-eafb77869526",
      "name": "Gemini AI轮询5",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1740,
        1660
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "5676159e-3a16-4065-896e-54eeb0806b44",
      "name": "Gemini AI轮询6",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1760,
        1940
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "8afe4329-7b97-4a30-a1df-97297f40f90d",
      "name": "Gemini AI轮询7",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1760,
        2240
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "5d21ccf7-ba38-4245-87c1-ccc07ad1e378",
      "name": "Gemini AI轮询8",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1740,
        2540
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "466b4cd3-e0a0-4161-a24e-2362c2c8ab46",
      "name": "Gemini AI轮询9",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1720,
        2860
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "d02a8591-cda2-4754-ba47-dec9ca37915a",
      "name": "Gemini AI轮询10",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1720,
        3160
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "b480f519-19fe-4737-aaf2-6b9eb78ba8d9",
      "name": "Gemini AI轮询11",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1740,
        3440
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "91e1f628-45a5-421a-bd6d-e367d49dd409",
      "name": "Gemini AI轮询12",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1740,
        3740
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "283d5378-b1ac-4282-a27e-882b40ae25b3",
      "name": "Gemini AI轮询13",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1720,
        4040
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "10d82ef4-61d2-4575-95bb-a3f3fa0679a1",
      "name": "Gemini AI轮询14",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1700,
        4360
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=对话记录如下:请回答最后一个角色为user的问题\n{{ $('Webhook').item.json.body.messages[1].role }}:\n{{ $('Webhook').item.json.body.messages[1].content }}\n{{ $('Webhook').item.json.body.messages[2].role }}:\n{{ $('Webhook').item.json.body.messages[2].content }}\n{{ $('Webhook').item.json.body.messages[3].role }}:\n{{ $('Webhook').item.json.body.messages[3].content }}\n{{ $('Webhook').item.json.body.messages[4].role }}:\n{{ $('Webhook').item.json.body.messages[4].content }}\n{{ $('Webhook').item.json.body.messages[5].role }}:\n{{ $('Webhook').item.json.body.messages[5].content }}",
        "options": {
          "systemMessage": "={{ $('Webhook').item.json.body.messages[0].content }}"
        }
      },
      "id": "e1851847-3052-4d24-9198-8ecca83c48d8",
      "name": "Gemini AI轮询15",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1700,
        4680
      ],
      "typeVersion": 1.6
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 0,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "0c95b29b-e71f-4cea-b978-9be263d78791",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 1,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "02d5a829-d750-4ccb-84dc-f33afd444bbe",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 2,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "d2a9e955-395f-4147-be2f-740a557b491a",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 3,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "cf3f972e-60b6-4a57-b8df-b04069fa6f49",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 4,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "8e2bc3b1-0037-490e-9bb1-f5088ec6de17",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 5,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "e084a83d-519c-49b1-9163-f917d9d82083",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 6,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "803fcb8f-1af9-4c66-8450-0b13c27c1109",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 7,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "4dcdad35-5123-476b-b035-ece7dcfc05dc",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 8,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "7785a67d-d398-4213-8d3b-bc2fd761a170",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 9,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "231aabf4-2335-4d0b-897d-c194aa49816c",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 10,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "996d6a9a-3205-44ff-8876-60b73fe09c5e",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 11,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "39e77a26-698b-4a3a-ad3e-cfa35c66f777",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 12,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "8a47a10e-7f3a-4ffa-8312-684471fce945",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 13,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c1a3613c-767b-4880-b79c-8ee54cd7f56f",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 14,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "59d94b09-dade-4d08-81d2-febbfc5c9994",
                    "leftValue": "={{ $json.currentIndex }}",
                    "rightValue": 15,
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {}
      },
      "id": "61b1d30d-45a4-48af-915c-2086df30b925",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -2360,
        2560
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "887a777d-f4db-41e1-8b72-5bf2b0979a36",
              "leftValue": "={{ $('Webhook').item.json.body.model }}",
              "rightValue": "gemini-1.5-pro-002",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "8beb18f1-890f-4288-a720-e5cc0ca80069",
              "leftValue": "={{ $('Webhook').item.json.body.model }}",
              "rightValue": "glm-4-flash",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "e576e177-1af1-4886-a9ce-7343cc58509e",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2920,
        2700
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "v1/chat/completions",
        "authentication": "headerAuth",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "5bd8073a-accf-43d2-ae3b-40b7ea68d6b5",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -3080,
        2700
      ],
      "webhookId": "231dbd2d-ca4c-4bf3-a18b-4b612042570d",
      "credentials": {
        "httpHeaderAuth": {
          "id": "1Mh74hpnj9mzMB8Q",
          "name": "硅基流动绘画"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n    \"id\": \"\",\n    \"model\": \"\",\n    \"usage\": {\n        \"prompt_tokens\": 1,\n        \"completion_tokens\": 1,\n        \"total_tokens\": 1\n    },\n    \"choices\": [\n        {\n            \"message\": {\n                \"role\": \"assistant\",\n                \"content\": \"{{ $json.output }}\"\n            },\n            \"finish_reason\": \"stop\",\n            \"index\": 0\n        }\n    ]\n}",
        "options": {}
      },
      "id": "c259450e-54e6-4872-a9a2-10ac47bd413e",
      "name": "这个节点可以使用Gemini flash模型,与pro模型一致。超过论坛字符数限制,故省略",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        -20,
        2820
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "SerpAPI": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI1": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat1": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI2": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询2",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat2": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI3": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat3": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI4": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat4": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询4",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI5": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询5",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat5": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询5",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI6": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询6",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat6": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询6",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI7": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询7",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat7": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询7",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI8": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询8",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat8": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询8",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI9": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询9",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat9": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询9",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI10": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询10",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat10": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询10",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI11": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询11",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat11": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询11",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI12": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询12",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat12": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询12",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI13": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询13",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat13": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询13",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI14": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询14",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat14": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询14",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI15": {
      "ai_tool": [
        [
          {
            "node": "Gemini AI轮询15",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat15": {
      "ai_languageModel": [
        [
          {
            "node": "Gemini AI轮询15",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询1": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询2": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询3": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询4": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询5": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询6": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询7": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询8": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询9": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询10": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询11": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询12": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询13": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询14": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini AI轮询15": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Gemini AI轮询",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询8",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询9",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询11",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询12",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询13",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询14",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gemini AI轮询15",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "这个节点可以使用Gemini flash模型,与pro模型一致。超过论坛字符数限制,故省略",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2d12aaac-a54a-4c94-9abf-4740d4c801b2",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "273cb072730a54351e245b85466131b67e03b4084264c10b9a2f40e05554ac84"
  },
  "id": "W7Z5G5xlJxuPLEGU",
  "tags": []
}

:sparkles:使用方法

导入工作流后,填写相关Gemini API KEY。
如想接入联网功能,还需填写Serp API Key。

如想修改轮询的账号数,在下图节点中修改即可:

请求地址为:https://你的n8n的地址/v1/chat/completions
认证密钥:自行任意设置

RPM

使用16个谷歌账号,Gemini Pro 的RPM可达到2×16次,每日可调用50×16次
相较于NEW API,NEW API为随机调用gemini实现负载均衡,会出现调用不均匀而调用失败的情况。
而此方法,调用gemini最均衡,而且更加稳定,延迟好像也更低?

获取Gemini API

前往官网登录获取:Google AI Studio |Gemini API |Google for Developers  |  Google AI for Developers

302 个赞

太强了!大佬!我去试试

20 个赞

虽然看不懂但看到第一张图就放弃了

16 个赞

感谢佬友,弄好再接入new api,更方便

5 个赞

这系列写得很用心,来给点热度了
最近好累先收藏了,下次闲著再搞

62 个赞

但非常简单,那么长是因为swich

2 个赞

我抄 我抄我抄

2 个赞

感谢佬分享,如果可以把gemini的api如何获得教程也加入一下的话就更好了~~~

1 个赞

不太懂這個,只是為了輪詢調用的話,為啥不直接在Render裡部署Litellm?有甚麼說法嗎?

2 个赞

首先,不“只是为了实现轮询”。这只是展示n8n的部分用法,n8n还可以做很多其他事情。

litellm不太了解,而且litellm实现负载均衡的方式不是随机调用吗?

1 个赞

看不懂看不懂,但是很强呀

1 个赞

佬,这个好像是非流式输出。它能实现流式输出吗?

n8n官方提供的AI节点好像不支持流式

但可以用http request节点请求使用流式输出

gemini pro API使用方法gemini官网应该有,按照教程写request请求应该能实现流式

佬,这个方案我试过了,也不行。测试单个http节点的时候,虽然是请求流式接口,但一定是所有数据都发送完毕之后才会走下一个节点

来支持一下,希望系列可以长久写下去

佬,请教一下为什么说是真正的轮询,n8n的算法和NEW API的有什么区别呢?

太强了,就是没那么多谷歌号

你可以接着写下去了,保证有人看

后者应该是说可能会一直使用某个而达到单个账号的上限,而前者平均下来就是每个号被用一次

太强了大佬!

2 个赞