使用Sora 2 API生成病毒视频
中级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 11 个节点。主要使用 If, Set, Code, Wait, FormTrigger 等节点。 使用Sora 2 AI为营销和内容创作创建社交媒体视频
前置要求
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "hnQkgo39M1YbV8JR",
"meta": {
"instanceId": "8dc97f110c3d1c4c1312bf2ee1e5a9845338284bdb271e93c73c8939c0887ef7"
},
"name": "使用 Sora 2 API 生成病毒视频",
"tags": [],
"nodes": [
{
"id": "b120b3de-3959-4ac9-b57d-e69dcb3ea216",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1104,
16
],
"parameters": {
"color": 3,
"width": 780,
"height": 1016,
"content": "# 使用 Sora 2 API 生成病毒视频"
},
"typeVersion": 1
},
{
"id": "67dce728-a195-403b-9a53-e029adc6031a",
"name": "获取生成状态",
"type": "n8n-nodes-base.httpRequest",
"position": [
-16,
256
],
"parameters": {
"url": "https://api.defapi.org/api/task/query",
"options": {},
"sendQuery": true,
"sendHeaders": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"queryParameters": {
"parameters": [
{
"name": "task_id",
"value": "={{$json.data.task_id}}"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"credentials": {
"httpBearerAuth": {
"id": "uZqL4UNyrG73Kntx",
"name": "Defapi account"
}
},
"typeVersion": 4.2
},
{
"id": "e6193ed3-bde1-4ca5-ba5b-2b62c2106348",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
288,
528
],
"parameters": {
"width": 416,
"height": 480,
"content": "## 结果"
},
"typeVersion": 1
},
{
"id": "1c0ba59b-a0f1-4d7b-a9a8-dc415e6f0b14",
"name": "转换为 JSON",
"type": "n8n-nodes-base.code",
"position": [
-32,
32
],
"parameters": {
"jsCode": "/**\n * Encodes multiple binary files from an n8n input item into Base64 strings.\n *\n * This code assumes it is running in an n8n \"Code\" or \"Function\" node\n * where 'this' refers to the node's context and 'helpers' are available.\n *\n * @returns {object} An object containing an array of file objects,\n * each with a 'path' and 'data' (Base64 string).\n */\nconst results = {args: {}};\nconsole.log('----', $input.first());\n\nconst bin = $input.first().binary?.['Image'];\n\n// Push a new object to the results array.\nif (bin) {\n results.args.images = [`data:${bin.mimeType};base64,${bin.data}`]\n}\nresults.args.prompt = $input.first().json['Prompt']\n\n// Return the final object in the expected format for the next node.\nreturn results;\n"
},
"typeVersion": 2
},
{
"id": "5987c5d7-e3ee-45ac-808f-48bdfa444748",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-304,
528
],
"parameters": {
"width": 544,
"height": 128,
"content": "## 示例提示"
},
"typeVersion": 1
},
{
"id": "8c98ae55-80b6-43aa-bd52-0ea3b78ebfb3",
"name": "格式化并显示结果",
"type": "n8n-nodes-base.set",
"position": [
432,
320
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "fa5f375f-cddc-4f7b-a018-67c28015d18b",
"name": "image_url",
"type": "string",
"value": "={{$json.data.result.video}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "2573c2b2-fed6-4ebd-8034-e87c6cc464c4",
"name": "发送 Sora 2 生成请求到 Defapi.org API",
"type": "n8n-nodes-base.httpRequest",
"position": [
192,
32
],
"parameters": {
"url": "https://api.defapi.org/api/sora2/gen",
"method": "POST",
"options": {},
"jsonBody": "={{ JSON.stringify($json.args, null, 2) }}",
"sendBody": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "uZqL4UNyrG73Kntx",
"name": "Defapi account"
}
},
"typeVersion": 4.2
},
{
"id": "70d6346b-9ae3-42d9-8af6-66add1b1e3b3",
"name": "等待处理完成",
"type": "n8n-nodes-base.wait",
"position": [
-240,
320
],
"webhookId": "e1e38844-d037-40bd-b420-0c89e86348b5",
"parameters": {
"amount": 10
},
"typeVersion": 1.1
},
{
"id": "7b882afa-5fa9-4188-b225-77c77f506cf5",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-304,
672
],
"parameters": {
"width": 544,
"height": 352,
"content": ""
},
"typeVersion": 1
},
{
"id": "d3932fe6-2a4a-468d-bf7e-8006e35b0625",
"name": "表单提交时",
"type": "n8n-nodes-base.formTrigger",
"position": [
-256,
32
],
"webhookId": "035fad50-e97c-4155-939d-c26c2545f743",
"parameters": {
"options": {},
"formTitle": "Upload Image",
"formFields": {
"values": [
{
"fieldLabel": "Prompt",
"requiredField": true
},
{
"fieldType": "file",
"fieldLabel": "Image",
"multipleFiles": false,
"acceptFileTypes": ".jpg,.png,.webp"
}
]
}
},
"typeVersion": 2.3
},
{
"id": "b0c9e335-8e5b-4904-a8d1-fcea76eeceeb",
"name": "检查生成是否完成",
"type": "n8n-nodes-base.if",
"position": [
208,
320
],
"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.status == 'success' }}"
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "c0b1c92f-782e-4d36-a1ea-c7459e116c47",
"connections": {
"Convert to JSON": {
"main": [
[
{
"node": "Send Sora 2 Generation Request to Defapi.org API",
"type": "main",
"index": 0
}
]
]
},
"On form submission": {
"main": [
[
{
"node": "Convert to JSON",
"type": "main",
"index": 0
}
]
]
},
"Obtain the generated status": {
"main": [
[
{
"node": "Check if Generation is Complete",
"type": "main",
"index": 0
}
]
]
},
"Wait for Processing Completion": {
"main": [
[
{
"node": "Obtain the generated status",
"type": "main",
"index": 0
}
]
]
},
"Check if Generation is Complete": {
"main": [
[
{
"node": "Format and Display Results",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait for Processing Completion",
"type": "main",
"index": 0
}
]
]
},
"Send Sora 2 Generation Request to Defapi.org API": {
"main": [
[
{
"node": "Wait for Processing Completion",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 Google Drive 和 Nano Banana API 的批量证件照转换器和增强器
使用 Google Drive 和 Nano Banana API 的批量证件照转换器和增强器
If
Set
Code
+5
16 节点panyanyany
内容创作
## 设置指南
使用 Gemini AI 生成复古宝丽来风格照片
If
Set
Code
+4
13 节点panyanyany
内容创作
使用Nano Banana AI将自拍转换为3D手办
使用Nano Banana AI将自拍转换为3D手办
If
Set
Code
+4
11 节点panyanyany
杂项
WordPress博客自动化专业版(深度研究)v2.1市场
使用GPT-4o、Perplexity AI和多语言支持自动化SEO优化的博客创建
If
Set
Xml
+27
125 节点Daniel Ng
内容创作
使用OpenAI和Firecrawl从产品URL创建AI生成的Meta广告活动
使用OpenAI和Firecrawl从产品URL创建AI生成的Meta广告活动
If
Set
Code
+15
40 节点Adam Crafts
内容创作
从您的多个参考图像生成视频片段
使用 Fal.ai VIDU 从参考图像创建病毒式视频并上传到 YouTube/TikTok
If
Set
Code
+6
20 节点Davide
内容创作