JUHE API Marketplace

Automating Ad Creative Generation with Nano Banana (Gemini 2.5 Flash)

4 min read
By Chloe Anderson

Google’s recently released Nano Banana (Gemini 2.5 Flash Image) model has unlocked powerful new capabilities for multimodal AI. One of the most exciting features is Image Fusion, which allows you to merge two separate images into a single, cohesive scene.

This workflow demonstrates how to build an automated system that generates unlimited eCommerce ad creatives by treating this fusion capability as a scalable API process.

This workflow demonstrates how to build an automated system that generates unlimited eCommerce ad creatives by treating this fusion capability as a scalable API process.

Note on Background Removal: While this guide focuses on the "Image Fusion" use case—merging a product into a lifestyle scene—Gemini 2.5 Flash is also highly capable of Background Removal. By adjusting the prompt in the generate_image node (e.g., "Extract the product in image 1 and place it on a transparent background"), you can reuse this exact same workflow architecture for bulk background removal tasks.


1. The Concept: "Zero-Shot" Ad Creative

Traditionally, creating ad assets requires a photoshoot: hiring a photographer, booking a studio, and physically placing your product in the hands of influencers or models.

With Gemini 2.5 Flash Image, you can achieve this virtually:

  1. Input 1: Your Product Image (e.g., a Stanley Cup).
  2. Input 2: A Reference Image (e.g., an influencer holding an empty hand or generic object).
  3. Prompt: "Create an image where the cup in image 1 is being held by the person in image 2..."

The model understands the physics, lighting, and context, "fusing" the objects naturally.

2. The Workflow Architecture

We have built an automation (available for download below) using n8n that handles this process in bulk.

Step 1: Trigger & Input

  • Form Trigger: A clean UI to upload your product image.
  • Image Processing: The workflow immediately converts this product image to a Base64 string, the format required by the Gemini API.

Step 2: Sourcing Influencers (Google Drive)

  • Instead of uploading a new influencer for every run, the workflow connects to a Google Drive folder.
  • It lists all images in the folder, treating them as a "batch" of potential ad creatives.
  • Scalability: To generate 50 new ads, simply drop 50 new photos into the Drive folder.

Step 3: The Gemini 2.5 Flash Loop

The workflow iterates through every influencer image found:

  1. Download: Fetches the influencer image from Drive.
  2. Base64 Conversion: Prepares the influencer image for the API.
  3. API Request: Sends both the Product Base64 and Influencer Base64 to wisdom-gate.juheapi.com.

The API Prompt

The core magic happens in the JSON body sent to Gemini:

json
{
  "contents": [{
    "parts": [
      { "text": "Create an image where the cup/tumbler in image 1 is being held by the person in the 2nd image..." },
      {
        "inline_data": {
          "mime_type": "image/png",
          "data": "{{ $node['product_image_to_base64'].json.data }}"
        }
      },
      {
        "inline_data": {
          "mime_type": "image/jpeg",
          "data": "{{ $node['influencer_image_to_base_64'].json.data }}"
        }
      }
    ]
  }]
}

Step 4: Output & Storage

  • The generated image (returned as inline data) is converted back to a binary file.
  • It is automatically uploaded to a designated Output Folder in Google Drive.
  • Files are named incrementally (e.g., "Influencer Image #1", "Influencer Image #2").

3. How to Use This Workflow

Prerequisites

  1. n8n: A self-hosted instance or n8n cloud account.
  2. Google Cloud Project: Enabled "Generative Language API" (Gemini).
  3. Google Drive API: Enabled credentials (OAuth2 Client ID/Secret) for n8n to access your Drive.

Setup Instructions

  1. Import the Workflow: Download the JSON file below and import it into n8n.
  2. Configure Credentials:
    • Set up your Google Drive credentials in the Drive nodes.
    • Set up your Google Drive credentials in the Drive nodes.
    • Set up your Wisdom Gate API key in the HTTP Request node headers.
  3. Set Folder IDs:
    • Update the list_influencer_images node with your "Input" folder ID.
    • Update the upload_image node with your "Output" folder ID.
  4. Run: Click "Open Form" in the trigger node, upload a product, and watch the creatives appear in your Drive.

Download Workflow

You can download the full JSON workflow file by contact support@juheapi.com.


Resources: