{
  "name": "Generate AI videos from text or images with Sora 2/Pro & GPT-5 enhancement",
  "nodes": [
    {
      "id": "a85d1e91-bf05-4a5a-9759-15de2b1b50e8",
      "name": "Note: Mode Router",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5280,
        2640
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## 🔀 Input Mode Router\n\n**Purpose:** Branches to image-to-video if file uploaded, else text-to-video with refinement.\n\n**Note:** Switch checks filename; ensures GPT-5 processes text prompts."
      }
    },
    {
      "id": "eda124e2-e1aa-4064-96a7-c31cbde19521",
      "name": "Note: Image Upload",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5744,
        2080
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## 🖼️ Temp Image Upload\n\n**Purpose:** Uploads reference image to tmpfiles.org for Sora image-to-video.\n\n**Note:** Multipart POST; swaps URL to /dl/ for direct API access."
      }
    },
    {
      "id": "1c76b2c1-9778-4f10-a078-6ce8eba97641",
      "name": "Note: Prompt Refiner",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5488,
        2928
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## 🤖 Prompt Refiner\n\n**Purpose:** Uses GPT-5 to enhance text prompts for Sora 2 text-to-video mode.\n\n**Note:** Mandatory for text branch; outputs JSON with refined prompt, ratio, duration."
      }
    },
    {
      "id": "707ea9aa-81eb-47d1-b000-eb3238c70b94",
      "name": "Note: JSON Parser",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5920,
        2944
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## 🔍 JSON Output Parser\n\n**Purpose:** Validates GPT-5 response against schema for clean API params.\n\n**Note:** Ensures prompt (50-4000 chars), ratio (16:9/9:16), duration (4/8/12)."
      }
    },
    {
      "id": "c474d947-6610-4731-bc3b-af7c09f926be",
      "name": "Note: Text-to-Video",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6288,
        2752
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## 🎥 Text-to-Video Call\n\n**Purpose:** Submits refined prompt to fal.ai Sora 2 text endpoint (pro if selected).\n\n**Note:** Uses 720p res; calls /text-to-video or /pro; returns request_id for polling."
      }
    },
    {
      "id": "607e987b-df5f-4d7a-8d49-b79440c62962",
      "name": "Note: Image-to-Video",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6240,
        2144
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## 🖼️ Image-to-Video Call\n\n**Purpose:** Sends raw prompt + image URL to fal.ai Sora 2 image endpoint.\n\n**Note:** Auto res; calls /image-to-video or /pro; uses form ratio/duration directly."
      }
    },
    {
      "id": "f50b63a0-dee7-4783-bcff-8b5d5b75949b",
      "name": "Video Input Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        5392,
        2448
      ]
    },
    {
      "id": "0c7ab4d0-5a34-41c1-9ea8-5a145056cee6",
      "name": "Prompt Refiner",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        5840,
        2592
      ]
    },
    {
      "id": "2cfdf665-263a-441a-abef-07136a766458",
      "name": "JSON Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        5984,
        2768
      ]
    },
    {
      "id": "e857b653-7894-43d8-8598-8d6998076a65",
      "name": "Temp Image Upload",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5888,
        2320
      ]
    },
    {
      "id": "e8760386-b433-473d-9099-bb2f03c7c3aa",
      "name": "Text-to-Video Call",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6144,
        2592
      ]
    },
    {
      "id": "2d84b59f-4c4e-4fac-968a-81eb6482c04e",
      "name": "Input Mode Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        5600,
        2448
      ]
    },
    {
      "id": "eef5e174-4d2a-450f-8bac-dd343865ad6b",
      "name": "Image-to-Video Call",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6064,
        2320
      ]
    },
    {
      "id": "c07d5074-c4b7-4f43-a0d7-f26e2cd37137",
      "name": "Wait 60 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        6336,
        2416
      ]
    },
    {
      "id": "557e1785-4e6c-4f2e-a9a4-3098b1d638cb",
      "name": "Status Check",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6544,
        2416
      ]
    },
    {
      "id": "320c2ee0-767d-4106-a605-b03bd1a80631",
      "name": "Status Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        6752,
        2416
      ]
    },
    {
      "id": "cfa44af4-e910-40cf-b581-1acee757871d",
      "name": "Retrieve Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6944,
        2400
      ]
    },
    {
      "id": "6ce27f08-cae8-4a9b-bac3-2e01fa31c864",
      "name": "Video Redirect",
      "type": "n8n-nodes-base.form",
      "position": [
        7152,
        2400
      ]
    },
    {
      "id": "d110e220-883b-4e3f-bbda-cd195ddf23dd",
      "name": "Overview Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4528,
        1984
      ],
      "parameters": {
        "width": 696,
        "height": 1184,
        "content": "# 🎬 Sora 2 Video Generator via Fal with GPT-5 Refinement\n\n## 📋 What This Template Does\nGenerate videos using OpenAI's Sora 2 via fal.ai's four endpoints (text-to-video, text-to-video/pro, image-to-vid"
      }
    },
    {
      "id": "6dad83d5-6cb1-4dca-90a1-c12048b5b544",
      "name": "Note: Form Trigger1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5248,
        2176
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## 📝 Video Input Form\n\n**Purpose:** Captures user prompt, ratio, model, duration, and optional image via web form.\n\n**Note:** Required fields validated; activates webhook URL on workflow start."
      }
    },
    {
      "id": "6e91faf7-a3c5-48ce-94d6-a993ea8e5d8e",
      "name": "Note: Polling Loop1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6688,
        2640
      ],
      "parameters": {
        "width": 332,
        "height": 192,
        "content": "## ⏳ Status Polling Loop\n\n**Purpose:** Waits 60s, checks Sora status, loops until COMPLETED.\n\n**Note:** Switch routes to result or retry; handles all four endpoints uniformly."
      }
    },
    {
      "id": "ad9eadd7-1e7f-4922-8ca7-6a673812ffd0",
      "name": "Refiner Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        5840,
        2768
      ]
    }
  ],
  "connections": {
    "Status Check": {
      "main": [
        [
          {
            "node": "Status Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refiner Model": {
      "ai_languageModel": [
        [
          {
            "node": "Prompt Refiner",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Status Router": {
      "main": [
        [
          {
            "node": "Retrieve Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt Refiner": {
      "main": [
        [
          {
            "node": "Text-to-Video Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Video": {
      "main": [
        [
          {
            "node": "Video Redirect",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60 Seconds": {
      "main": [
        [
          {
            "node": "Status Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video Input Form": {
      "main": [
        [
          {
            "node": "Input Mode Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Mode Router": {
      "main": [
        [
          {
            "node": "Temp Image Upload",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prompt Refiner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Temp Image Upload": {
      "main": [
        [
          {
            "node": "Image-to-Video Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Prompt Refiner",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Text-to-Video Call": {
      "main": [
        [
          {
            "node": "Wait 60 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image-to-Video Call": {
      "main": [
        [
          {
            "node": "Wait 60 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}