8
n8n 中文网amn8n.com

Flux AI 文生图副本

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 23 个节点。主要使用 If, Code, Wait, GoogleDrive, HttpRequest 等节点。 使用 Flux AI 集成 Google Sheets 和 Drive 的文生图生成器

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "GhhQipbYpxeWDukK",
  "meta": {
    "instanceId": "60c025075753afcab9f803964b4caaca9402f435deb4efafbb8e3b93b54d8752",
    "templateCredsSetupCompleted": true
  },
  "name": "Text To Image Flux AI 副本",
  "tags": [],
  "nodes": [
    {
      "id": "b3c3a883-4999-4b37-9f34-dc0d39e74900",
      "name": "Google Sheets2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -400,
        -480
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "4d98ceae-2e2b-44cc-a885-ac9df6c8445c",
      "name": "循环处理项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -160,
        -480
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "64c9af39-3b1d-4095-b5df-c4a6010e8ba5",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        1500,
        -160
      ],
      "webhookId": "5c3d0025-ab08-4ab1-946d-7878c57a76e9",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "81fbbaf8-5f0d-42b1-bb96-dad3a61caf7b",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -600,
        -480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1e7416e9-9331-4d13-b7ab-447aa37d7cdc",
      "name": "条件判断2",
      "type": "n8n-nodes-base.if",
      "position": [
        100,
        -460
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e0b7b7c8-3a7a-466d-bae7-269282b49d34",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Prompt }}",
              "rightValue": ""
            },
            {
              "id": "64dde394-0e49-4306-a24a-de2bf448fc95",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json['drive path'] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "59f2d118-2bb7-46a2-8dde-95dff6d681fc",
      "name": "条件判断1",
      "type": "n8n-nodes-base.if",
      "position": [
        680,
        -200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "205d9270-aa0e-4864-bbb6-c67206eda0a2",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c5fbcba1-9b63-4493-8547-8c55698fa5ba",
      "name": "Google Sheets4",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        960,
        -180
      ],
      "parameters": {
        "columns": {
          "value": {
            "Base64": "={{ $json.error }}",
            "Prompt": "={{ $json.Prompt }}"
          },
          "schema": [
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "drive path",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "drive path",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Generated Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Generated Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Base64",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Base64",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Prompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "647c344f-689a-40b5-a7ea-b1ec84b50866",
      "name": "代码1",
      "type": "n8n-nodes-base.code",
      "position": [
        640,
        -620
      ],
      "parameters": {
        "jsCode": "const base64String = $input.first().json.image_base64;\nconsole.log(base64String);\n// If it includes a prefix like 'data:image/jpeg;base64,', split it\nconst cleanedBase64 = base64String.includes(\",\")\n  ? base64String.split(\",\")[1]\n  : base64String;\n\nreturn [\n  {\n    binary: {\n      data: {\n        data: Buffer.from(cleanedBase64, 'base64'),\n        mimeType: 'image/jpeg', // or image/png depending on the format\n        fileName: 'output.jpg'\n      }\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7b99ef51-5c71-4a5a-8e2f-6bd86446c2b6",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        940,
        -580
      ],
      "parameters": {
        "columns": {
          "value": {
            "Base64": "={{ $('HTTP Request1').item.json.image_base64 }}",
            "Prompt": "={{ $('If2').item.json.Prompt }}",
            "Generated Date": "={{$now}}"
          },
          "schema": [
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "drive path",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "drive path",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Generated Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Generated Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Base64",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Base64",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "7def0479-c62e-4c9f-8001-03cafdea3c74",
      "name": "HTTP请求1",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        340,
        -500
      ],
      "parameters": {
        "url": "https://text-to-image-flux-ai.p.rapidapi.com/flux.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.Prompt }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "text-to-image-flux-ai.p.rapidapi.co"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e6645ea0-8ec7-46a3-a04d-12fef706a03d",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1080,
        -1100
      ],
      "parameters": {
        "name": "={{ $binary.data.fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "53711d81-9c16-49dd-917b-76d45730b8a7",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1580,
        -1000
      ],
      "parameters": {
        "width": 780,
        "height": 1220,
        "content": "# 文本转图片Flux AI工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "ed7d467c-34ad-42a4-89ce-de69187cf2f1",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -760
      ],
      "parameters": {
        "height": 500,
        "content": "### 1. 当点击\"执行工作流\"时(手动触发器)"
      },
      "typeVersion": 1
    },
    {
      "id": "ca2119ad-fb45-45a0-b3b2-dbbabdf42b35",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -760
      ],
      "parameters": {
        "height": 500,
        "content": "### 2. Google Sheets2(读取提示)"
      },
      "typeVersion": 1
    },
    {
      "id": "f36a50d3-9610-46be-954d-8d4b691429dc",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -760
      ],
      "parameters": {
        "height": 500,
        "content": "### 3. 循环处理项目(分批处理)"
      },
      "typeVersion": 1
    },
    {
      "id": "57b85cd9-1d1f-4f8c-8fca-ec1553183917",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        -760
      ],
      "parameters": {
        "height": 500,
        "content": "### 4. 条件判断2(检查提示和驱动器路径)"
      },
      "typeVersion": 1
    },
    {
      "id": "e9b2273a-643f-47eb-8e37-61418385a841",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        -760
      ],
      "parameters": {
        "height": 520,
        "content": "### 5. HTTP请求1(生成图片)"
      },
      "typeVersion": 1
    },
    {
      "id": "2b66a488-d1d6-49f1-84d9-52919b0eb945",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -900
      ],
      "parameters": {
        "height": 400,
        "content": "### 6. 代码1(转换Base64为二进制)"
      },
      "typeVersion": 1
    },
    {
      "id": "b9a32ed9-dbc5-48d0-bd0f-cd5656c0c641",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -760
      ],
      "parameters": {
        "width": 380,
        "height": 320,
        "content": "### 7. Google Sheets1(追加图片数据)"
      },
      "typeVersion": 1
    },
    {
      "id": "22f66814-7f95-4a6f-ac46-4030ec422191",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        920,
        -1260
      ],
      "parameters": {
        "width": 440,
        "height": 320,
        "content": "### 8. Google Drive1(上传图片)"
      },
      "typeVersion": 1
    },
    {
      "id": "97e072fe-1809-447f-9303-1d0fcda6b19c",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        -420
      ],
      "parameters": {
        "height": 400,
        "content": "### 9. Google Sheets4(更新错误)"
      },
      "typeVersion": 1
    },
    {
      "id": "112e8ff7-e2b2-4294-bdbe-744e1d3b1160",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        -380
      ],
      "parameters": {
        "height": 380,
        "content": "### 10. 等待(批次间暂停)"
      },
      "typeVersion": 1
    },
    {
      "id": "add007b2-05f1-4515-9c18-69604382aee7",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -420
      ],
      "parameters": {
        "height": 400,
        "content": "### 11. 条件判断1(错误处理)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2f2002fa-33cc-430d-ac3f-fb69999268d0",
  "connections": {
    "If1": {
      "main": [
        [
          {
            "node": "Google Sheets4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets2": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets4": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Google Sheets2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流