Overview
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 generates professional-quality video content perfect for tiktok, youtube, marketing campaigns, and creative projects.
Input: Creative prompt (required) + optional image
Output: AI-generated viral video ready for social media and content marketing
Users 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.
Prerequisites
- A Defapi account and API key: Sign up at Defapi.org to obtain your API key for Sora 2 access.
- An active n8n instance (cloud or self-hosted) with HTTP Request and form submission capabilities.
- Basic knowledge of AI prompts for video generation to achieve optimal results.
- 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.
- For 15-second HD videos, prefix your prompt with
(15s,hd)
.
- (Optional) An image to use as a reference or starting point for video generation.
- Image Restrictions: Avoid uploading images with real people or highly realistic human faces, as they will be rejected during content review.
- Important Notes:
- The API requires proper authentication via Bearer token for all requests.
- Content undergoes multi-stage moderation. Avoid violence, adult content, copyrighted material, and living celebrities in both prompts and images.
Setup Instructions
- Obtain API Key: Register at Defapi.org and generate your API key with Sora 2 access. Store it securely—do not share it publicly.
- Configure Credentials: In n8n, create HTTP Bearer Auth credentials named "Defapi account" with your API key.
- Configure the Form: In the "Upload Image" form trigger node, ensure the following fields are set up:
- Prompt (text field, required) - Describe the video scene you want to generate
- Image (file upload, optional) - Optionally upload .jpg, .png, or .webp image files as reference
- Test the Workflow:
- Click "Execute Workflow" in n8n to activate the form trigger.
- Access the generated form URL and enter your creative video prompt. Optionally upload an image for additional context.
- The workflow will process any uploaded image through the "Convert to JSON" node, converting it to base64 format.
- The request is sent to the Sora 2 API endpoint at Defapi.org.
- The system will wait 10 seconds and then poll the API status until video generation is complete.
- Handle Outputs: The final "Format and Display Results" node formats and displays the generated video URL for download or embedding.
Workflow Structure
The workflow consists of the following nodes:
- Upload Image (Form Trigger) - Collects user input: creative prompt (required) and optional image file
- Convert to JSON (Code Node) - Converts any uploaded image to base64 data URI and formats prompt
- Send Sora 2 Generation Request to Defapi.org API (HTTP Request) - Submits video generation request to Sora 2 API
- Wait for Processing Completion (Wait Node) - Waits 10 seconds before checking status
- Obtain the generated status (HTTP Request) - Polls API task query endpoint for completion status
- Check if Image Generation is Complete (IF Node) - Checks if status equals 'success'
- Format and Display Results (Set Node) - Extracts and formats final video URL output
Technical Details
Customization Tips
- Enhance Prompts: Include specifics like:
- Scene description and action sequences
- Character behaviors and emotions
- Camera movements and angles (e.g., slow-motion, dramatic zoom)
- Audio/music style (e.g., dramatic, upbeat, cinematic)
- Visual effects and atmosphere
- Timing and pacing details
- 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...
Content Moderation
The API implements a three-stage content review process:
- Image Review: Rejects images with real people or highly realistic human faces
- Prompt Filtering: Checks for violence, adult content, copyrighted material, and living celebrities
- Output Review: Final check after generation (often causes failures at 90%+ completion)
Best Practices:
- Avoid real human photos; use illustrations or cartoons instead
- Keep prompts generic; avoid brand names and celebrity names
- You can reference verified Sora accounts (e.g., "let @sama dance")
- If generation fails at 90%+, simplify your prompt and try again
Example Prompts
- "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."
- "(15s,hd) Animated fantasy landscape with floating islands, waterfalls cascading into clouds, magical creatures flying, golden sunset lighting, epic orchestral music."
- "(15s,hd) Product showcase with 360-degree rotation, dramatic lighting changes, particle effects, modern electronic background music."
Use Cases
- Social Media Content: Generate eye-catching videos for Instagram Reels, TikTok, and YouTube Shorts
- Marketing Campaigns: Create unique promotional videos from product images
- Creative Projects: Transform static images into dynamic storytelling videos
- Content Marketing: Produce engaging video content without expensive production costs
- Viral Content Creation: Generate shareable, attention-grabbing videos for maximum engagement