AI & AUTOMATION

Mastering AI Image Generation: How to Use Nano Banana Pro in n8n

The landscape of AI is evolving rapidly, and Nano Banana Pro is a standout model for generating high-fidelity images. By integrating this model into n8n, you can build robust automation workflows that handle everything from simple text-to-image creation to complex multi-image composites.

In this guide, I will walk you through a specific n8n workflow that leverages the KIE.ai API to access Nano Banana Pro. We will cover three distinct scenarios found in the workflow: Text-to-Image, Image-to-Image (with file upload), and Multi-Image Editing.

Share by Nate Herk

Prerequisites & Setup

To run the attached workflow, you need to configure access to two specific services used in the nodes:

  1. KIE API Key: The workflow uses https://api.kie.ai for the image generation. You must sign up at KIE.ai and add your API Key to the Header Parameters (Authorization: Bearer YOUR API KEY) in all KIE HTTP Request nodes.
  2. ImgBB API Key: For the Image-to-Image branch, the workflow uploads files to https://api.imgbb.com to generate public URLs.
Download workflow n8n: https://romhub.io/n8n/Nano_Banana_Pro

The Core Logic: The “Polling” Loop

Before diving into the specific branches, it is crucial to understand the logic that governs all three. Because AI image generation takes time, you cannot simply make a request and get an image immediately. This workflow uses a polling mechanism:

  1. Create Task: Send the prompt/parameters to jobs/createTask.
  2. Wait: Pause the workflow (e.g., 5 seconds) to give the AI time to process.
  3. Get Info: Call jobs/recordInfo using the taskId returned from step 1.
  4. Switch: Check the state of the job:
    • generating: Loops back to the Wait node to try again.
    • success: Moves to the Result node to output the final image URL.
    • fail: Stops the workflow or handles the error.

Scenario 1: Text to Image

This is the simplest implementation, ideal for generating visuals purely from a text description.

1. The Trigger & Prompt

The workflow starts with a Schedule Trigger followed by a Set node. In this specific workflow, the prompt is hardcoded as:

A hyper-realistic image of the Chicago skyline at sunset."

2. The API Request

The HTTP Request node sends a POST request to https://api.kie.ai/api/v1/jobs/createTask.

The JSON Body Structure:

Unlike some other APIs, Nano Banana Pro inside KIE nests the parameters inside an input object.

{
  "model": "nano-banana-pro",
  "input": {
    "prompt": "{{ $json.prompt }}",
    "aspect_ratio": "1:1",
    "resolution": "4K",
    "output_format": "png"
  }
}

Once the task is created, the workflow enters the polling loop described above until the image is ready.

Scenario 2: Image to Image (Form Upload)

This branch allows users to upload a local file via an n8n Form, which is then transformed by the AI.

1. Form Trigger

The Form Trigger node collects two fields:

  • Image Prompt (Text)
  • Image (File Upload)

2. Hosting the Image (ImgBB)

Nano Banana Pro requires a publicly accessible URL for input images; it cannot process raw binary data directly. Therefore, this workflow includes an intermediate step:

  • HTTP Request (Get URL): Takes the binary file from the form and uploads it to https://api.imgbb.com/1/upload.
  • The API returns a public URL (e.g., {{ $json.data.url }}).

3. The API Request

The request to KIE is similar to the Text-to-Image call, but with the addition of the image_input array within the input object.

{
  "model": "nano-banana-pro",
  "input": {
    "prompt": "{{ $('On form submission').item.json['Image Prompt'] }}",
    "image_input": [
      "{{ $json.data.url }}"
    ],
    ...
  }
}

Scenario 3: Multiple Images to Image

This is the most advanced feature, allowing you to combine multiple reference images (e.g., a shirt, a watch, and a water bottle) into a single generated scene.

1. Defining Inputs

In the Prompt/Images Set node, the workflow hardcodes three specific Amazon product image URLs and a complex prompt:

A hyper-realistic image of a man wearing the shirt provided in the image. He is hiking on a mountain and is holding the water bottle provided in the image. He is also wearing the watch provided in the image."

2. The API Request

The structure here is key. You pass multiple URLs into the image_input array.

{
  "model": "nano-banana-pro",
  "input": {
    "prompt": "{{ $json.prompt }}",
    "image_input": [
      "{{ $json.image1 }}",
      "{{ $json.image2 }}",
      "{{ $json.image3 }}"
    ],
    "resolution": "4K",
    ...
  }
}

3. Processing

Multi-image tasks are computationally heavy. The polling loop (Wait -> Get Image2 -> Switch2) is essential here, as the status may remain generating for several cycles before switching to success.

Conclusion

This n8n workflow demonstrates how to harness the power of Nano Banana Pro via KIE.ai. By managing the asynchronous nature of AI generation with a Wait/Switch loop and handling image hosting via ImgBB, you can automate high-quality asset creation for marketing, e-commerce, and content production.

Next Steps

  1. Import the JSON: Load the Nano_Banana_Pro.json file into your n8n instance.
  2. Add Keys: Replace YOUR API KEY in the Header parameters of the HTTP nodes.
  3. Test: Activate the workflow and try the “Text to Image” branch first to verify your connection.

You may also like

Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments