8
n8n 中文网amn8n.com

蛋糕图片生成器

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 11 个节点。主要使用 Webhook, HttpRequest, Agent, RespondToWebhook, LmChatOpenAi 等节点。 使用OpenAI GPT和Replicate Flux Schnell生成自定义蛋糕图片

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "DE9G0H2GoX4JpP2C",
  "meta": {
    "instanceId": "803369b330aff65653c557f3d0dd038a389dc95d5e0aa902bc1df630e482e6a7",
    "templateCredsSetupCompleted": true
  },
  "name": "蛋糕图片生成器",
  "tags": [],
  "nodes": [
    {
      "id": "3bbf3ae1-a1d3-4d8e-8f1a-d620a8cc68fa",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        16,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ojOuwGjFsedrgBV6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "65ad017a-d18c-48f9-b315-42d8495204d9",
      "name": "生成图像",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        -16
      ],
      "parameters": {
        "url": "https://api.replicate.com/v1/models/black-forest-labs/flux-schnell/predictions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"version\": \"latest\",\n  \"input\": {\n    \"prompt\": \"{{$json['prompt']}}\"\n  }\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "1fsT3mjTBKXFask9",
          "name": "Replicate API Token"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "440001e5-7036-41d9-8a7e-ce14f67a49c1",
      "name": "提示词生成器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -80,
        -16
      ],
      "parameters": {
        "text": "=You are an expert in creating ai cake images.\nI want you to randomise the cake And put a very specific  {{ $json.body.name }} On the cake.\n\nBut remember one thing I don't want you to add anything else other than the prompt In the output. I dont want you to add any quotes Or any other information other than the plain text of the prompt.\n\nAlso wherever you mention to write the name\nInstead of \"{{ $json.body.name }}\" write it \\\"{{ $json.body.name }}\\\"\"\nthe name \\nabin\\ is {{ $json.body.name }}\n\neg : black forest gateau cake spelling out the words \\\"FLUX SCHNELL\\\"\", tasty, food photography, dynamic shot\n\ngive a very detailed prompt so that it can perfectly create the images of the cake",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "23fbd09d-63a5-449a-88f7-fae556de6097",
      "name": "用户发送请求",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -320,
        -16
      ],
      "webhookId": "5cfa7429-5637-4c1a-a81c-a53dfb154a5d",
      "parameters": {
        "path": "5cfa7429-5637-4c1a-a81c-a53dfb154a5d",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "e174bbd7-5eeb-41ba-9183-06bd84c42dbc",
      "name": "下载图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        544,
        -16
      ],
      "parameters": {
        "url": "={{ $json.output[0] }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "0eff512d-4cfd-492d-b63e-4ab52a49fdb6",
      "name": "响应请求",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        768,
        -16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.4
    },
    {
      "id": "3c788a4d-1e7c-4b49-b9d2-660f93a85826",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -80
      ],
      "parameters": {
        "color": 4,
        "width": 272,
        "height": 224,
        "content": "从 Bolt 前端接收用户输入(例如姓名/场合)。"
      },
      "typeVersion": 1
    },
    {
      "id": "ca05fccf-4021-4914-b976-1f17dc34346c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 304,
        "height": 416,
        "content": "使用 OpenAI GPT 生成创意蛋糕提示词。"
      },
      "typeVersion": 1
    },
    {
      "id": "44009c51-447b-40dc-a563-bdfa411e93ba",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -96
      ],
      "parameters": {
        "color": 6,
        "height": 240,
        "content": "将生成的提示词发送到 Replicate Flux Schnell 创建蛋糕图片。"
      },
      "typeVersion": 1
    },
    {
      "id": "0826cf08-d5fd-4f74-b3a2-06c9cf1f37f5",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -80
      ],
      "parameters": {
        "width": 224,
        "height": 224,
        "content": "从 Replicate 获取生成的蛋糕图片。"
      },
      "typeVersion": 1
    },
    {
      "id": "1f9c45e0-8b04-4db7-9a96-5d84b8bd54a7",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -80
      ],
      "parameters": {
        "color": 3,
        "height": 224,
        "content": "将最终蛋糕图片 URL 返回给前端。"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8ec6e9ea-0764-4692-8dfc-e72156240101",
  "connections": {
    "Download Image": {
      "main": [
        [
          {
            "node": "Respond to Requests",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt Generator": {
      "main": [
        [
          {
            "node": "Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Prompt Generator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "User Sends Request": {
      "main": [
        [
          {
            "node": "Prompt Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流