8
n8n 中文网amn8n.com

使用 BananaAPI 和 Nano Banana 引擎通过文本提示生成 AI 图像

高级

这是一个Content Creation, Miscellaneous, Multimodal AI领域的自动化工作流,包含 16 个节点。主要使用 If, Set, Wait, FormTrigger, HttpRequest 等节点。 使用 BananaAPI 和 Nano Banana 引擎通过文本提示生成 AI 图像

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "ae35fcac1ced05e71449f098fbec8ecb6349893e0c2112cc033acbf2f682aad4"
  },
  "nodes": [
    {
      "id": "c77e4131-abb7-4f10-bac4-809dc2467d42",
      "name": "表单 — 获取提示",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        560,
        1136
      ],
      "webhookId": "9f404ff0-1029-4086-b044-43cbbd9d1039",
      "parameters": {
        "options": {},
        "formTitle": "Banana API — Image Generator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "api_token",
              "placeholder": "Bearer xxxxxxx...",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "prompt",
              "placeholder": "Ví dụ: a neon cyberpunk cat, detailed, 4k",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Output Format [optional]",
              "fieldOptions": {
                "values": [
                  {
                    "option": "png"
                  },
                  {
                    "option": "jpeg"
                  }
                ]
              }
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Image Size [optional]",
              "fieldOptions": {
                "values": [
                  {
                    "option": "16:9"
                  },
                  {
                    "option": "9:16"
                  },
                  {
                    "option": "1:1"
                  },
                  {
                    "option": "3:4"
                  },
                  {
                    "option": "4:3"
                  }
                ]
              }
            },
            {
              "fieldLabel": "image_url_1 [optional]",
              "placeholder": "https://example.com/input.jpg"
            },
            {
              "fieldLabel": "image_url_2 [optional]"
            },
            {
              "fieldLabel": "image_url_3 [optional]"
            },
            {
              "fieldLabel": "image_url_4 [optional]"
            },
            {
              "fieldLabel": "image_url_5 [optional]"
            }
          ]
        },
        "formDescription": "Enter the prompt and (optionally) the original image link for the Banana API to generate a new image."
      },
      "typeVersion": 2.2
    },
    {
      "id": "aa769a6a-0170-4851-82b8-0169eca8ec4a",
      "name": "提交 — Banana API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1072,
        1136
      ],
      "parameters": {
        "url": "https://bananaapi.com/api/n8n/generate/",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"input\": {\n    \"prompt\": \"{{ $json.prompt }}\",\n    \"image_size\": \"{{ $json['Image Size [optional]'] }}\",\n    \"output_format\": \"{{ $json['Output Format [optional]'] }}\",\n    \"image_urls\": [\"{{ $json['image_url_1 [optional]'] }}\",\"{{ $json['image_url_2 [optional]'] }}\",\"{{ $json['image_url_3 [optional]'] }}\",\"{{ $json['image_url_4 [optional]'] }}\",\"{{ $json['image_url_5 [optional]'] }}\"]\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.api_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c3522fe8-9442-4fcc-a2d2-cd90ac3fef15",
      "name": "等待 5 秒",
      "type": "n8n-nodes-base.wait",
      "position": [
        1472,
        1136
      ],
      "webhookId": "72d55c47-b651-4121-b59f-dab21489cb35",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "037eee00-f9da-41bc-b508-6bb3fa87c68a",
      "name": "检查状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1632,
        1136
      ],
      "parameters": {
        "url": "=https://bananaapi.com/api/n8n/image-status/{{$('Submit — Banana API').item.json.taskId}}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "749b2fd0-650c-4b31-9527-c7b84a2c7357",
      "name": "等待5秒(循环)",
      "type": "n8n-nodes-base.wait",
      "position": [
        2048,
        1088
      ],
      "webhookId": "b347eefb-f36a-4072-9135-fb4ad8abed5d",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "3d5b6f8d-364b-4a48-82cb-fc5409502788",
      "name": "返回链接",
      "type": "n8n-nodes-base.set",
      "position": [
        2528,
        1056
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "80fd7573-3eac-4fc4-aced-b122e5eac718",
              "name": "image_url",
              "type": "string",
              "value": "={{$json.imageUrl}}"
            },
            {
              "id": "26339522-2fe9-48f6-aafd-e1aa9ed89327",
              "name": "task_id",
              "type": "string",
              "value": "={{$('Submit — Banana API').item.json.taskId}}"
            },
            {
              "id": "3e26803c-640d-463d-b857-a3bd29ea2358",
              "name": "status",
              "type": "string",
              "value": "={{$json.status}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "01a74ecd-93e3-4eb3-ab72-3ab82a008294",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        1808,
        1072
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "4e3a3b7c-61e8-49c4-abf7-5eb3db4a3eef",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Check Status').item.json.status }}",
              "rightValue": "=completed"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0f715abf-ae0a-42d5-8647-5e9488cd3f9d",
      "name": "说明 — 概述",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## 概述"
      },
      "typeVersion": 1
    },
    {
      "id": "71c558a9-d4e5-4ba2-8dc1-170e8a4ba0db",
      "name": "说明 — 先决条件",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## 先决条件"
      },
      "typeVersion": 1
    },
    {
      "id": "77a8c9f2-61af-4e2e-9ba4-6c3ca1494567",
      "name": "说明 — 步骤1(表单输入)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        800
      ],
      "parameters": {
        "width": 464,
        "height": 496,
        "content": "## 步骤1 — 用户表单输入"
      },
      "typeVersion": 1
    },
    {
      "id": "5ae4ce78-4f6c-4148-8485-a90d21ba32dd",
      "name": "说明 — 步骤2(POST请求)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        800
      ],
      "parameters": {
        "width": 464,
        "height": 496,
        "content": "## 步骤2 — 提交至Banana API"
      },
      "typeVersion": 1
    },
    {
      "id": "3c7bfc47-5d0f-45fb-a53f-25c24d2ed1f5",
      "name": "说明 — 步骤3(处理)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        800
      ],
      "parameters": {
        "width": 912,
        "height": 496,
        "content": "## 步骤3 — 处理"
      },
      "typeVersion": 1
    },
    {
      "id": "583222b7-f53c-4376-8958-4c544c4ace60",
      "name": "说明 — 步骤5(输出)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2336,
        800
      ],
      "parameters": {
        "width": 464,
        "height": 496,
        "content": "## 步骤4 — 返回输出"
      },
      "typeVersion": 1
    },
    {
      "id": "abfd4d9f-d7be-4a74-87ae-8618a6ff826a",
      "name": "说明 — API参考",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## API参考"
      },
      "typeVersion": 1
    },
    {
      "id": "5074a457-5ec7-4a5c-81bc-54c120818b08",
      "name": "说明 — 价格优势",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## 价格优势"
      },
      "typeVersion": 1
    },
    {
      "id": "1d11806a-56e9-4e02-9aeb-5dfef750b1ae",
      "name": "说明 — 故障排除",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## 故障排除"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Return Links",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 5s (loop)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5s": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5s (loop)": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form — Get Prompt": {
      "main": [
        [
          {
            "node": "Submit — Banana API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit — Banana API": {
      "main": [
        [
          {
            "node": "Wait 5s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流