{
  "name": "rawroute: Prompt to Image + Video",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "prompt-to-media",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000001",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        200,
        300
      ],
      "webhookId": "rawroute-prompt-to-media"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ 'https://api.rawroute.dev' + '/v1/chat/completions' }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'claude-sonnet-5-5', temperature: 0.7, messages: [{ role: 'system', content: 'Return strict JSON with keys image_prompt and video_prompt derived from the user brief. No markdown.' }, { role: 'user', content: $json.body?.prompt || $json.prompt || 'Monochrome architectural lighthouse at dusk' }], response_format: { type: 'json_object' } }) }}",
        "options": {
          "timeout": 60000
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000002",
      "name": "Claude Sonnet 5.5 Expand Prompt",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ 'https://api.rawroute.dev' + '/v1/images/generations' }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'gemini-3.1-flash-image', prompt: JSON.parse($json.choices[0].message.content).image_prompt, n: 1, size: '1024x1024' }) }}",
        "options": {
          "timeout": 120000
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000003",
      "name": "Nano Banana 2 Generate Image",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ 'https://api.rawroute.dev' + '/v1/videos' }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'veo-3.1', prompt: JSON.parse($('Claude Sonnet 5.5 Expand Prompt').item.json.choices[0].message.content).video_prompt, seconds: '8', resolution: '720p' }) }}",
        "options": {
          "timeout": 60000
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000004",
      "name": "Veo 3.1 Submit Video",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        920,
        300
      ]
    },
    {
      "parameters": {
        "amount": 10,
        "unit": "seconds"
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000005",
      "name": "Wait 10s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1140,
        300
      ],
      "webhookId": "rawroute-video-wait"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ 'https://api.rawroute.dev' + '/v1/videos/' + $json.id }}",
        "options": {
          "timeout": 30000
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000006",
      "name": "Poll Video Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        300
      ],
      "retryOnFail": true,
      "maxTries": 4,
      "waitBetweenTries": 2000,
      "notes": "Polls GET /v1/videos/{id} with retryOnFail on 429/502/503/504."
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "cond-terminal-status",
              "leftValue": "={{ ['completed', 'succeeded', 'done', 'failed', 'error'].includes(String($json.status || '').toLowerCase()) }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000007",
      "name": "Video Ready?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1580,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ expanded: JSON.parse($('Claude Sonnet 5.5 Expand Prompt').item.json.choices[0].message.content), image: $('Nano Banana 2 Generate Image').item.json.data?.[0] || null, video: { id: $json.id, status: $json.status, content_endpoint: 'https://api.rawroute.dev' + '/v1/videos/' + $json.id + '/content', raw: $json } }) }}",
        "options": {}
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000008",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1820,
        240
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Claude Sonnet 5.5 Expand Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude Sonnet 5.5 Expand Prompt": {
      "main": [
        [
          {
            "node": "Nano Banana 2 Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Nano Banana 2 Generate Image": {
      "main": [
        [
          {
            "node": "Veo 3.1 Submit Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Veo 3.1 Submit Video": {
      "main": [
        [
          {
            "node": "Wait 10s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10s": {
      "main": [
        [
          {
            "node": "Poll Video Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Poll Video Status": {
      "main": [
        [
          {
            "node": "Video Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video Ready?": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "executionTimeout": 900
  },
  "meta": {}
}
