N8n - Google Gemini nano banana set up issue

Set up problem

Describe the problem/error/question

Hello,
I would like to set up options for nano banana such as resulotion, aspect ratio, top-p and temprature. Therefore, there is no space inthe module to select them.
Thank you.

What is the error message (if any)?

Please share your workflow


(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

yeah n8n’s Gemini node doesnt expose those — gotta hit the API directly. heres the HTTP Request node:

all the params from ur screenshot map straight in — aspectRatio (1:1, 16:9, 9:16 etc), imageSize (1K/2K/4K), temperature, topP. swap the prompt/values to whatever u need. is this for the jewelry + model combine flow from ur other thread, or just text-to-image?

Hi @Trilogy_Elektronik , welcome back ^^

the built-in Gemini node in n8n currently does not expose those image generation settings, so if you want things like aspectRatio, imageSize, temperature, topP, or topK, the easiest way is to call the Gemini API directly with an HTTP Request node instead.

I tested this pattern before and it works well for image generation with a reference image. One important note though: you should not keep your API key inside a Set node like in the sample workflow, because that can leak the key if the workflow gets shared. It’s better to store the key in credentials or pass it through a secure environment variable.

Here’s a simple workflow you can import and adapt:

A few practical notes:

  • aspectRatio supports quite a few presets, not just 1:1, 16:9, and 9:16. From what’s currently documented for Nano Banana image generation, the supported ratios include 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, and 21:9.

  • imageSize depends on the model/version, but in practice you’ll typically see options like 1K, 2K, and in some cases 4K on newer Nano Banana variants.

  • If you only want text-to-image, you can remove the fileData block completely.

  • If you want image editing, style transfer, or composition based on a reference image, keep the reference image in the request.

Don’t hesitate to ask if you need anything else or want to tweak this further. I really hope this ends up being the solution that works for you.

Yes you are right, for the Jewelry + model mockup study.

Thank you so much @nguyenthieutoan . What is the exact name of node? How can I find it?

Sorry, I am new this is my first automation.

I saw it :slight_smile: You have already shared the JSON code. Perfect!

Hi @Trilogy_Elektronik it’s really great to hear that you were able to get it working so easily. If it solves your problem, please don’t forget to mark my reply as the solution, that would mean a lot to me.

@Trilogy_Elektronik is there any other questions you have that we can assist with?

I am trying to solve the problem with AI and gemini but we cannot find a solution for these nodes.

Could you please check the data into the nodes that you suggested?

Prepare :

HTTP:

yea, I’ll test it for you real quick! Give me like 15 mins, and I should be done!

@Trilogy_Elektronik two things —

  1. regenerate ur API key right now. its visible in ur screenshot (the AIzaSyB… one). anyone scrolling this thread can grab + use it. take 30 sec on aistudio.google.com → Get API Key → revoke old + create new.

  2. the real bug: in ur last screenshot (Expression vs Result panel), look at the right side — inlineData.data resolves to [undefined]. that means $binary.productimage.toBase64() cant find a binary field called productimage on the upstream node. so gemini receives the literal string [undefined] as the base64 image data, hence the “unable to process input image” error.

fix: click ur upstream node (the one before HTTP Request — looks like a Google Drive download) and check the binary output panel. the actual key is probably data, not productimage. then in ur HTTP body change to:

{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "inlineData": {
            "data": "={{ $('Google Drive').first().binary.data.toBase64() }}",
            "mimeType": "image/jpeg"
          }
        },
        { "text": "={{ $json.describeImage }}" },
        { "text": "={{ $json.mainPrompt }}" }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": ["IMAGE"],
    "imageConfig": {
      "aspectRatio": "={{ $json.aspectRatio }}",
      "imageSize": "={{ $json.size }}"
    },
    "temperature": "={{ $json.temperature }}",
    "topP": "={{ $json.topP }}",
    "topK": "={{ $json.topK }}"
  }
}

swap ‘Google Drive’ for whatever ur source node is actually called, and data for the actual binary key u see in its output. once inlineData.data resolves to a real base64 string the call will go through.

@achamm Thank you so much for your help. I will also change my API key. I really appreciate it.

I used the code, but unfortunately the data still doesn’t work.

You have helped me a lot.

Best regards

@Trilogy_Elektronik ah ok i see the issue now — looking back at ur Prepare node, its only setting text fields (image_model, geminiApi, prompts, params). theres no actual image binary feeding into the HTTP node. so when the HTTP request tries to read $binary it returns undefined no matter what name we use.

u need a Google Drive Download node BEFORE the HTTP call to fetch the actual product image bytes. heres the missing node:

connect: Prepare → Download Product Image → HTTP Request. then in the HTTP body change inlineData.data to:

={{ $(‘Download Product Image’).first().binary.data.toBase64() }}

and add productImageId to ur Prepare node as the actual Google Drive file ID of the product image (the part after /d/ in the share URL, or pull it from ur loop). once that download node runs, the HTTP node finally has a real binary to send.

if that doesent work, can you redact the api key from ur workflow, do control A in n8n control C and than controlV into your post/reply?

Dear @achamm

I used also additional node that you requested but the data is still red :confused: Thats why the system cannot generate an image.

I am not sure the my workflow is OK or not. But I have to leave now due business day on tomorrow.

Thank you so much for your help @achamm @nguyenthieutoan

Have a nice day!

@Trilogy_Elektronik your good! Enjoy your buisness day, and I’ll try to mfigure it out