使用KIE.AI Midjourney API生成AI图像和视频
中级
这是一个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": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1232,
0
],
"parameters": {
"width": 780,
"height": 120,
"content": "## STEP 1 - GET API KEY (YOURAPIKEY)\n- Create an account [here](https://kie.ai/) and obtain API KEY.\n- It will be used in on form submission.\n- Important: Please keep your key safe and do not disclose it to others."
},
"typeVersion": 1
},
{
"id": "22d993e4-94ae-45d6-893f-8c048438a0dc",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
1232,
208
],
"parameters": {
"width": 780,
"height": 180,
"content": "## STEP 2 - Usage Process\n1. **Start Workflow** - Click \"Execute workflow\" button to begin the task.\n2. **Fill Form** - Complete the required fields in the popup form.\n3. **Submit - Click** \"Submit\" button to send your request.\n4. **Close Window** - You can close the form window after successful submission.\n5. **Wait for Generation** - System automatically checks status every 10 seconds.\n6. **Get Results** - Video files will be displayed automatically when generation is complete."
},
"typeVersion": 1
},
{
"id": "a511baf3-1db7-458f-b0fe-e5198028d4b8",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-160,
-80
],
"parameters": {
"color": 3,
"width": 1148,
"height": 1576,
"content": "## Generate AI Images & Videos with KIE.AI Midjourney API\n### Overview\nGenerate high-quality AI images and videos using KIE.AI's Midjourney API through an intuitive form interface. This n8n workflow supports three distinct content creation modes, delivering professional results with automated processing and real-time progress monitoring.\n**Supported Modes:**\n- **Text-to-Image** (`mj_txt2img`): Generate original images from written descriptions\n- **Image-to-Image** (`mj_img2img`): Transform or enhance existing images with AI\n- **Image-to-Video** (`mj_video`): Animate still images into short video clips\nUsers interact only through a simple form interface, requiring no coding skills. After submitting a request, the system automatically calls the KIE.AI API, monitors progress in real-time, and retrieves the final output once ready.\n### Perfect for\nContent creators, designers, marketers, and developers who need to quickly generate diverse AI visual content with automated processing and professional quality results.\n### Prerequisites\n- **KIE.AI Account**: Sign up at [KIE.AI](https://kie.ai) to obtain your free or paid API key.\n- **n8n Instance**: Active n8n instance (cloud or self-hosted) with HTTP Request and form submission capabilities.\n- **AI Prompt Knowledge**: Basic understanding of AI prompts for optimal generation results.\n- **Reference Images** (Optional): Publicly accessible image URLs for image-to-image or image-to-video generation.\n### Quick Setup\n#### 1. **Get API Key**\nRegister at [KIE.AI](https://kie.ai) and generate your API key. Store it securely and never share it publicly.\n#### 2. **Configure Form Fields**\nSet up these fields in your \"On Form Submission\" node:\n- **`tasktype`** (Required): Select generation mode\n - `mj_txt2img` for text-to-image generation\n - `mj_img2img` for image-to-image generation \n - `mj_video` for image-to-video generation\n- **`prompt`** (Required): Text description for your content generation\n- **`imgurl`** (Optional): Image URL array for image-to-image or image-to-video generation\n - **Important**: Leave empty for text-to-image generation (`mj_txt2img`)\n- **`api_key`** (Required): Your KIE.AI API key for authentication\n#### 3. **Test & Use**\n1. Click \"Execute Workflow\" in n8n.\n2. Access the generated form URL.\n3. Fill in your details and submit.\n4. Wait for processing (workflow polls every 10 seconds).\n5. Results will be displayed automatically.\n### Customization Tips\n#### Write Detailed Prompts:\nInclude specific details for better results:\n- **Style**: realistic, anime, cinematic, watercolor, oil painting\n- **Composition**: close-up, wide shot, portrait, landscape\n- **Lighting**: dramatic, soft, neon, natural, studio\n- **Subject Details**: actions, scenes, movements, visual elements\n#### Example Enhanced Prompt:\n\"Cinematic portrait of a cyberpunk character with neon blue lighting, close-up composition, dramatic shadows, futuristic mood\"\n#### Leverage Multiple Modes:\n- Start with text-to-image for initial concepts.\n- Use image-to-image to refine and enhance results.\n- Apply image-to-video to animate your best images.\n- Combine modes for complex creative workflows.\n#### Common Use Cases:\n- Social media content creation.\n- Marketing material development.\n- Product visualization.\n- Storyboarding and prototyping.\n- Creative asset generation.\n### Troubleshooting\n- **API Key Invalid**: Verify your key is correct and active.\n- **Generation Fails**: Check prompt length and content appropriateness.\n- **Slow Processing**: Video generation can take 2-5 minutes; this is normal.\n- **Image URL Issues**: Ensure URLs are publicly accessible and properly formatted.\n**Keywords:** KIE.AI API, AI image generation, AI video generation, text-to-image, image-to-video, automated workflows, n8n template, AI content creation"
},
"typeVersion": 1
},
{
"id": "c4edd10d-0ce7-4431-8e8a-cea2e8a41f67",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1232,
496
],
"parameters": {
"width": 780,
"height": 552,
"content": "## STEP 3 - Form Parameters\n1. **Prompt** \n - Purpose: Describe the video content you want to generate.\n - Example: \"A dog playing in a park\".\n - Tips:\n Be detailed and specific in describing video content.\n Include actions, scenes, and style information.\n Describe movements and visual elements you want to see.\n More detailed descriptions lead to better results.\n2. **img_url** (Image-to-Video, Optional)\n - Purpose: Provide an image URL for image-to-image or image-to-video generation. Note: If you are using text-to-image generation (mj_txt2img), please do not fill in this parameter.\n - Example: https://file.example.com/your-image.jpg\n - Tips:\n Required for: mj_img2img (image-to-image) and mj_video/mj_video_hd (image-to-video).\n Not needed for: mj_txt2img (text-to-image) - leave this field empty.\n Use a clear and relevant image to guide the generation.\n3. **task_type (Task Type)** \n - Purpose: Select the type of AI generation task you want to perform.\n - Options: mj_txt2img (text-to-image),mj_img2img (image-to-image),mj_video (image-to-video)\nmj_video_hd (image-to-high-definition-video)\n - Tips:Choose mj_video or mj_video_hd for video generation. Choose mj_txt2img for text-to-image generation. Choose mj_img2img for image-to-image generation.\n4. **api_key** (API Key)\n - This is what you get in the first step.\n"
},
"typeVersion": 1
},
{
"id": "2c5110d0-2789-43ba-8097-fe6b415483b2",
"name": "Submit Text Prompt for Video Generation",
"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": "Send Video Generation Request to 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": "Wait for Video Processing Completion",
"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": "Obtain the generated status",
"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": "Check if Video Generation is Complete",
"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": "Format and Display Video Results",
"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": {
"7d9755a2-0391-413e-a8fb-b4ac5c78aba1": {
"main": [
[
{
"node": "fa6a595c-9504-40d9-b1ae-10df8b60fcd1",
"type": "main",
"index": 0
}
]
]
},
"e5612a76-7d1e-46b4-b8e7-ca1accf8e316": {
"main": [
[
{
"node": "7d9755a2-0391-413e-a8fb-b4ac5c78aba1",
"type": "main",
"index": 0
}
]
]
},
"fa6a595c-9504-40d9-b1ae-10df8b60fcd1": {
"main": [
[
{
"node": "94e27cb8-5a53-43f6-9c1a-3b8433f9fb77",
"type": "main",
"index": 0
}
],
[
{
"node": "e5612a76-7d1e-46b4-b8e7-ca1accf8e316",
"type": "main",
"index": 0
}
]
]
},
"2c5110d0-2789-43ba-8097-fe6b415483b2": {
"main": [
[
{
"node": "478b1370-b1c2-476a-83ee-384c23fc6092",
"type": "main",
"index": 0
}
]
]
},
"478b1370-b1c2-476a-83ee-384c23fc6092": {
"main": [
[
{
"node": "e5612a76-7d1e-46b4-b8e7-ca1accf8e316",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 杂项, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用KIE.AI Nano Banana API生成角色一致的AI图像
使用KIE.AI Nano Banana API生成角色一致的AI图像
If
Set
Wait
+
If
Set
Wait
10 节点damo
杂项
使用KIE.ai API和表单界面通过Suno V3.5生成AI音乐
使用KIE.ai API和表单界面通过Suno V3.5生成AI音乐
If
Set
Wait
+
If
Set
Wait
10 节点yichao zeng
内容创作
使用KIE.AI Veo3从文本提示生成AI视频
使用KIE.AI Veo3从文本提示生成AI视频
If
Set
Wait
+
If
Set
Wait
10 节点yichao zeng
内容创作
使用AI将PDF采购订单自动化转换为Adobe Commerce销售订单
使用AI将PDF采购订单自动化转换为Adobe Commerce销售订单
If
Set
Code
+
If
Set
Code
96 节点JKingma
文档提取
使用 BananaAPI 和 Nano Banana 引擎通过文本提示生成 AI
使用 BananaAPI 和 Nano Banana 引擎通过文本提示生成 AI 图像
If
Set
Wait
+
If
Set
Wait
16 节点Tran Trung Nghia
内容创作
使用Veo3 API和VietVid.com从文本或图像生成AI视频
使用Veo3 API和VietVid.com从文本或图像生成AI视频
If
Set
Wait
+
If
Set
Wait
13 节点Tran Trung Nghia
内容创作