使用 Replicate 和 Flux 生成图像
中级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 14 个节点。主要使用 Code, Merge, Aggregate, HttpRequest, ManualTrigger 等节点。 使用 Replicate 和 Flux 生成图像
前置要求
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "52254486b159b349334953c1738da94e90477c7604aa8db2062d11afc0120739"
},
"nodes": [
{
"id": "a11410a3-6444-40f1-a564-7ee5707377b2",
"name": "上传图片2",
"type": "n8n-nodes-base.httpRequest",
"position": [
640,
-16
],
"parameters": {
"url": "https://articles.emp0.com/wp-json/wp/v2/media",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "binaryData",
"sendHeaders": true,
"authentication": "predefinedCredentialType",
"headerParameters": {
"parameters": [
{
"name": "Content-Disposition",
"value": "=attachment; filename=\"img-{{ $('Code1').item.json.slug }}.jpg\""
}
]
},
"inputDataFieldName": "data",
"nodeCredentialType": "wordpressApi"
},
"credentials": {
"wordpressApi": {
"id": "G1G8jDdEoWAVytQb",
"name": "Wordpress - anya@emp0.com"
}
},
"retryOnFail": true,
"typeVersion": 4.2,
"waitBetweenTries": 5000
},
{
"id": "d1d5d3e3-72aa-49a3-9411-a8a2bcfdfbb9",
"name": "HTTP 请求1",
"type": "n8n-nodes-base.httpRequest",
"position": [
240,
-16
],
"parameters": {
"url": "= https://api.replicate.com/v1/models/{{ $json.model }}/predictions",
"method": "POST",
"options": {},
"jsonBody": "={{ $json.model_config }}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "content-type",
"value": "application/json"
},
{
"name": "Prefer",
"value": "wait"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"id": "JvhQAEa4Frw0CDoq",
"name": "Leonardo AI"
},
"httpHeaderAuth": {
"id": "rv80WUvVdf5qIJTg",
"name": "Header Auth - replicate"
}
},
"typeVersion": 4.2
},
{
"id": "41c272ef-26de-4481-8490-4bd37d7e52aa",
"name": "HTTP请求2",
"type": "n8n-nodes-base.httpRequest",
"position": [
432,
-16
],
"parameters": {
"url": "={{ $json.output || $json.output[0] }}",
"options": {},
"sendHeaders": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{
"name": "accept",
"value": "application/json"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"id": "JvhQAEa4Frw0CDoq",
"name": "Leonardo AI"
},
"httpHeaderAuth": {
"id": "rv80WUvVdf5qIJTg",
"name": "Header Auth - replicate"
}
},
"typeVersion": 4.2
},
{
"id": "0ceb522f-0c64-41f1-a207-9188bc70af6e",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
192,
-112
],
"parameters": {
"color": 5,
"width": 384,
"height": 272,
"content": "## 使用 replicate 生成图像"
},
"typeVersion": 1
},
{
"id": "1289653b-9165-470b-b717-1a0649f5dbbd",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
592,
-112
],
"parameters": {
"color": 6,
"width": 342,
"height": 272,
"content": "## 上传"
},
"typeVersion": 1
},
{
"id": "26418c06-d385-4e56-a989-0ea71cf2ebd4",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
192,
176
],
"parameters": {
"color": 7,
"width": 768,
"height": 496,
"content": "## 图像已生成"
},
"typeVersion": 1
},
{
"id": "ccd10411-364b-4ea6-867a-d50063bfea83",
"name": "当点击“执行工作流”时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-144,
160
],
"parameters": {},
"typeVersion": 1
},
{
"id": "8057ae5d-d37b-47cd-829a-02e650b4e836",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
1296,
-32
],
"parameters": {
"jsCode": "return {\n \"public_image_url\" :$input.first().json.data[0].guid.raw,\n \"wordpress\":$input.first().json.data[0],\n \"twitter\":$input.first().json.data[1]\n}"
},
"typeVersion": 2
},
{
"id": "adfdcc3f-d411-47a7-83cd-7c3fa8e224a1",
"name": "当被其他工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-144,
-16
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "prompt"
},
{
"name": "slug"
},
{
"name": "model"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "97437ee7-8648-4807-82ed-44391787f9ad",
"name": "代码1",
"type": "n8n-nodes-base.code",
"position": [
64,
-16
],
"parameters": {
"jsCode": "const input = $input.first().json;\n\nconst models = {\n \"black-forest-labs/flux-dev\": {\n \"input\":{\n prompt: input.prompt,\n go_fast: true,\n guidance: 3.5,\n megapixels: \"1\",\n num_outputs: 1,\n aspect_ratio: \"16:9\",\n output_format: \"webp\",\n output_quality: 80,\n prompt_strength: 0.8,\n num_inference_steps: 28,\n }\n },\n \"black-forest-labs/flux-schnell\" : {\n \"input\": {\n \"prompt\": input.prompt,\n \"go_fast\": true,\n \"megapixels\": \"1\",\n \"num_outputs\": 1,\n \"aspect_ratio\": \"16:9\",\n \"output_format\": \"webp\",\n \"output_quality\": 80,\n \"num_inference_steps\": 4\n }\n },\n \"black-forest-labs/flux-1.1-pro\":{\n \"input\": {\n \"prompt\": input.prompt,\n \"aspect_ratio\": \"16:9\",\n \"output_format\": \"webp\",\n \"output_quality\": 100,\n \"safety_tolerance\": 2,\n \"prompt_upsampling\": true\n }\n }\n // You can define more models here\n};\n\nif (!models.hasOwnProperty(input.model)) {\n throw new Error(`Model \"${input.model}\" is not supported.`);\n}\n\nreturn {\n ...input,\n model: input.model,\n model_config: models[input.model],\n};\n"
},
"typeVersion": 2
},
{
"id": "0a7e0c9e-e149-4654-bc63-f5534244ce90",
"name": "合并",
"type": "n8n-nodes-base.merge",
"position": [
960,
-32
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "706c943b-9c62-4042-baaf-a08d5aeaa5ab",
"name": "上传媒体 (X)",
"type": "n8n-nodes-base.httpRequest",
"position": [
800,
-16
],
"parameters": {
"url": "https://upload.twitter.com/1.1/media/upload.json?media_category=TWEET_IMAGE",
"method": "POST",
"options": {
"response": {
"response": {
"responseFormat": "json"
}
}
},
"sendBody": true,
"contentType": "multipart-form-data",
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "media",
"parameterType": "formBinaryData",
"inputDataFieldName": "data"
}
]
},
"nodeCredentialType": "twitterOAuth1Api"
},
"credentials": {
"twitterOAuth1Api": {
"id": "HywNT47jE0Dh8NvQ",
"name": "X OAuth account"
}
},
"typeVersion": 4.2
},
{
"id": "8f0a060f-731d-4970-a2ec-0b48af4e2527",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
1120,
-32
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"typeVersion": 1
},
{
"id": "5ec62e6f-991f-4c59-b3b2-84cd6b8c168e",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-176,
400
],
"parameters": {
"color": 6,
"width": 342,
"height": 272,
"content": "## 模型与定价 / img"
},
"typeVersion": 1
}
],
"pinData": {
"When clicking ‘Execute workflow’": [
{
"slug": "joker-watching-batman",
"model": "black-forest-labs/flux-1.1-pro",
"prompt": "joker watching a batman movie on his laptop"
}
]
},
"connections": {
"Code1": {
"main": [
[
{
"node": "HTTP Request1",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request1": {
"main": [
[
{
"node": "HTTP Request2",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request2": {
"main": [
[
{
"node": "Upload image2",
"type": "main",
"index": 0
},
{
"node": "Upload Media (X)",
"type": "main",
"index": 0
}
]
]
},
"Upload image2": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Upload Media (X)": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
内容生成器 v3
AI驱动博客自动化:使用GPT-4生成并发布SEO文章至WordPress和Twitter
If
Set
Code
+25
144 节点Jay Emp0
内容创作
基于Web数据的AI图表生成与WordPress上传
基于Web数据的AI驱动图表生成,使用GPT-4o并上传至WordPress
Code
Http Request
Manual Trigger
+7
15 节点Jay Emp0
内容创作
使用Leonardo AI和WordPress生成并上传博客图片
使用Leonardo AI和WordPress生成并上传博客图片
Code
Wait
Http Request
+3
12 节点Jay Emp0
内容创作
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
内容聚合
使用Gemini AI从网站文章自动化社交媒体帖子发布到LinkedIn和X/Twitter
If
Set
Xml
+16
34 节点Vadim
内容创作
使用 OpenAI、ElevenLabs 和 Fal.ai 自动化病毒式内容创作,适用于视频、播客和 ASMR
使用 OpenAI、ElevenLabs 和 Fal.ai 自动化病毒式内容创作,适用于视频、播客和 ASMR
Set
Code
Wait
+16
97 节点Adam Crafts
内容创作
工作流信息
难度等级
中级
节点数量14
分类2
节点类型7
作者
Jay Emp0
@jay-emp0AI and Automation developer. Im implementing n8n and ai tools to automate marketing and sales in companies
外部链接
在 n8n.io 查看 →
分享此工作流