8
n8n 中文网amn8n.com

使用Nano Banana AI将自拍转换为3D手办

中级

这是一个Miscellaneous, Multimodal AI领域的自动化工作流,包含 11 个节点。主要使用 If, Set, Code, Wait, FormTrigger 等节点。 使用Nano Banana AI将自拍转换为3D手办

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "O4GSdLho332Jps5T",
  "meta": {
    "instanceId": "323608cbec55d18261b8bc24f73f48c4455cb4a115f1b3e3d2435ba7c138103c"
  },
  "name": "使用 Nano Banana AI 将自拍转换为 3D 手办",
  "tags": [],
  "nodes": [
    {
      "id": "06a897f4-23bf-448b-a8a2-c2e58ff235ca",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 780,
        "height": 760,
        "content": "# 使用 Nano Banana AI 将自拍转换为 3D 手办"
      },
      "typeVersion": 1
    },
    {
      "id": "1829c8eb-71de-42b9-b639-d9d5ab14b751",
      "name": "获取生成状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        448,
        832
      ],
      "parameters": {
        "url": "https://api.defapi.org/api/task/query",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "task_id",
              "value": "={{$json.data.task_id}}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Convert to JSON').item.json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "703a60bb-bef1-4b95-ab9a-3f7846b104bc",
      "name": "向 Defapi.org API 发送图像生成请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        16,
        832
      ],
      "parameters": {
        "url": "https://api.defapi.org/api/image/gen",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"prompt\": \"{{$json.prompt}}\",\n  \"model\": \"google/nano-banana\",\n  \"images\": [\"{{ $json.img_url }}\"]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "edc3adde-c4bb-444f-9b88-a3e3f3c93908",
      "name": "模板使用n8n的默认聊天触发器",
      "type": "n8n-nodes-base.wait",
      "position": [
        256,
        832
      ],
      "webhookId": "bb6c2821-9586-44b7-8606-2ee69a77ed75",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "5f185c51-de9f-4e14-8b35-b2f1f853ef52",
      "name": "对于外部平台:替换为Webhook触发器并配置您平台的Webhook URL",
      "type": "n8n-nodes-base.if",
      "position": [
        640,
        832
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "db9a5dec-997b-4c3f-9582-37c9bbeb19ff",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "=true",
              "rightValue": "={{ $json.data.status == 'success' }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "0460ef13-34c0-4d8e-96ce-0b55d8e76bf1",
      "name": "支持平台:任何具有Webhook功能的平台(网站、Slack、Teams、Discord等)",
      "type": "n8n-nodes-base.set",
      "position": [
        816,
        816
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fa5f375f-cddc-4f7b-a018-67c28015d18b",
              "name": "image_url",
              "type": "string",
              "value": "={{$json.data.result[0].image}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6308e14e-c71b-4fa7-90b4-6b6f7d30d5d9",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        1056
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 576,
        "content": "## 输入照片"
      },
      "typeVersion": 1
    },
    {
      "id": "fef5e68a-f44b-48f9-862d-8e16be66fed3",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        1040
      ],
      "parameters": {
        "width": 416,
        "height": 608,
        "content": "## 结果图像"
      },
      "typeVersion": 1
    },
    {
      "id": "871e4071-6f48-477e-bbf6-060f51ec415b",
      "name": "上传图像",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -336,
        688
      ],
      "webhookId": "254a1336-57d2-4ba0-93e1-e8460fc94f00",
      "parameters": {
        "options": {},
        "formTitle": "Upload Image",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Image",
              "multipleFiles": false,
              "requiredField": true,
              "acceptFileTypes": "image/*"
            },
            {
              "fieldLabel": "API Key",
              "requiredField": true
            },
            {
              "fieldLabel": "Prompt",
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "196c9105-021b-4718-b04b-f2086721b0c0",
      "name": "转换为 JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        -128,
        688
      ],
      "parameters": {
        "jsCode": "/**\n * Encodes multiple binary files from an n8n input item into Base64 strings.\n *\n * This code assumes it is running in an n8n \"Code\" or \"Function\" node\n * where 'this' refers to the node's context and 'helpers' are available.\n *\n * @returns {object} An object containing an array of file objects,\n * each with a 'path' and 'data' (Base64 string).\n */\nconst results = {};\n\nconst bin = $input.first().binary['Image'];\n\n// Use n8n's helper function to get the file buffer.\nconst binBuffer = await this.helpers.getBinaryDataBuffer(0, 'Image');\n\n// Push a new object to the results array.\nresults.img_url = `data:${bin.mimeType};base64,${Buffer.from(binBuffer).toString('base64')}`\nresults.api_key = $input.first().json['API Key']\nresults.prompt = $input.first().json['Prompt']\n\n// Return the final object in the expected format for the next node.\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f8bee05a-feef-4fce-9b7c-4041d4570312",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        816
      ],
      "parameters": {
        "content": "## 示例提示"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "888d4d4c-6200-49f7-8f21-b81499d324ef",
  "connections": {
    "Upload Image": {
      "main": [
        [
          {
            "node": "Convert to JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to JSON": {
      "main": [
        [
          {
            "node": "Send Image Generation Request to Defapi.org API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Obtain the generated status": {
      "main": [
        [
          {
            "node": "Check if Image Generation is Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format and Display Image Results": {
      "main": [
        []
      ]
    },
    "Wait for Image Processing Completion": {
      "main": [
        [
          {
            "node": "Obtain the generated status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Image Generation is Complete": {
      "main": [
        [
          {
            "node": "Format and Display Image Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Image Processing Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Image Generation Request to Defapi.org API": {
      "main": [
        [
          {
            "node": "Wait for Image Processing Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 杂项, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流