Generate Images with n8n and Gemini Nano Banana

Introduction

Product photos, social graphics, and blog headers eat a small team’s week in small pieces. Each image takes only a few minutes to brief, but the queue never empties. This tutorial builds a repeatable n8n workflow that turns a row, a form submission, or a scheduled trigger into a finished image with Google Gemini Nano Banana, then files it in Google Drive with a predictable name. It is written for automation builders who already run n8n and want image generation inside a workflow, not inside a chat window.

Quick answer

In n8n, add a Google Gemini node, set the Image operation to Generate an Image, pick the gemini-nano-banana-2.1 model, add a Gemini API credential, and send the binary output to Google Drive.

Evidence

Nano Banana is Google’s image generation family inside the Gemini API, and the current model to build on is Nano Banana 2.1. Google’s own model page describes it as “the latest high-efficiency image generation and conversational editing model” that “maintains Flash-level speed and cost efficiency while delivering significant improvements in visual quality, prompt adherence, multi-turn character consistency, and text rendering.” That sentence matters for workflow design, because it tells you the model is built for repeated edits of the same subject, not just one-off generations.

The numbers that drive the design are concrete. As of October 2026, Nano Banana 2.1 supports 1K, 2K, and 4K output, with 1K as the default, and it fixes tiling artifacts on wide and panoramic aspect ratios such as 1:4, 4:1, 1:8, and 8:1 at 2K and 4K. It supports multi-image fusion with up to 14 reference images, with character consistency for up to 4 characters and object fidelity for up to 10 objects, according to the Gemini Nano Banana 2.1 model documentation. Its input token limit is 131,072 tokens and its output token limit is 32,768 tokens on the same page. For a product pipeline, the 14 image limit is the practical headline, because one call can hold a product shot, a lifestyle reference, and a style reference at the same time.

Cost is the second design input. Google’s Gemini API pricing lists image output at $30 per million output tokens, and at that rate a 1K Nano Banana 2.1 image works out to about $0.034. Do this math before scheduling a batch: 100 images a day at 1K costs roughly $3.40 per day in image output tokens, plus input tokens. That makes 1K the right default for drafts, social variants, and thumbnails, with 2K or 4K reserved for hero images. If a batch looks expensive, drop the resolution, not the model.

On the n8n side, the Google Gemini node already covers this use case without custom code. Its documented operations include Image operations named Generate an Image, which creates an image from a text prompt, and Edit Image, which uploads one or more images and applies edits based on a prompt, as listed in the n8n Google Gemini node documentation. That means the workflow below uses a supported node operation, not an undocumented workaround. If your n8n version does not list Nano Banana 2.1 in the model dropdown yet, update n8n first, and use the HTTP Request fallback in the troubleshooting section only as a stopgap.

Prerequisites

  • A running n8n instance, self-hosted or n8n Cloud, with permission to add credentials.
  • A Gemini API key from Google AI Studio, with billing enabled on the linked Google Cloud project.
  • A Google Drive account connected to n8n, or a local folder if you prefer the Write Binary File node.
  • A short list of products or topics to generate for, with one prompt template per image type.
  • Basic familiarity with n8n expressions, because prompts and filenames work best when they are built from incoming data rather than typed by hand.

If you are still setting up n8n, read the self-hosted n8n installation guide first. For the bigger picture, see the complete n8n guide, and for an agent around this pipeline, the n8n AI agent tutorial.

Step-by-step guide

Step 1: Create the Gemini API credential

Open Google AI Studio and create an API key, then restrict it to the Generative Language API if your setup allows it. In n8n, create a Google Gemini (PaLM) API credential and paste the key. Save and reopen it to catch a trailing space pasted from the browser, the most common silent failure here. Keep the key out of workflow JSON, screenshots, and shared exports.

Step 2: Build the input row

Start with a source that already holds your brief, not a prompt typed into the node. A Google Sheets node reading rows with a status of pending is the simplest reliable source, with columns for product name, prompt, image type, and status. A Manual Trigger works for the first test and a Schedule Trigger once the workflow is stable, and a sheet gives you an audit trail: every image maps back to a row, and a failed row stays pending instead of vanishing.

Add a Set node after the source that builds two fields: a full prompt and a safe filename. A good prompt names the subject, the scene, the style, and what must not change. For example: “Studio product photo of a matte black ceramic mug on a light oak table, soft morning window light, plain warm gray background, centered composition, no text, no logo.” A good filename is built from the product name, the image type, and the date, such as mug-studio-2026-10-29.png.

Step 3: Add the Google Gemini node for image generation

Add the Google Gemini node, set the resource to Image and the operation to Generate an Image, select your Gemini credential, and set the model to gemini-nano-banana-2.1. Map the prompt field to the prompt built in Step 2 using an expression, so each row generates its own image. Run once with a Manual Trigger and confirm the output contains binary image data. If it returns text only, you selected a text operation by mistake, so switch back to the Image operation and run again.

Keep the first run at 1K output. The goal is to prove the whole chain, including credential, prompt, binary handling, and file delivery. Turn the resolution dial only after the chain works, raising selected rows to 2K or 4K for final assets.

Step 4: Deliver the binary output immediately

Connect the Gemini node to a Google Drive node set to upload a file, and map the binary data to the upload input. Set the filename from the safe filename built in Step 2, and set the destination folder to one folder per campaign or product line. If you prefer local storage, use the Write Binary File node with the same filename expression and an absolute path. Either way, the image lands in a searchable place in the same execution that created it.

Add a final step that writes the result back to your source row. In the Sheets version, update the row status from pending to done and store the Drive file name or link. This closes the loop, and it is what makes the workflow safe to run on a schedule: a second run skips done rows instead of regenerating and re-billing them.

Step 5: Add an edit variant for existing photos

Copy the workflow, or add a second branch, and change the Gemini node operation to Edit Image. This branch takes an existing product photo as input, plus a prompt that describes only the change, such as “Replace the background with a plain warm gray studio backdrop, keep the mug, its label, and its lighting exactly unchanged.” Because Nano Banana 2.1 can take up to 14 reference images, you can also pass a style reference image alongside the product photo and ask for the same lighting and color grade. Keep edit prompts conservative: one change per call produces far more usable results than a paragraph of changes.

Step 6: Bound cost and retries in node settings

Open the Gemini node settings and turn on retry on failure, with a short wait and a small retry count, such as two retries. Transient rate limits and brief API hiccups then resolve without failing the whole batch. Do not set unlimited retries, because a prompt the safety filter rejects will fail the same way every time.

Add an IF node after the Gemini node that checks whether binary output exists. If it does, continue to Drive upload. If it does not, route the item to a Sheet update that marks the row as failed with the error message, so you can fix the prompt and rerun only that row. Without this check, an empty output reaches the Drive node and produces a confusing error far from the real cause.

Troubleshooting

The model name is rejected with a 400 error

This almost always means the model string is wrong or your n8n version predates the model. Check the string character by character: the current model is gemini-nano-banana-2.1, not the older gemini-3.1-flash-image used by Nano Banana 2. If the model does not appear in the dropdown at all, update n8n, then reopen the node. As a stopgap, an HTTP Request node can call the Gemini API directly, but prefer the supported node once the update lands, because it handles binary output for you.

Authentication fails with a 401 or 403 error

A 401 means the key is wrong, expired, or pasted with extra whitespace. A 403 usually means billing is not enabled on the linked project, or the key is restricted to a different API. Recreate the key in Google AI Studio, confirm billing is attached, paste it into a fresh n8n credential without trailing spaces, and test with a single Manual Trigger run before reactivating the schedule.

The workflow succeeds but no image file appears

Check the Gemini node output first, not the Drive node. If it has no binary data, the IF node check from Step 6 should have caught it, and the row should be marked failed with the real error. If binary data exists but Drive has no file, check the Drive node mapping: the binary property name must match what the Gemini node produced, and the destination folder must exist. A renamed binary property between nodes is a classic cause, fixed by remapping the input rather than regenerating the image.

Text in the image is garbled or misspelled

Nano Banana 2.1 improves text rendering over earlier models, but short text still renders more reliably than long text. Keep on-image text to a few words, spell it in the prompt exactly as it must appear, and put it in quotation marks inside the prompt. If a headline keeps failing, generate the image without text and add the headline with a design tool afterwards. That split is faster than burning ten generations on one stubborn word.

Rate limits return 429 errors on large batches

A 429 means you are sending requests faster than your quota allows, not that the workflow is broken. Slow the batch with a Wait node between items, split the sheet into smaller scheduled runs, or process high priority rows first. Check your quota in the Google Cloud console before raising limits, because a bigger batch without more quota just moves the same failure later in the run.

Every edit changes the product, not just the background

Edit prompts fail when they describe the whole scene instead of the single change. Rewrite the prompt to name what must stay unchanged first, then the one change, and stop. If the product still drifts, reduce the reference images to just the product photo, run the edit again, and add a style reference only once the background swap is stable.

FAQ

Which Nano Banana model should I pick in n8n?

Pick gemini-nano-banana-2.1 for most work. It is the current general availability model with 1K, 2K, and 4K output. Use the Lite model, gemini-3.1-flash-lite-image, only for high volume drafts where 1K output is enough and cost matters more than fine detail.

How much does one Nano Banana image cost through the API?

At the published rate of $30 per million image output tokens, a 1K image works out to about $0.034. That means 100 product images a day cost roughly $3.40 in image output tokens, before input tokens. Always check the current pricing page before budgeting a large batch, because token rates change.

Can n8n edit an existing product photo with Nano Banana?

Yes. Use the Google Gemini node with the Image operation set to Edit Image, upload one or more reference images, and write a prompt that describes only the change you want, for example swapping a background while keeping the product unchanged. The model can fuse up to 14 reference images in one call.

Why does my n8n Gemini node return no image?

The usual causes are an expired or restricted API key, a model name that your n8n version does not list, or a prompt that the safety filter blocks. Check the node execution log for the HTTP status, confirm the model name character by character, and test the same prompt in Google AI Studio before changing the workflow.

Where should generated images go in an n8n workflow?

Send the binary output to a Google Drive upload node or a Write Binary File node immediately, with a filename built from the product name and date. Never leave generated images only in an execution log, because logs are hard to search and old executions are eventually pruned.

Do I need a paid Google account to use Nano Banana in n8n?

You need a Gemini API key with billing enabled on the underlying Google Cloud project, because image output is billed on the API surface. Creating the key itself is free, but an image call without billing attached fails, so enable billing before your first workflow run.

Conclusion

The workflow in this tutorial is deliberately boring: a sheet of briefs, one Gemini node, one Drive upload, and a status writeback. Boring is the point, because a boring pipeline runs every day without attention, while a clever one breaks in ways that need attention. Start at 1K with Nano Banana 2.1, prove the chain end to end, add the edit branch for existing photos, and only then spend money on higher resolutions. Next, extend the same pattern with the n8n AI agent tutorial if you want an agent to write the prompts, or keep the prompts in the sheet if you prefer humans to stay in control of the brief.

Frequently asked questions

Which Nano Banana model should I pick in n8n?

Pick gemini-nano-banana-2.1 for most work. It is the current general availability model with 1K, 2K, and 4K output. Use the Lite model, gemini-3.1-flash-lite-image, only for high volume drafts where 1K output is enough and cost matters more than fine detail.

How much does one Nano Banana image cost through the API?

At the published rate of $30 per million image output tokens, a 1K image works out to about $0.034. That means 100 product images a day cost roughly $3.40 in image output tokens, before input tokens. Always check the current pricing page before budgeting a large batch, because token rates change.

Can n8n edit an existing product photo with Nano Banana?

Yes. Use the Google Gemini node with the Image operation set to Edit Image, upload one or more reference images, and write a prompt that describes only the change you want, for example swapping a background while keeping the product unchanged. The model can fuse up to 14 reference images in one call.

Why does my n8n Gemini node return no image?

The usual causes are an expired or restricted API key, a model name that your n8n version does not list, or a prompt that the safety filter blocks. Check the node execution log for the HTTP status, confirm the model name character by character, and test the same prompt in Google AI Studio before changing the workflow.

Where should generated images go in an n8n workflow?

Send the binary output to a Google Drive upload node or a Write Binary File node immediately, with a filename built from the product name and date. Never leave generated images only in an execution log, because logs are hard to search and old executions are eventually pruned.

Do I need a paid Google account to use Nano Banana in n8n?

You need a Gemini API key with billing enabled on the underlying Google Cloud project, because image output is billed on the API surface. Creating the key itself is free, but an image call without billing attached fails, so enable billing before your first workflow run.

TP
ToolPilot Team

We install, break, and fix automation tools so you don't have to. Every tutorial on ToolPilot is tested hands-on before publishing.

Keep reading