8
n8n 中文网amn8n.com

mj

中级

这是一个Miscellaneous, Multimodal AI领域的自动化工作流,包含 10 个节点。主要使用 If, Set, Wait, FormTrigger, HttpRequest 等节点。 使用KIE.AI Midjourney API生成AI图像和视频

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "PNYUq9YR60V9ZDpj",
  "meta": {
    "instanceId": "984a3a573b2ceefaa62e65118c88bad010712c3575386e48d0fa024f616c2747"
  },
  "name": "mj",
  "tags": [],
  "nodes": [
    {
      "id": "7874a7d7-0078-492f-937a-67b529a99f97",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        0
      ],
      "parameters": {
        "width": 780,
        "height": 120,
        "content": "## 步骤 1 - 获取 API 密钥 (YOURAPIKEY)"
      },
      "typeVersion": 1
    },
    {
      "id": "22d993e4-94ae-45d6-893f-8c048438a0dc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        208
      ],
      "parameters": {
        "width": 780,
        "height": 180,
        "content": "## 步骤 2 - 使用流程"
      },
      "typeVersion": 1
    },
    {
      "id": "a511baf3-1db7-458f-b0fe-e5198028d4b8",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -80
      ],
      "parameters": {
        "color": 3,
        "width": 1148,
        "height": 1576,
        "content": "## 使用 KIE.AI Midjourney API 生成 AI 图像和视频"
      },
      "typeVersion": 1
    },
    {
      "id": "c4edd10d-0ce7-4431-8e8a-cea2e8a41f67",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        496
      ],
      "parameters": {
        "width": 780,
        "height": 552,
        "content": "## 步骤 3 - 表单参数"
      },
      "typeVersion": 1
    },
    {
      "id": "2c5110d0-2789-43ba-8097-fe6b415483b2",
      "name": "提交文本提示进行视频生成",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        640,
        1584
      ],
      "webhookId": "791b190b-2acc-4d10-b593-c1929e67686c",
      "parameters": {
        "options": {},
        "formTitle": "AI video generator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "prompt"
            },
            {
              "fieldLabel": "img_url"
            },
            {
              "fieldLabel": "task_type",
              "placeholder": "mj_txt2img"
            },
            {
              "fieldLabel": "api_key"
            }
          ]
        },
        "formDescription": "Please fill in the following information to generate your video"
      },
      "typeVersion": 2.2
    },
    {
      "id": "478b1370-b1c2-476a-83ee-384c23fc6092",
      "name": "发送视频生成请求到 KIE.AI API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        864,
        1584
      ],
      "parameters": {
        "url": "https://api.kie.ai/api/v1/mj/generate",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"taskType\": \"{{$json.task_type}}\",\n  \"speed\": \"fast\",\n  \"prompt\": \"{{$json.prompt}}\",\n  \"fileUrls\": \"{{$json.img_url ? [$json.img_url] : []}}\",\n  \"aspectRatio\": \"16:9\",\n  \"version\": \"7\",\n  \"variety\": 10,\n  \"stylization\": 1,\n  \"weirdness\": 1,\n  \"waterMark\": \"\",\n  \"callBackUrl\": \"https://api.example.com/callback\",\n  \"ow\": 500,\n  \"videoBatchSize\": 1\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": "e5612a76-7d1e-46b4-b8e7-ca1accf8e316",
      "name": "等待视频处理完成",
      "type": "n8n-nodes-base.wait",
      "position": [
        1104,
        1584
      ],
      "webhookId": "bb6c2821-9586-44b7-8606-2ee69a77ed75",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "7d9755a2-0391-413e-a8fb-b4ac5c78aba1",
      "name": "获取生成状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1312,
        1584
      ],
      "parameters": {
        "url": "https://api.kie.ai/api/v1/mj/record-info",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "taskId",
              "value": "={{$json.data.taskId}}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{$node[\"Submit Text Prompt for Video Generation\"].json[\"api_key\"]}}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fa6a595c-9504-40d9-b1ae-10df8b60fcd1",
      "name": "检查视频生成是否完成",
      "type": "n8n-nodes-base.if",
      "position": [
        1152,
        1808
      ],
      "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.successFlag == 1 }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "94e27cb8-5a53-43f6-9c1a-3b8433f9fb77",
      "name": "格式化并显示视频结果",
      "type": "n8n-nodes-base.set",
      "position": [
        1520,
        1792
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fa5f375f-cddc-4f7b-a018-67c28015d18b",
              "name": "img1",
              "type": "string",
              "value": "={{ $json.data.resultInfoJson.resultUrls[0].resultUrl }}"
            },
            {
              "id": "8f93e12e-13da-495f-a686-c0abc22f39d9",
              "name": "img2",
              "type": "string",
              "value": "={{ $json.data.resultInfoJson.resultUrls[1].resultUrl }}"
            },
            {
              "id": "9b0893fb-f0ad-4aaa-a709-d32fbe4947a4",
              "name": "img3",
              "type": "string",
              "value": "={{ $json.data.resultInfoJson.resultUrls[2].resultUrl }}"
            },
            {
              "id": "e5301b8c-700e-4d0d-a2c8-1538071cd7e0",
              "name": "img4",
              "type": "string",
              "value": "={{ $json.data.resultInfoJson.resultUrls[3].resultUrl }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "212ee606-7da0-4985-b493-7cc97e74f2d3",
  "connections": {
    "Obtain the generated status": {
      "main": [
        [
          {
            "node": "Check if Video Generation is Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Video Processing Completion": {
      "main": [
        [
          {
            "node": "Obtain the generated status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Video Generation is Complete": {
      "main": [
        [
          {
            "node": "Format and Display Video Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Video Processing Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit Text Prompt for Video Generation": {
      "main": [
        [
          {
            "node": "Send Video Generation Request to KIE.AI API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Video Generation Request to KIE.AI API": {
      "main": [
        [
          {
            "node": "Wait for Video Processing Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 杂项, 多模态 AI

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流