{
  "name": "Modal: flux dev subworkflow",
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "prompt"
            },
            {
              "name": "width",
              "type": "number"
            },
            {
              "name": "height",
              "type": "number"
            },
            {
              "name": "steps",
              "type": "number"
            },
            {
              "name": "guidance_scale",
              "type": "number"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -1056,
        0
      ],
      "id": "a8b8c8b0-b73d-4039-aca4-c1d386c081d1",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "errorMessage": "The size of the image (width x height) is larger than 1 megapixel"
      },
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        0,
        -288
      ],
      "id": "202dfb57-c1c5-4174-b5ce-0811c9719d5b",
      "name": "Image > 1 megapixel"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f6e30a82-76cd-4bfd-9bc5-b7fffb15e35c",
              "leftValue": "={{ $json.width * $json.height > 1048576 }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -448,
        -16
      ],
      "id": "7bc0143c-c84f-48c4-99e4-1d753141fb6f",
      "name": "Check image size"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3f7d5020-0710-4f3c-858f-0485a2bd2963",
              "name": "width",
              "value": "={{ $('When Executed by Another Workflow').item.json.width || 1024 }}",
              "type": "number"
            },
            {
              "id": "39b906fa-3e0b-45b9-9c1b-95cbc51e195d",
              "name": "prompt",
              "value": "={{ $('When Executed by Another Workflow').item.json.prompt }}",
              "type": "string"
            },
            {
              "id": "3f8593d2-cfb3-437a-a9fc-4430995cb78f",
              "name": "height",
              "value": "={{ $('When Executed by Another Workflow').item.json.height || 1024 }}",
              "type": "number"
            },
            {
              "id": "065181ef-404a-4860-9019-976e6e8391e0",
              "name": "seed",
              "value": "={{ Math.floor(Math.random() * 100000000) }}",
              "type": "number"
            },
            {
              "id": "2c131da3-e708-4468-bb09-d400e7e5f28c",
              "name": "steps",
              "value": "={{ $('When Executed by Another Workflow').item.json.steps || 40 }}",
              "type": "number"
            },
            {
              "id": "95df4de2-196a-4f64-a2ed-3959ede14154",
              "name": "url",
              "value": "={{   ((u) => {   let s = u.trim();   if (!/^https?:\\/\\//i.test(s)) s = 'https://' + s;   const parts = s.split('/');   return parts[0] + '//' + parts[2]; })($json.MODAL_URL)  }}/generate",
              "type": "string"
            },
            {
              "id": "aa3da4e4-9c9e-4cf4-b8bf-f7f08717ec02",
              "name": "guidance_scale",
              "value": "={{ $('When Executed by Another Workflow').item.json.guidance_scale || 3.5 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -656,
        0
      ],
      "id": "3e4fadf2-1a32-44eb-8c81-b393a717e224",
      "name": "Setup workflow"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Setup workflow').item.json.url }}",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $('Setup workflow').item.json.prompt }}"
            },
            {
              "name": "width",
              "value": "={{ $('Setup workflow').item.json.width }}"
            },
            {
              "name": "height",
              "value": "={{ $('Setup workflow').item.json.height }}"
            },
            {
              "name": "seed",
              "value": "={{ $('Setup workflow').item.json.seed }}"
            },
            {
              "name": "steps",
              "value": "={{ $('Setup workflow').item.json.steps }}"
            },
            {
              "name": "guidance_scale",
              "value": "={{ $('Setup workflow').item.json.guidance_scale }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        16,
        0
      ],
      "id": "0a6a94cd-6d62-4f77-b118-f6abf834f4f3",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2df0bb38-9912-4978-ad56-3236c5d54126",
              "name": "MODAL_URL",
              "value": "<<insert your modal server url here>>",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -848,
        0
      ],
      "id": "1732669f-0019-45d7-8c64-34fa2a16db7e",
      "name": "Edit Fields"
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check image size": {
      "main": [
        [
          {
            "node": "Image > 1 megapixel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup workflow": {
      "main": [
        [
          {
            "node": "Check image size",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        []
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Setup workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "086d50f7-ce1e-457c-a1a4-7b46ba68e1cc",
  "id": "J4CdzHvSiRhLbRi4",
  "tags": []
}