{
  "nodes": [
    {
      "id": "c77e4131-abb7-4f10-bac4-809dc2467d42",
      "name": "Form \u2014 Get Prompt",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        560,
        1136
      ],
      "parameters": {
        "options": {},
        "formTitle": "Banana API \u2014 Image Generator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "api_token",
              "placeholder": "Bearer YOUR_TOKEN_HERE",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "prompt",
              "placeholder": "V\u00ed d\u1ee5: a neon cyberpunk cat, detailed, 4k",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Output Format [optional]",
              "fieldOptions": {
                "values": [
                  {
                    "option": "png"
                  },
                  {
                    "option": "jpeg"
                  }
                ]
              }
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Image Size [optional]",
              "fieldOptions": {
                "values": [
                  {
                    "option": "16:9"
                  },
                  {
                    "option": "9:16"
                  },
                  {
                    "option": "1:1"
                  },
                  {
                    "option": "3:4"
                  },
                  {
                    "option": "4:3"
                  }
                ]
              }
            },
            {
              "fieldLabel": "image_url_1 [optional]",
              "placeholder": "https://example.com/input.jpg"
            },
            {
              "fieldLabel": "image_url_2 [optional]"
            },
            {
              "fieldLabel": "image_url_3 [optional]"
            },
            {
              "fieldLabel": "image_url_4 [optional]"
            },
            {
              "fieldLabel": "image_url_5 [optional]"
            }
          ]
        },
        "formDescription": "Enter the prompt and (optionally) the original image link for the Banana API to generate a new image."
      },
      "typeVersion": 2.2
    },
    {
      "id": "aa769a6a-0170-4851-82b8-0169eca8ec4a",
      "name": "Submit \u2014 Banana API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1072,
        1136
      ],
      "parameters": {
        "url": "https://bananaapi.com/api/n8n/generate/",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"input\": {\n    \"prompt\": \"{{ $json.prompt }}\",\n    \"image_size\": \"{{ $json['Image Size [optional]'] }}\",\n    \"output_format\": \"{{ $json['Output Format [optional]'] }}\",\n    \"image_urls\": [\"{{ $json['image_url_1 [optional]'] }}\",\"{{ $json['image_url_2 [optional]'] }}\",\"{{ $json['image_url_3 [optional]'] }}\",\"{{ $json['image_url_4 [optional]'] }}\",\"{{ $json['image_url_5 [optional]'] }}\"]\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.api_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c3522fe8-9442-4fcc-a2d2-cd90ac3fef15",
      "name": "Wait 5s",
      "type": "n8n-nodes-base.wait",
      "position": [
        1472,
        1136
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "037eee00-f9da-41bc-b508-6bb3fa87c68a",
      "name": "Check Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1632,
        1136
      ],
      "parameters": {
        "url": "=https://bananaapi.com/api/n8n/image-status/{{$('Submit \u2014 Banana API').item.json.taskId}}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "749b2fd0-650c-4b31-9527-c7b84a2c7357",
      "name": "Wait 5s (loop)",
      "type": "n8n-nodes-base.wait",
      "position": [
        2048,
        1088
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "3d5b6f8d-364b-4a48-82cb-fc5409502788",
      "name": "Return Links",
      "type": "n8n-nodes-base.set",
      "position": [
        2528,
        1056
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "80fd7573-3eac-4fc4-aced-b122e5eac718",
              "name": "image_url",
              "type": "string",
              "value": "={{$json.imageUrl}}"
            },
            {
              "id": "26339522-2fe9-48f6-aafd-e1aa9ed89327",
              "name": "task_id",
              "type": "string",
              "value": "={{$('Submit \u2014 Banana API').item.json.taskId}}"
            },
            {
              "id": "3e26803c-640d-463d-b857-a3bd29ea2358",
              "name": "status",
              "type": "string",
              "value": "={{$json.status}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "01a74ecd-93e3-4eb3-ab72-3ab82a008294",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1808,
        1072
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "4e3a3b7c-61e8-49c4-abf7-5eb3db4a3eef",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Check Status').item.json.status }}",
              "rightValue": "=completed"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0f715abf-ae0a-42d5-8647-5e9488cd3f9d",
      "name": "NOTE \u2014 Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## Overview\nThis workflow integrates **BananaAPI.com** with the **Google Nano Banana** image generation engine. Users can submit prompts and optional reference images via a form, then the workflow calls BananaAPI.com, checks the task status in a loop, and finally returns the generated image link.\n\n**Why use it?**\n- Cost effective: only **$0.025 per image**\n- **Pay-as-you-go**: pay only for what you use\n- **Credits never expire**: no monthly subscription pressure\n\nIdeal for creators, marketers, and developers who want affordable and automated image generation."
      },
      "typeVersion": 1
    },
    {
      "id": "71c558a9-d4e5-4ba2-8dc1-170e8a4ba0db",
      "name": "NOTE \u2014 Prerequisites",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## Prerequisites\n- **BananaAPI.com account + API key (Bearer)** \u2014 create your key at https://bananaapi.com/api\n- An **n8n instance** (Cloud or self-hosted)\n- Basic knowledge of AI prompts to get the best quality images\n\n\u26a0\ufe0f Never commit or share your API key publicly. Use **n8n Credentials** for production setups."
      },
      "typeVersion": 1
    },
    {
      "id": "77a8c9f2-61af-4e2e-9ba4-6c3ca1494567",
      "name": "NOTE \u2014 Step 1 (Form Input)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        800
      ],
      "parameters": {
        "width": 464,
        "height": 496,
        "content": "## Step 1 \u2014 User Form Input\nThe **Form Trigger** asks the user to provide:\n- `api_token` (required) \u2014 Banana API Bearer YOUR_TOKEN_HERE\n- `prompt` (required) \u2014 image description (e.g. *\u201ca neon cyberpunk cat, detailed, 4k\u201d*)\n- `Output Format [optional]` \u2014 choose PNG or JPEG\n- `Image Size [optional]` \u2014 16:9, 9:16, 1:1, 3:4, 4:3\n- `image_url_1 ... image_url_5 [optional]` \u2014 reference images for editing or transformation"
      },
      "typeVersion": 1
    },
    {
      "id": "5ae4ce78-4f6c-4148-8485-a90d21ba32dd",
      "name": "NOTE \u2014 Step 2 (POST Request)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        800
      ],
      "parameters": {
        "width": 464,
        "height": 496,
        "content": "## Step 2 \u2014 Submit to Banana API\nThe **HTTP POST** node sends the request:\n- URL: `https://bananaapi.com/api/n8n/generate/`\n- Headers:\n  - `Content-Type: application/json`\n  - `Authorization: Bearer {{ $json.api_token }}`\n- JSON Body includes:\n  - `prompt`\n  - `image_size`\n  - `output_format`\n  - `image_urls` (array of up to 5)\n\nBananaAPI will return a `taskId` to track progress."
      },
      "typeVersion": 1
    },
    {
      "id": "3c7bfc47-5d0f-45fb-a53f-25c24d2ed1f5",
      "name": "NOTE \u2014 Step 3 (Processing)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        800
      ],
      "parameters": {
        "width": 912,
        "height": 496,
        "content": "## Step 3 \u2014 Processing\nBananaAPI forwards the request to the **Nano Banana** engine, which generates or edits the image based on the prompt and optional input images.\n\n\u23f1 Average generation time: a few seconds to ~1 minute, depending on complexity and server load.\n- After 5s wait, the workflow calls:\n  `GET https://bananaapi.com/api/n8n/image-status/{{ taskId }}`\n- If `status != completed`, the loop waits 5s and retries\n- When `status = completed`, the workflow continues"
      },
      "typeVersion": 1
    },
    {
      "id": "583222b7-f53c-4376-8958-4c544c4ace60",
      "name": "NOTE \u2014 Step 5 (Output)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2336,
        800
      ],
      "parameters": {
        "width": 464,
        "height": 496,
        "content": "## Step 4 \u2014 Return Output\nWhen completed, the **Set node** outputs:\n- `image_url` \u2014 the final generated image link\n- `task_id` \u2014 the task reference ID\n- `status` \u2014 task completion state\n\n\ud83d\udca1 Tip: Add a **Webhook Response** node to return a clean JSON payload for frontend apps."
      },
      "typeVersion": 1
    },
    {
      "id": "abfd4d9f-d7be-4a74-87ae-8618a6ff826a",
      "name": "NOTE \u2014 API Reference",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2320,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## API Reference\n- **POST** `https://bananaapi.com/api/n8n/generate/`\n- **GET** `https://bananaapi.com/api/n8n/image-status/{taskId}`\n\nDocs: https://bananaapi.com/api\n\n\u2705 Always include `Authorization: Bearer <token>` in headers."
      },
      "typeVersion": 1
    },
    {
      "id": "5074a457-5ec7-4a5c-81bc-54c120818b08",
      "name": "NOTE \u2014 Pricing Advantages",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## Pricing Advantages\n- **Only $0.025 per image** \u2014 very cost-effective\n- **Pay-as-you-go**: no monthly subscription\n- **Credits never expire** \u2014 use anytime, no rush\n\nPerfect for scaling automation workflows or experimenting without wasted costs."
      },
      "typeVersion": 1
    },
    {
      "id": "1d11806a-56e9-4e02-9aeb-5dfef750b1ae",
      "name": "NOTE \u2014 Troubleshooting",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        448
      ],
      "parameters": {
        "color": 3,
        "width": 480,
        "height": 336,
        "content": "## Troubleshooting\n- **401/403 Unauthorized** \u2192 Check Authorization header (`Bearer YOUR_TOKEN_HERE`)\n- **Invalid JSON** \u2192 Ensure POST body is valid JSON (double quotes, no trailing commas)\n- **No imageUrl returned** \u2192 Task still pending; wait longer or re-check taskId\n- **Slow performance** \u2192 Increase wait interval from 5s to 8\u201310s"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Return Links",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 5s (loop)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5s": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5s (loop)": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form \u2014 Get Prompt": {
      "main": [
        [
          {
            "node": "Submit \u2014 Banana API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit \u2014 Banana API": {
      "main": [
        [
          {
            "node": "Wait 5s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}