This workflow corresponds to n8n.io template #9337 — we link there as the canonical source.
This workflow follows the Form Trigger → HTTP Request recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "hnQkgo39M1YbV8JR",
"name": "Generate Viral Video Using Sora 2 API",
"tags": [],
"nodes": [
{
"id": "b120b3de-3959-4ac9-b57d-e69dcb3ea216",
"name": "Sticky Note3",
"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 YOUR_TOKEN_HERE 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\u2014do not share it publicly.\n2. **Configure Credentials**: In n8n, create HTTP Bearer YOUR_TOKEN_HERE 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 YOUR_TOKEN_HERE 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": "Obtain the generated status",
"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": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "e6193ed3-bde1-4ca5-ba5b-2b62c2106348",
"name": "Sticky Note4",
"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": "Convert to 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": "Sticky Note",
"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": "Format and Display Results",
"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": "Send Sora 2 Generation Request to 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": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "70d6346b-9ae3-42d9-8af6-66add1b1e3b3",
"name": "Wait for Processing Completion",
"type": "n8n-nodes-base.wait",
"position": [
-240,
320
],
"parameters": {
"amount": 10
},
"typeVersion": 1.1
},
{
"id": "7b882afa-5fa9-4188-b225-77c77f506cf5",
"name": "Sticky Note1",
"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": "On form submission",
"type": "n8n-nodes-base.formTrigger",
"position": [
-256,
32
],
"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": "Check if Generation is Complete",
"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,
"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
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
httpBearerAuth
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This 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…
Source: https://n8n.io/workflows/9337/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow is designed to take user inputs in order to generate an image using the Riverflow 2.0 model through the Replicate API. It can handle both image generation as well as image editing. Addit
Sales teams looking to build targeted company lead lists
Paste your webinar recording URL into a simple form — and this workflow does the rest automatically. WayinVideo AI scans the full recording and extracts the most engaging clip segments, ready for your
The Recap AI - Insurance Lawyer Lead Gen. Uses executeWorkflowTrigger, formTrigger, @mendable/n8n-nodes-firecrawl, googleSheets. Event-driven trigger; 33 nodes.
Trending YouTube Videos copy. Uses googleSheets, openAi, httpRequest, stickyNote. Event-driven trigger; 12 nodes.