8
n8n 中文网amn8n.com

图像到图像生成

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 Set, Wait, Airtable, HttpRequest, ManualTrigger 等节点。 使用 FLUX.1 Kontext 和 Mistral 通过 AI 增强提示词变换图像

前置要求
  • Airtable API Key
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移

无法加载工作流预览

导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "",
  "meta": {
    "instanceId": "",
    "templateCredsSetupCompleted": true
  },
  "name": "图像到图像生成",
  "tags": [],
  "nodes": [
    {
      "id": "",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -680,
        -180
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -380,
        -180
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://airtable.com/",
          "cachedResultName": "YTB Outlier Finder"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://airtable.com/",
          "cachedResultName": "Image Generation"
        },
        "options": {
          "fields": [
            "ImageDescription",
            "Situation",
            "BaseImage",
            "Name"
          ]
        },
        "operation": "search",
        "filterByFormula": "={Prompt} = \"\""
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "",
      "name": "生成图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        140,
        -180
      ],
      "parameters": {
        "url": "https://fal.run/fal-ai/flux-pro/kontext/max",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.text }}"
            },
            {
              "name": "image_url",
              "value": "={{ $('Airtable').item.json.BaseImage[0].url }}"
            },
            {
              "name": "guidance_scale",
              "value": "7.5"
            },
            {
              "name": "num_images",
              "value": 1
            },
            {
              "name": "safety_tolerance",
              "value": 2
            },
            {
              "name": "output_format",
              "value": "jpeg"
            },
            {
              "name": "sync_mode",
              "value": "false"
            },
            {
              "name": "aspect_ratio",
              "value": "1:1"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Key {{ $('Edit Fields').item.json.FalAITOKEN }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "",
      "name": "记录图像帖子",
      "type": "n8n-nodes-base.airtable",
      "position": [
        640,
        -200
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://airtable.com/",
          "cachedResultName": "YTB Outlier Finder"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://airtable.com/",
          "cachedResultName": "Table 2"
        },
        "columns": {
          "value": {
            "Name": "={{ $('Airtable').item.json.Name }}",
            "Prompt": "={{ $json.prompt }}",
            "FinalImage": "={{ [{ \"url\": $json.images[0].url}] }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "BaseImage",
              "type": "array",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "BaseImage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ImageDescription",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "ImageDescription",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Situation",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Situation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "FinalImage",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "FinalImage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Name"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "",
      "name": "检查是否已生成",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        340,
        -180
      ],
      "parameters": {
        "url": "={{ $json.images[0].url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        500,
        -120
      ],
      "webhookId": "",
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "",
      "name": "Mistral Cloud Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
      "position": [
        -140,
        -20
      ],
      "parameters": {
        "model": "mistral-large-latest",
        "options": {}
      },
      "credentials": {
        "mistralCloudApi": {
          "id": "",
          "name": "Mistral Cloud account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "生成提示词",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -220,
        -180
      ],
      "parameters": {
        "text": "You are a Image Generation assistant.",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "type": "HumanMessagePromptTemplate",
              "message": "=You are a creative prompt engineer specializing in generating detailed image-to-image prompts for AI models like Stable Diffusion or Leonardo AI.\n\nYou will receive:\n- A base subject :{{ $json.ImageDescription }}\n- A situation or context that must be represented visually :{{ $json.Situation }}\n\nYour task is to generate an enhanced, imaginative prompt that:\n- Incorporates the visual details from the situation.\n- Respects the base subject’s identity (i.e., the AI will transform an image of the given subject, not create a completely new one).\n- Uses scene-building language to describe environment, mood, lighting, and dynamics.\n- Mentions the style if relevant (e.g., “realistic”, “cinematic”, “fantasy illustration”, etc.).\n- Avoids over-describing the subject's core features (to preserve the base image).\n\nOutput Format:\n- One paragraph of 1–3 sentences.\n- Include keywords or phrases that guide the AI visually (e.g., “dramatic lighting”, “smoke and lava in the background”, “third-person perspective”).\n- Return ONLY the prompt that will be directly given to the Image Generation LLM.\n\nExample Input:\nSubject: “a dog”\nSituation: “the dog is climbing a volcano in eruption”\n\nExample Output Prompt:\n“A dog braving the treacherous slopes of an erupting volcano, surrounded by glowing lava streams and thick clouds of smoke. The sky is darkened with ash as fiery embers illuminate the scene. Realistic style, cinematic lighting, wide-angle perspective.”"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -280
      ],
      "parameters": {
        "color": 7,
        "width": 760,
        "height": 400,
        "content": "## 图像生成"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -280
      ],
      "parameters": {
        "color": 7,
        "width": 780,
        "height": 400,
        "content": "## 基础图像和提示词"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -700
      ],
      "parameters": {
        "color": 7,
        "width": 780,
        "height": 400,
        "content": "## 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -1200
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 480,
        "content": "## 工作原理?"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -920
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 620,
        "content": "## 基础图像"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -720
      ],
      "parameters": {
        "color": 7,
        "width": 360,
        "height": 420,
        "content": "## 生成的图像"
      },
      "typeVersion": 1
    },
    {
      "id": "",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -520,
        -180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "",
              "name": "FalAITOKEN",
              "type": "string",
              "value": "[YOUR_API_TOKEN]"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Check IF Generated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "Generate Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image": {
      "main": [
        [
          {
            "node": "Check IF Generated",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Generate Prompt": {
      "main": [
        [
          {
            "node": "Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check IF Generated": {
      "main": [
        [
          {
            "node": "Log Image Posts",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Cloud Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Nasser

Nasser

@nasser

Data Engineer, now automating processes mostly with n8n, Make and code

外部链接
在 n8n.io 查看

分享此工作流