{
  "name": "Modal: flux schnell subworkflow",
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "prompt"
            },
            {
              "name": "width",
              "type": "number"
            },
            {
              "name": "height",
              "type": "number"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -1056,
        0
      ],
      "id": "7b7d7308-c230-454b-aea4-2857b1bfbf0e",
      "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": "f447c7aa-ba33-40d9-9131-9ccd7b0546af",
      "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": "648a8c7f-72d5-41c3-b722-f63af8eac4fc",
      "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": 4,
              "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"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -656,
        0
      ],
      "id": "9585531d-b5ed-482f-a2f5-a47e819a8388",
      "name": "Setup workflow"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Setup workflow').item.json.url }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "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": "cfg",
              "value": "1"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        16,
        0
      ],
      "id": "9c19e1d4-4037-45bb-92bc-aaf7129cfd34",
      "name": "HTTP Request",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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": "6fd20fb6-9931-44e4-9eab-d057972e4623",
      "name": "Configure me"
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Configure me",
            "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": [
        []
      ]
    },
    "Configure me": {
      "main": [
        [
          {
            "node": "Setup workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ebbc7288-a51b-4431-957d-670f8a28c4ed",
  "id": "7xU7Q9gCrLxWxtqm",
  "tags": []
}