8
n8n 中文网amn8n.com

使用 Sora GPT、Google Drive 和 Sheets 生成并存储 AI 图像

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 11 个节点。主要使用 Code, FormTrigger, GoogleDrive, HttpRequest, GoogleSheets 等节点。 使用 Sora GPT、Google Drive 和 Sheets 生成并存储 AI 图像

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "60c025075753afcab9f803964b4caaca9402f435deb4efafbb8e3b93b54d8752"
  },
  "nodes": [
    {
      "id": "ffd9cc3e-8d6b-4b7c-a600-39f9511f4e19",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        80,
        -60
      ],
      "webhookId": "664f5a3c-d13b-4831-96e7-5a80567a5dbe",
      "parameters": {
        "options": {},
        "formTitle": "Image to Image Using GPT Sora",
        "formFields": {
          "values": [
            {
              "fieldType": "textarea",
              "fieldLabel": "Prompt",
              "requiredField": true
            },
            {
              "fieldLabel": "Image url",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Add Image and prompt to recreate your desired image"
      },
      "typeVersion": 2.2
    },
    {
      "id": "1b9fef9c-259e-4885-8596-c9319de01180",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        300,
        -60
      ],
      "parameters": {
        "url": "https://sora-gpt-image.p.rapidapi.com/ai-img/img-to-img.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.Prompt }}"
            },
            {
              "name": "img_url",
              "value": "={{ $json['Image url'] }}"
            },
            {
              "name": "width",
              "value": "1024"
            },
            {
              "name": "height",
              "value": "1024"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "sora-gpt-image.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1f2d4911-0151-4e7a-a3f5-f2f4ab2230ea",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1740,
        -360
      ],
      "parameters": {
        "columns": {
          "value": {
            "Image": "={{ $binary.data.fileName }}",
            "Prompt": "={{ $('On form submission').item.json.Prompt }}",
            "Generated Date": "={{ $('On form submission').item.json.submittedAt }}"
          },
          "schema": [
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Image",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Image",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Generated Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Generated Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19RkfJHHLt15sIwaeN5Fgrd4BuVTacA0_mYP-gPcBVao/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "qUtlCnYpk7bXXaYp",
          "name": "Google Sheets account 3"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "214a0309-83a7-4d8b-99b3-5809a97533cd",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1340,
        -220
      ],
      "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": "bc885b5f-d31b-4f5e-9ada-a4a5e421eb82",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        -60
      ],
      "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": "26c911dc-2f63-4d8e-b8a0-b54634d17b81",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -920,
        -540
      ],
      "parameters": {
        "width": 580,
        "height": 3080,
        "content": "# **使用 GPT Sora 进行图生图**"
      },
      "typeVersion": 1
    },
    {
      "id": "6513598b-6cb9-4ae9-b1c2-167fcb57c581",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -380
      ],
      "parameters": {
        "width": 500,
        "height": 440,
        "content": "## 1. **表单提交时**"
      },
      "typeVersion": 1
    },
    {
      "id": "29045bc9-0dcd-453e-aa3c-722e94aef44d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        -560
      ],
      "parameters": {
        "width": 440,
        "height": 660,
        "content": "## 2. 向 Sora GPT Image API 发送 HTTP 请求"
      },
      "typeVersion": 1
    },
    {
      "id": "73ecda33-8fb7-4d90-b510-b2c70914af02",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        760,
        -540
      ],
      "parameters": {
        "width": 300,
        "height": 640,
        "content": "## 3. **代码(Base64 转换)**"
      },
      "typeVersion": 1
    },
    {
      "id": "4c95d81d-907d-4c15-af58-e08f919234c6",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1180,
        -660
      ],
      "parameters": {
        "width": 380,
        "height": 680,
        "content": "## 4. **上传图片到 Google Drive**"
      },
      "typeVersion": 1
    },
    {
      "id": "9a8d33bc-572d-48ea-9585-20eeb24e24c4",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -880
      ],
      "parameters": {
        "width": 420,
        "height": 720,
        "content": "## 5. **记录详情到 Google Sheets**"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量11
分类2
节点类型6
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流