Back to Home

Sora 2 n8n Pipeline for Video

n8n pipeline automates video production with Sora 2: random idea combinations, render via proxy, polling, YouTube publication. Cost $0.15/video, 6 videos per day.

Video Automation with Sora 2 in n8n
Advertisement 728x90

# Automating Video Content with Sora 2 and n8n: The Complete Pipeline

The pipeline starts with an entropy module in JavaScript and LangChain. Instead of generating ideas from scratch with an LLM, predefined arrays are used: actions (skydiving, meditating, playing guitar), subjects (cyberpunk samurai, giant marshmallow man, majestic dragon), settings (neon-lit Tokyo alley, minecraft world, Studio Ghibli landscape). The script in the Code node randomly combines elements, forming basic setups like "cyberpunk samurai meditating in a forest made of candy".

Prompt Agent based on LangChain (z-ai/glm-4.5-air model via OpenRouter) details the combination into a cinematic prompt. The Formatting node cleans the output with regular expressions: removes asterisks, extra line breaks, and quotes. This is critical for Sora 2, which is sensitive to JSON format in API requests.

Video Rendering via Proxy

Video generation happens through the api.kie.ai gateway in the HTTP Request node (POST). Parameters:

Google AdInline article slot
  • model: "sora-2-text-to-video"
  • n_frames: 10 (balance of dynamics and costs)
  • aspect_ratio: "portrait" (9:16 for Shorts/Reels)
  • remove_watermark: true

Cost per video is about $0.15. The official Sora API is limited; the proxy provides access for mass rendering.

Handling Asynchronicity with Polling

API returns taskId, file is prepared asynchronously. Polling is used:

  • Wait Node: 10-minute pause.
  • GET request to recordInfo by taskId.
  • If node: status check (code 200, presence of resultJson).

On error — Stop and Error branch. On success — JSON parsing to extract MP4 link.

Google AdInline article slot

Final Packaging and Publishing

Parallelly, Description Writer (LLM agent) launches: generates a clickbait title for YouTube Shorts from the original prompt (one phrase).

Sequence:

  • HTTP Request2: download MP4 in binary format.
  • YouTube Upload: upload to channel with title and category.

Scaling and Launch

Schedule trigger every 4 hours — 6 videos per day, budget <$1. Fully autonomous: randomizer for ideas, Sora for rendering, automated publishing.

Google AdInline article slot

Key Points:

  • Controlled randomness instead of pure LLM for unique visuals.
  • Polling with 10-minute pause minimizes requests.
  • Regex prompt cleaning is critical for Sora API stability.
  • Portrait 9:16 + 10 frames optimal for Shorts.
  • Daily output: 6 videos for $0.90.

— Editorial Team

Advertisement 728x90

Read Next