8
n8n 中文网amn8n.com

使用 Anthropic Claude API 批量处理提示

高级

这是一个Building Blocks, AI领域的自动化工作流,包含 39 个节点。主要使用 If, Set, Code, Wait, Merge 等节点,结合人工智能技术实现智能自动化。 使用 Anthropic Claude API 批量处理提示

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "97d44c78f314fab340d7a5edaf7e2c274a7fbb8a7cd138f53cc742341e706fe7"
  },
  "nodes": [
    {
      "id": "fa4f8fd6-3272-4a93-8547-32d13873bbc1",
      "name": "提交批次",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        180,
        40
      ],
      "parameters": {
        "url": "https://api.anthropic.com/v1/messages/batches",
        "method": "POST",
        "options": {},
        "jsonBody": "={ \"requests\": {{ JSON.stringify($json.requests) }} }",
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "={{ $json[\"anthropic-version\"] }}"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "id": "ub0zN7IP2V83OeTf",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2916dc85-829d-491a-a7a8-de79d5356a53",
      "name": "检查批次状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        840,
        115
      ],
      "parameters": {
        "url": "=https://api.anthropic.com/v1/messages/batches/{{ $json.id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "={{ $('When Executed by Another Workflow').item.json[\"anthropic-version\"] }}"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "id": "ub0zN7IP2V83OeTf",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1552ec92-2f18-42f6-b67f-b6f131012b3c",
      "name": "当由其他工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -40,
        40
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "anthropic-version"
            },
            {
              "name": "requests",
              "type": "array"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "4bd40f02-caf1-419d-8261-a149cd51a534",
      "name": "获取结果",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        620,
        -160
      ],
      "parameters": {
        "url": "={{ $json.results_url }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "={{ $('When Executed by Another Workflow').item.json[\"anthropic-version\"] }}"
            }
          ]
        },
        "nodeCredentialType": "anthropicApi"
      },
      "credentials": {
        "anthropicApi": {
          "id": "ub0zN7IP2V83OeTf",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5df366af-a54d-4594-a1ab-7a9df968101e",
      "name": "解析响应",
      "type": "n8n-nodes-base.code",
      "notes": "JSONL separated by newlines",
      "position": [
        840,
        -160
      ],
      "parameters": {
        "jsCode": "for (const item of $input.all()) {\n  if (item.json && item.json.data) {\n    // Split the string into individual JSON objects\n    const jsonStrings = item.json.data.split('\\n');\n\n    // Parse each JSON string and store them in an array\n    const parsedData = jsonStrings.filter(str => str.trim() !== '').map(str => JSON.parse(str));\n\n    // Replace the original json with the parsed array.\n    item.json.parsed = parsedData;\n  }\n}\n\nreturn $input.all();"
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "68aa4ee2-e925-4e30-a7ab-317d8df4d9bc",
      "name": "如果处理结束",
      "type": "n8n-nodes-base.if",
      "position": [
        400,
        40
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9494c5a3-d093-49c5-837f-99cd700a2f13",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.processing_status }}",
              "rightValue": "ended"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2b974e3b-495b-48af-8080-c7913d7a2ba8",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -720
      ],
      "parameters": {
        "width": 1060,
        "height": 520,
        "content": "### 此工作流使用 Anthropic API 自动向 Claude 发送批量提示。它一次提交多个提示并检索结果。"
      },
      "typeVersion": 1
    },
    {
      "id": "928a30b5-5d90-4648-a82e-e4f1a01e47a5",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        -720
      ],
      "parameters": {
        "width": 980,
        "height": 600,
        "content": "#### 结果"
      },
      "typeVersion": 1
    },
    {
      "id": "5dcb554e-32df-4883-b5a1-b40305756201",
      "name": "批次状态轮询间隔",
      "type": "n8n-nodes-base.wait",
      "position": [
        620,
        40
      ],
      "webhookId": "7efafe72-063a-45c6-8775-fcec14e1d263",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "c25cfde5-ab83-4e5a-a66f-8cc9f23a01f6",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        325
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 620,
        "content": "# 使用示例"
      },
      "typeVersion": 1
    },
    {
      "id": "6062ca7c-aa08-4805-9c96-65e5be8a38fd",
      "name": "运行示例",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -40,
        625
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9878729a-123d-4460-a582-691ca8cedf98",
      "name": "单一查询示例",
      "type": "n8n-nodes-base.set",
      "position": [
        634,
        775
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1ea47ba2-64be-4d69-b3db-3447cde71645",
              "name": "query",
              "type": "string",
              "value": "Hey Claude, tell me a short fun fact about bees!"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "df06c209-8b6a-4b6d-8045-230ebdfcfbad",
      "name": "删除原始属性",
      "type": "n8n-nodes-base.set",
      "position": [
        1528,
        775
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d238d62b-2e91-4242-b509-8cfc698d2252",
              "name": "custom_id",
              "type": "string",
              "value": "={{ $json.custom_id }}"
            },
            {
              "id": "21e07c09-92e3-41e7-8335-64653722e7e9",
              "name": "params",
              "type": "object",
              "value": "={{ $json.params }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f66d6a89-ee33-4494-9476-46f408976b29",
      "name": "构建 'requests' 数组",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1968,
        625
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "requests"
      },
      "typeVersion": 1
    },
    {
      "id": "0f9eb605-d629-4cb7-b9cb-39702d201567",
      "name": "设置所需的 'anthropic-version'",
      "type": "n8n-nodes-base.set",
      "notes": "2023-06-01",
      "position": [
        2188,
        625
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9f9e94a0-304b-487a-8762-d74421ef4cc0",
              "name": "anthropic-version",
              "type": "string",
              "value": "2023-06-01"
            }
          ]
        },
        "includeOtherFields": true
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "f71f261c-f4ad-4c9f-bd72-42ab386a65e1",
      "name": "执行工作流'使用 Anthropic Claude 批量 API 并行处理多个提示'",
      "type": "n8n-nodes-base.executeWorkflow",
      "notes": "See above",
      "position": [
        2408,
        625
      ],
      "parameters": {
        "options": {
          "waitForSubWorkflow": true
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "xQU4byMGhgFxnTIH",
          "cachedResultName": "Process Multiple Prompts in Parallel with Anthropic Claude Batch API"
        },
        "workflowInputs": {
          "value": {
            "requests": "={{ $json.requests }}",
            "anthropic-version": "={{ $json['anthropic-version'] }}"
          },
          "schema": [
            {
              "id": "anthropic-version",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "anthropic-version",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "requests",
              "type": "array",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "requests",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "requests"
          ],
          "attemptToConvertTypes": true,
          "convertFieldsToString": true
        }
      },
      "notesInFlow": true,
      "typeVersion": 1.2
    },
    {
      "id": "bd27c1a6-572c-420d-84ab-4d8b7d14311b",
      "name": "为单一查询构建批次 'request' 对象",
      "type": "n8n-nodes-base.code",
      "position": [
        1308,
        775
      ],
      "parameters": {
        "jsCode": "// Loop over input items and modify them to match the response example, then return input.all()\nfor (const item of $input.all()) {\n  item.json.params = {\n    max_tokens: item.json.max_tokens,\n    messages: [\n      {\n        content: item.json.query,\n        role: \"user\"\n      }\n    ],\n    model: item.json.model\n  };\n}\n\nreturn $input.all();\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fa342231-ea94-43ab-8808-18c8d04fdaf8",
      "name": "简单内存存储",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        644,
        595
      ],
      "parameters": {
        "sessionKey": "\"Process Multiple Prompts in Parallel with Anthropic Claude Batch API example\"",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "67047fe6-8658-45ba-be61-52cf6115f4e4",
      "name": "用示例数据填充聊天内存",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        556,
        375
      ],
      "parameters": {
        "mode": "insert",
        "messages": {
          "messageValues": [
            {
              "message": "You are a helpful AI assistant"
            },
            {
              "type": "user",
              "message": "Hey Claude, tell me a short fun fact about video games!"
            },
            {
              "type": "ai",
              "message": "short fun fact about video games!"
            },
            {
              "type": "user",
              "message": "No, an actual fun fact"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "dbb295b8-01fd-445f-ab66-948442b6c71d",
      "name": "从聊天内存和执行数据构建批次 'request' 对象",
      "type": "n8n-nodes-base.code",
      "position": [
        1528,
        475
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (const item of $input.all()) {\n  const inputMessages = item.json.messages;\n  const customId = item.json.custom_id;\n  const model = item.json.model;\n  const maxTokens = item.json.max_tokens;\n\n  if (inputMessages && inputMessages.length > 0) {\n    let systemMessageContent = undefined;\n    const transformedMessages = [];\n\n    // Process each message entry in sequence\n    for (const messageObj of inputMessages) {\n      // Extract system message if present\n      if ('system' in messageObj) {\n        systemMessageContent = messageObj.system;\n      }\n      \n      // Process human and AI messages in the order they appear in the object keys\n      // We need to determine what order the keys appear in the original object\n      const keys = Object.keys(messageObj);\n      \n      for (const key of keys) {\n        if (key === 'human') {\n          transformedMessages.push({\n            role: \"user\",\n            content: messageObj.human\n          });\n        } else if (key === 'ai') {\n          transformedMessages.push({\n            role: \"assistant\",\n            content: messageObj.ai\n          });\n        }\n        // Skip 'system' as we already processed it\n      }\n    }\n\n    const params = {\n      model: model,\n      max_tokens: maxTokens,\n      messages: transformedMessages\n    };\n\n    if (systemMessageContent !== undefined) {\n      params.system = systemMessageContent;\n    }\n\n    output.push({\n      custom_id: customId,\n      params: params\n    });\n  }\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "f9edb335-c33d-45fc-8f9b-12d7f37cc23e",
      "name": "加载聊天内存数据",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        932,
        475
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "22399660-ebe5-4838-bad3-c542d6d921a3",
      "name": "第一个提示结果",
      "type": "n8n-nodes-base.executionData",
      "position": [
        2848,
        525
      ],
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "assistant_response",
              "value": "={{ $json.result.message.content[0].text }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0e7f44f4-c931-4e0f-aebc-1b8f0327647f",
      "name": "第二个提示结果",
      "type": "n8n-nodes-base.executionData",
      "position": [
        2848,
        725
      ],
      "parameters": {
        "dataToSave": {
          "values": [
            {
              "key": "assistant_response",
              "value": "={{ $json.result.message.content[0].text }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e42b01e0-8fc5-42e1-aa45-aa85477e766b",
      "name": "拆分出解析结果",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1060,
        -160
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "parsed"
      },
      "typeVersion": 1
    },
    {
      "id": "343676b9-f147-4981-b555-8af570374e8c",
      "name": "过滤第二个提示结果",
      "type": "n8n-nodes-base.filter",
      "position": [
        2628,
        725
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9e4b3524-7066-46cc-a365-8d23d08c1bda",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.custom_id }}",
              "rightValue": "={{ $('Append execution data for single query example').item.json.custom_id }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c9f5f366-27c4-4401-965b-67c314036fb6",
      "name": "过滤第一个提示结果",
      "type": "n8n-nodes-base.filter",
      "position": [
        2628,
        525
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9e4b3524-7066-46cc-a365-8d23d08c1bda",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.custom_id }}",
              "rightValue": "={{ $('Append execution data for chat memory example').item.json.custom_id }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0a5b9c3d-665b-4e35-be9e-c8297314969d",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        110,
        -100
      ],
      "parameters": {
        "height": 300,
        "content": "## 向 Anthropic 提交批次请求"
      },
      "typeVersion": 1
    },
    {
      "id": "f19813a5-f669-45dd-a446-947a30b02b09",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        350,
        -5
      ],
      "parameters": {
        "width": 640,
        "height": 300,
        "content": "## 循环直到处理状态为 'ended'"
      },
      "typeVersion": 1
    },
    {
      "id": "9f424fce-5610-4b85-9be6-4c2c403002db",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -200
      ],
      "parameters": {
        "width": 280,
        "height": 180,
        "content": "### 检索消息批次结果"
      },
      "typeVersion": 1
    },
    {
      "id": "b87673b1-f08d-4c51-8ee5-4d54557cb382",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        380
      ],
      "parameters": {
        "color": 5,
        "width": 820,
        "height": 340,
        "content": "# 使用聊天历史节点的示例"
      },
      "typeVersion": 1
    },
    {
      "id": "d6d8ac02-7005-40a1-9950-9517e98e315c",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        720
      ],
      "parameters": {
        "width": 1540,
        "height": 220,
        "content": "# 使用单一查询字符串的示例"
      },
      "typeVersion": 1
    },
    {
      "id": "0d63deb0-dece-4502-9020-d67c1f194466",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        320
      ],
      "parameters": {
        "color": 3,
        "width": 660,
        "height": 400,
        "content": "# 环境设置"
      },
      "typeVersion": 1
    },
    {
      "id": "cab94e09-6b84-4a38-b854-670241744db5",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2120,
        800
      ],
      "parameters": {
        "height": 220,
        "content": "## anthropic-version"
      },
      "typeVersion": 1
    },
    {
      "id": "ab0a51a1-3c84-4a88-968b-fd46ab07de85",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 480,
        "height": 300,
        "content": "# 使用聊天历史节点的示例(结果)"
      },
      "typeVersion": 1
    },
    {
      "id": "d91b9be7-ef32-48d6-b880-cab0e99ba9bc",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        700
      ],
      "parameters": {
        "width": 480,
        "height": 300,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "341811e9-6677-42d9-be28-c388dbf68101",
      "name": "将两个示例请求合并到数组中",
      "type": "n8n-nodes-base.merge",
      "position": [
        1748,
        625
      ],
      "parameters": {},
      "typeVersion": 3.1
    },
    {
      "id": "45a09f05-7610-4b0a-ab7f-0094c4b3f318",
      "name": "为单一查询示例附加执行数据",
      "type": "n8n-nodes-base.set",
      "notes": "custom_id, model and max tokens",
      "position": [
        1010,
        775
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8276602f-689f-45c2-bce0-5df8500912b6",
              "name": "custom_id",
              "type": "string",
              "value": "second-prompt-in-my-batch"
            },
            {
              "id": "2c513dc2-d8cb-4ba3-b3c1-ea79517b9434",
              "name": "model",
              "type": "string",
              "value": "claude-3-5-haiku-20241022"
            },
            {
              "id": "b052140b-1152-4327-9c5a-5030b78990b7",
              "name": "max_tokens",
              "type": "number",
              "value": 100
            }
          ]
        },
        "includeOtherFields": true
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "c4e35349-840c-4c81-852c-0d8cd9331364",
      "name": "为聊天内存示例附加执行数据",
      "type": "n8n-nodes-base.set",
      "notes": "custom_id, model and max tokens",
      "position": [
        1308,
        475
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8276602f-689f-45c2-bce0-5df8500912b6",
              "name": "custom_id",
              "type": "string",
              "value": "first-prompt-in-my-batch"
            },
            {
              "id": "2c513dc2-d8cb-4ba3-b3c1-ea79517b9434",
              "name": "model",
              "type": "string",
              "value": "claude-3-5-haiku-20241022"
            },
            {
              "id": "b052140b-1152-4327-9c5a-5030b78990b7",
              "name": "max_tokens",
              "type": "number",
              "value": 100
            }
          ]
        },
        "includeOtherFields": true
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "058aedb1-fdfe-4edc-8d51-3b93ec7d232d",
      "name": "截断聊天内存",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "notes": "ensure clean state",
      "position": [
        180,
        475
      ],
      "parameters": {
        "mode": "delete",
        "deleteMode": "all"
      },
      "notesInFlow": true,
      "typeVersion": 1.1
    }
  ],
  "pinData": {},
  "connections": {
    "Get results": {
      "main": [
        [
          {
            "node": "Parse response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run example": {
      "main": [
        [
          {
            "node": "One query example",
            "type": "main",
            "index": 0
          },
          {
            "node": "Truncate Chat Memory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit batch": {
      "main": [
        [
          {
            "node": "If ended processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse response": {
      "main": [
        [
          {
            "node": "Split Out Parsed Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One query example": {
      "main": [
        [
          {
            "node": "Append execution data for single query example",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check batch status": {
      "main": [
        [
          {
            "node": "If ended processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If ended processing": {
      "main": [
        [
          {
            "node": "Get results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Batch Status Poll Interval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory Store": {
      "ai_memory": [
        [
          {
            "node": "Load Chat Memory Data",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Fill Chat Memory with example data",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "Truncate Chat Memory",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Truncate Chat Memory": {
      "main": [
        [
          {
            "node": "Fill Chat Memory with example data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Chat Memory Data": {
      "main": [
        [
          {
            "node": "Append execution data for chat memory example",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Status Poll Interval": {
      "main": [
        [
          {
            "node": "Check batch status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Construct 'requests' array": {
      "main": [
        [
          {
            "node": "Set desired 'anthropic-version'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete original properties": {
      "main": [
        [
          {
            "node": "Join two example requests into array",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter First Prompt Results": {
      "main": [
        [
          {
            "node": "First Prompt Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Second Prompt Results": {
      "main": [
        [
          {
            "node": "Second Prompt Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set desired 'anthropic-version'": {
      "main": [
        [
          {
            "node": "Execute Workflow 'Process Multiple Prompts in Parallel with Anthropic Claude Batch API'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Submit batch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fill Chat Memory with example data": {
      "main": [
        [
          {
            "node": "Load Chat Memory Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Join two example requests into array": {
      "main": [
        [
          {
            "node": "Construct 'requests' array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append execution data for chat memory example": {
      "main": [
        [
          {
            "node": "Build batch 'request' object from Chat Memory and execution data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build batch 'request' object for single query": {
      "main": [
        [
          {
            "node": "Delete original properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append execution data for single query example": {
      "main": [
        [
          {
            "node": "Build batch 'request' object for single query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build batch 'request' object from Chat Memory and execution data": {
      "main": [
        [
          {
            "node": "Join two example requests into array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow 'Process Multiple Prompts in Parallel with Anthropic Claude Batch API'": {
      "main": [
        [
          {
            "node": "Filter First Prompt Results",
            "type": "main",
            "index": 0
          },
          {
            "node": "Filter Second Prompt Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 构建模块, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量39
分类2
节点类型16
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Greg Evseev

Greg Evseev

@greg

15+ years in AI/ML development & integration. Now specializing in establishing ISO 42001-compliant AI management systems. Background includes AI/ML research, system development, AI governance, and ISO 42001 Lead Auditor training (in progress). Helping organizations: ✓ Evaluate AI maturity & governance ✓ Implement ISO 42001 systems ✓ Bridge technical & regulatory requirements ✓ Design practical AI governance frameworks Expertise: AI Risk Assessment, Compliance Strategy, Technical Due Diligence.

外部链接
在 n8n.io 查看

分享此工作流