AI Image Generation via BananaAPI Polling Loop - n8n Workflow

Automate AI image generation efficiently using this robust n8n workflow. Submit prompts via an n8n form trigger, handle asynchronous tasks with a polling loop, and fetch high-quality images from BananaAPI.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Content Creators & Marketers: Who need affordable, high-volume automated image generation directly integrated into their systems.
Developers: Seeking reliable n8n templates for handling asynchronous API tasks using dynamic polling loops.
Automation Engineers: Looking for a practical example of integrating complex AI services into an n8n workflow.
Users: Interested in leveraging the cost-effective $0.025 per image pricing of the Nano Banana engine via BananaAPI.

Overview

This specialized n8n workflow is designed to streamline the process of AI image creation using the highly competitive BananaAPI service, powered by the Nano Banana engine. AI image generation is often an asynchronous task, meaning the API doesn't return the final result immediately. This robust n8n workflow solves this challenge by employing a polling mechanism.

The process begins with an n8n trigger (a user-friendly form) to collect inputs like the prompt, preferred size, format, and optional reference image URLs. The core value of this n8n automation lies in its ability to submit the request, wait a short period, and then continually check the task status via the 'Check Status' n8n node until the image is completed. This allows users to build reliable automation around tasks that take time to process, making this one of the most useful n8n templates for developers working with external APIs.

How it Works

This powerful n8n workflow operates in several distinct stages:


  1. Input Collection: The n8n trigger is the 'Form — Get Prompt' n8n node. It generates a public URL where users can input required details: the Banana API bearer token, the text prompt, and optional parameters like image size (e.g., 1:1, 16:9) and up to five reference image URLs.

  2. Task Submission: The 'Submit — Banana API' n8n node, an HTTP Request node, sends a POST request to the BananaAPI generation endpoint (/generate/). Crucially, it uses expressions to dynamically set the Authorization header with the user-provided API token.

  3. Initial Wait: Following submission, the 'Wait 5s' n8n node pauses the execution flow, giving the Nano Banana engine time to start processing the image generation task.

  4. Status Check (Polling Loop Start): The 'Check Status' n8n node sends a GET request to the BananaAPI status endpoint, referencing the taskId received in Step 2. This checks the current status of the AI image task.

  5. Conditional Flow Control: The 'If' n8n node evaluates the returned status. If the status is completed, the workflow proceeds to the final step. If the status is anything else (e.g., processing), the workflow executes the secondary branch.

  6. Looping: If the task is not complete, the 'Wait 5s (loop)' n8n node introduces another delay before looping back to the 'Check Status' n8n node, repeating the polling process until the status is complete.

  7. Output Return: Once the image is ready, the 'Return Links' n8n node (a Set node) captures the final output, providing the generated imageurl, taskid, and status as a clean payload.

Installation Guide

To set up this advanced n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON code and paste it into your n8n instance using the 'Import from JSON' function.

  2. BananaAPI Setup: Ensure you have an account and a Bearer API token from BananaAPI.com.

  3. Configure Credentials (Recommended): Although the Form Trigger asks for the token, for production use, it is best practice to store the BananaAPI token using n8n Credentials and reference it in the 'Submit — Banana API' n8n node instead of relying on form input.

  4. Activate the Trigger: Open the 'Form — Get Prompt' n8n trigger and copy the generated public webhook URL.

  5. Test the n8n workflow: Use the form URL to submit a prompt. Run the n8n workflow in 'Test' mode to observe the polling loop in action and ensure all nodes are executing correctly.

Node Details

This reliable n8n workflow utilizes several key n8n nodes:

Form — Get Prompt (n8n trigger): The starting point for the n8n workflow. It collects necessary user input including the required prompt and apitoken, along with optional fields like Output Format and Image Size.
Submit — Banana API (HTTP Request n8n node): Responsible for initiating the AI generation task. Key configuration includes using POST method to the /generate/ endpoint, dynamically inserting the prompt data into the JSON body, and setting the Authorization: Bearer header using an expression referencing the incoming api
token.
Wait 5s & Wait 5s (loop) (Wait n8n node): These nodes manage the asynchronous nature of image generation by introducing timed delays (5 seconds) before proceeding or looping back, ensuring the n8n workflow doesn't overload the API.
Check Status (HTTP Request n8n node): This node polls the status endpoint (/image-status/{{taskId}}). It is configured using an expression to retrieve the taskId output from the 'Submit — Banana API' n8n node.
If (If n8n node): Controls the polling logic. It checks if the status field returned by the 'Check Status' n8n node equals completed. If true, the n8n workflow exits the loop. If false, it routes the execution back to the loop wait.
Return Links (Set n8n node): The final processing n8n node. It cleans up the output and clearly presents the final imageurl, taskid, and status to the next step or the webhook response.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by
Tran Trung Nghia
Tran Trung Nghia

Featured*