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": "Generate Viral Video Using 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": "# Generate Viral Video Using Sora 2 API\n\n## Overview\nThis workflow utilizes the Defapi API with **Sora 2 AI** model to generate stunning **viral videos** with creative AI-generated motion, effects, and storytelling. Simply provide a creative prompt describing your desired video scene, and optionally upload an image as a reference. The AI generates professional-quality video content perfect for tiktok, youtube, marketing campaigns, and creative projects.\n\n**Input:** Creative prompt (required) + optional image \n**Output:** AI-generated viral video ready for social media and content marketing\n\nUsers can interact through a simple form, providing a text prompt describing the desired video scene and optionally uploading an image for context. The system automatically submits the request to the Defapi Sora 2 API, monitors the generation status in real time, and retrieves the final video output. This solution is ideal for content creators, social media marketers, video producers, and businesses who want to quickly generate engaging video content with minimal setup.\n\n## Prerequisites\n- A Defapi account and API key: Sign up at [Defapi.org](https://defapi.org) to obtain your API key for Sora 2 access.\n- An active n8n instance (cloud or self-hosted) with HTTP Request and form submission capabilities.\n- Basic knowledge of AI prompts for video generation to achieve optimal results.\n - Example prompt: A pack of dogs driving tiny cars in a high-speed chase through a city, wearing sunglasses and honking their horns, with dramatic action music and slow-motion jumps over fire hydrants.\n - For 15-second HD videos, prefix your prompt with `(15s,hd)`.\n- (Optional) An image to use as a reference or starting point for video generation.\n - **Image Restrictions**: Avoid uploading images with real people or highly realistic human faces, as they will be rejected during content review.\n- **Important Notes**: \n - The API requires proper authentication via Bearer token for all requests.\n - Content undergoes multi-stage moderation. Avoid violence, adult content, copyrighted material, and living celebrities in both prompts and images.\n\n## Setup Instructions\n1. **Obtain API Key**: Register at Defapi.org and generate your API key with Sora 2 access. Store it securely—do not share it publicly.\n2. **Configure Credentials**: In n8n, create HTTP Bearer Auth credentials named \"Defapi account\" with your API key.\n3. **Configure the Form**: In the \"Upload Image\" form trigger node, ensure the following fields are set up:\n - **Prompt** (text field, required) - Describe the video scene you want to generate\n - **Image** (file upload, optional) - Optionally upload .jpg, .png, or .webp image files as reference\n4. **Test the Workflow**:\n - Click \"Execute Workflow\" in n8n to activate the form trigger.\n - Access the generated form URL and enter your creative video prompt. Optionally upload an image for additional context.\n - The workflow will process any uploaded image through the \"Convert to JSON\" node, converting it to base64 format.\n - The request is sent to the Sora 2 API endpoint at Defapi.org.\n - The system will wait 10 seconds and then poll the API status until video generation is complete.\n5. **Handle Outputs**: The final \"Format and Display Results\" node formats and displays the generated video URL for download or embedding.\n\n## Workflow Structure\nThe workflow consists of the following nodes:\n1. **Upload Image** (Form Trigger) - Collects user input: creative prompt (required) and optional image file\n2. **Convert to JSON** (Code Node) - Converts any uploaded image to base64 data URI and formats prompt\n3. **Send Sora 2 Generation Request to Defapi.org API** (HTTP Request) - Submits video generation request to Sora 2 API\n4. **Wait for Processing Completion** (Wait Node) - Waits 10 seconds before checking status\n5. **Obtain the generated status** (HTTP Request) - Polls API task query endpoint for completion status\n6. **Check if Image Generation is Complete** (IF Node) - Checks if status equals 'success'\n7. **Format and Display Results** (Set Node) - Extracts and formats final video URL output\n\n## Technical Details\n- **API Endpoint**: `https://api.defapi.org/api/sora2/gen` (POST request)\n- **Model Used**: Sora 2 AI video generation model\n- **Video Capabilities**: Supports 15-second videos and high-definition (HD) output\n- **Status Check Endpoint**: `https://api.defapi.org/api/task/query` (GET request)\n- **Wait Time**: 10 seconds between status checks\n- **Image Processing**: If an image is uploaded, it is converted to base64 data URI format (`data:image/[type];base64,[data]`) for API submission\n- **Authentication**: Bearer token authentication using the configured Defapi account credentials\n- **Request Body Format**:\n ```json\n {\n \"prompt\": \"Your video description here\",\n \"images\": [\"data:image/jpeg;base64,...\"]\n }\n ```\n Note: The `images` array can contain an image or be empty if no image is provided\n- **Response Format**: The API returns a task_id which is used to poll for completion status. Final result contains `data.result.video` with the video URL.\n- **Accepted Image Formats**: .jpg, .png, .webp\n- **Specialized For**: Viral video content, social media videos, creative video marketing\n\n## Customization Tips\n- **Enhance Prompts**: Include specifics like:\n - Scene description and action sequences\n - Character behaviors and emotions\n - Camera movements and angles (e.g., slow-motion, dramatic zoom)\n - Audio/music style (e.g., dramatic, upbeat, cinematic)\n - Visual effects and atmosphere\n - Timing and pacing details\n- **Enable 15s and HD Output**: To generate 15-second high-definition videos, start your prompt with `(15s,hd)`. For example: `(15s,hd) A pack of dogs driving tiny cars in a high-speed chase through a city...`\n\n## Content Moderation\n\nThe API implements a three-stage content review process:\n\n1. **Image Review**: Rejects images with real people or highly realistic human faces\n2. **Prompt Filtering**: Checks for violence, adult content, copyrighted material, and living celebrities\n3. **Output Review**: Final check after generation (often causes failures at 90%+ completion)\n\n**Best Practices:**\n- Avoid real human photos; use illustrations or cartoons instead\n- Keep prompts generic; avoid brand names and celebrity names\n- You can reference verified Sora accounts (e.g., \"let @sama dance\")\n- If generation fails at 90%+, simplify your prompt and try again\n\n## Example Prompts\n- \"A pack of dogs driving tiny cars in a high-speed chase through a city, wearing sunglasses and honking their horns, with dramatic action music and slow-motion jumps over fire hydrants.\"\n- \"(15s,hd) Animated fantasy landscape with floating islands, waterfalls cascading into clouds, magical creatures flying, golden sunset lighting, epic orchestral music.\"\n- \"(15s,hd) Product showcase with 360-degree rotation, dramatic lighting changes, particle effects, modern electronic background music.\"\n\n## Use Cases\n- **Social Media Content**: Generate eye-catching videos for Instagram Reels, TikTok, and YouTube Shorts\n- **Marketing Campaigns**: Create unique promotional videos from product images\n- **Creative Projects**: Transform static images into dynamic storytelling videos\n- **Content Marketing**: Produce engaging video content without expensive production costs\n- **Viral Content Creation**: Generate shareable, attention-grabbing videos for maximum engagement\n\n"
},
"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": "## Result\n"
},
"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": "## Example prompt\nA pack of dogs driving tiny cars in a high-speed chase through a city, wearing sunglasses and honking their horns, with dramatic action music and slow-motion jumps over fire hydrants."
},
"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": "Defapi.orgへのSora 2生成リクエスト送信 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": "\n## Content Moderation\n\nThe API implements a three-stage content review process:\n\n1. **Image Review**: Rejects images with real people or highly realistic human faces\n2. **Prompt Filtering**: Checks for violence, adult content, copyrighted material, and living celebrities\n3. **Output Review**: Final check after generation (often causes failures at 90%+ completion)\n\n**Best Practices:**\n- Avoid real human photos; use illustrations or cartoons instead\n- Keep prompts generic; avoid brand names and celebrity names\n- You can reference verified Sora accounts (e.g., \"let @sama dance\")\n- If generation fails at 90%+, simplify your prompt and try again"
},
"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": {
"1c0ba59b-a0f1-4d7b-a9a8-dc415e6f0b14": {
"main": [
[
{
"node": "2573c2b2-fed6-4ebd-8034-e87c6cc464c4",
"type": "main",
"index": 0
}
]
]
},
"d3932fe6-2a4a-468d-bf7e-8006e35b0625": {
"main": [
[
{
"node": "1c0ba59b-a0f1-4d7b-a9a8-dc415e6f0b14",
"type": "main",
"index": 0
}
]
]
},
"67dce728-a195-403b-9a53-e029adc6031a": {
"main": [
[
{
"node": "b0c9e335-8e5b-4904-a8d1-fcea76eeceeb",
"type": "main",
"index": 0
}
]
]
},
"70d6346b-9ae3-42d9-8af6-66add1b1e3b3": {
"main": [
[
{
"node": "67dce728-a195-403b-9a53-e029adc6031a",
"type": "main",
"index": 0
}
]
]
},
"b0c9e335-8e5b-4904-a8d1-fcea76eeceeb": {
"main": [
[
{
"node": "8c98ae55-80b6-43aa-bd52-0ea3b78ebfb3",
"type": "main",
"index": 0
}
],
[
{
"node": "70d6346b-9ae3-42d9-8af6-66add1b1e3b3",
"type": "main",
"index": 0
}
]
]
},
"2573c2b2-fed6-4ebd-8034-e87c6cc464c4": {
"main": [
[
{
"node": "70d6346b-9ae3-42d9-8af6-66add1b1e3b3",
"type": "main",
"index": 0
}
]
]
}
}
}よくある質問
このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
中級 - コンテンツ作成, マルチモーダルAI
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
Google Drive および Nano Banana API を使用したバッチ証明写真変換機・アップグレード機
Google Drive と Nano Banana API を使ったバッチ証明写真変換機とアップグレード機
If
Set
Code
+
If
Set
Code
16 ノードpanyanyany
コンテンツ作成
## 設定ガイド
Gemini AI を使ってレトロポリタオ風の写真を生成
If
Set
Code
+
If
Set
Code
13 ノードpanyanyany
コンテンツ作成
WordPressブログの自動化プロフェッショナル版(先端研究)v2.1マーケットプラグイン
GPT-4o、Perplexity AI、そして多言語対応を使ったSEO最適化ブログ作成の自動化
If
Set
Xml
+
If
Set
Xml
125 ノードDaniel Ng
コンテンツ作成
OpenAIとFirecrawlを使って製品URLからAI生成のMeta広告キャンペーンを作成する
OpenAI と Firecrawl を使って製品 URL から AI 生成の Meta 広告キャンペーンを作成
If
Set
Code
+
If
Set
Code
40 ノードAdam Crafts
コンテンツ作成
複数のリファレンス画像からビデオクリップを生成
Fal.ai VIDU を使って参照画像からウイルスのな動画を作成して YouTube/TikTok にアップロード
If
Set
Code
+
If
Set
Code
20 ノードDavide
コンテンツ作成
Nano Banana APIを使用した商品アイデアジェネレーター
Defapiを使用してGoogle Nano-Bananaモデルを使用して製品イメージを生成する
If
Set
Wait
+
If
Set
Wait
11 ノードpanyanyany
その他