{
  "name": "Replicate Image Generator",
  "nodes": [
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "succeeded",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "ad802b5b-99c6-4a95-9815-2c61b55f2489"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "succeeded"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "62840b4b-123d-455d-8369-65f21240b113",
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "failed",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "failed"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "6e6c1d03-1863-4f9f-a5c3-53ce3b295dec",
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "canceled",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "canceled"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "11e2e8b5-6c3e-4efb-a544-888fc809fbdf",
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "processing",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "processing"
            }
          ]
        },
        "options": {
          "fallbackOutput": "none"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        660,
        -20
      ],
      "id": "1e699bc9-9dbb-45a9-a371-9730aee7ebad",
      "name": "Switch"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        920,
        140
      ],
      "id": "128fb831-aa7c-4985-8e35-4cd42d772d59",
      "name": "Wait",
      "webhookId": "d8c3439d-fc1d-487a-950c-7da37a998b3f"
    },
    {
      "parameters": {
        "url": "=https://api.replicate.com/v1/predictions/{{ $json.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "id": "7a830287-b147-41ec-9190-9c632a6ee142",
      "name": "Get Status",
      "credentials": {
        "httpHeaderAuth": {
          "id": "RYotBpt5in0HQRBh",
          "name": "Replicate Header Auth"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.replicate.com/v1/models/black-forest-labs/flux-1.1-pro-ultra/predictions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"input\": {\n    \"aspect_ratio\": \"1:1\",\n    \"image_prompt_strength\": 0.1,\n    \"output_format\": \"png\",\n    \"prompt\": \"{{$json.prompt}}\",\n    \"raw\": false,\n    \"safety_tolerance\": 2,\n    \"seed\": 0\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ],
      "id": "de75d9af-0556-45b4-abec-5b30500307f7",
      "name": "Create Image",
      "credentials": {
        "httpHeaderAuth": {
          "id": "RYotBpt5in0HQRBh",
          "name": "Replicate Header Auth"
        }
      }
    },
    {
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n  \"prompt\": \"image prompt\"\n}"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "f0884832-b3db-4eb1-9ac0-1efa0efcae16",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "url": "={{ $json.output }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        920,
        -100
      ],
      "id": "acfce2c5-5503-4aed-9035-a12769bc71f6",
      "name": "HTTP Request"
    }
  ],
  "pinData": {},
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Status": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Image": {
      "main": [
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Create Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "instanceId": "a3dee2c6aba3365766e3abaf66908fcdd28e578f25779c6e4ace5101e13800bd"
  },
  "tags": [],
  "id": "RdQnSDah8Ikw8QjH",
  "versionId": "92a9a579-0b26-43ac-9d9f-176f82956ac4"
}
