Large Language ModelsGenerate imagesGenerate videos

n8n Image Generation Workflow: Nano Banana and Gemini Templates

A working n8n image generation workflow needs more than a single node. This article walks through Nano Banana and Gemini templates, the HTTP Request setup, prompt variables, batching, retries, and saving finished images to storage, with a PicassoIA path for testing prompts first.

n8n Image Generation Workflow: Nano Banana and Gemini Templates
Cristian Da Conceicao
Founder of Picasso IA

Most n8n image automations break the same way. Someone wires a prompt field to a node, gets one lovely picture on the first run, and then a batch of forty rows hits a rate limit, a safety block, or a base64 string that never turns into a real file. This article builds an n8n image generation workflow that survives the second run, using the Nano Banana family from Google and the Gemini image endpoint behind it.

You get the node order, the exact request body, three reusable templates, retry settings, a cost estimate, and a way to test prompts on PicassoIA before you spend a single API call. Nano Banana is the nickname for Gemini 2.5 Flash Image, so everything here applies whichever name you use.

Why Image Workflows Break in n8n

Text workflows forgive sloppy design. If an LLM node returns a slightly odd sentence, the next node still receives a string. Images are different: the output is binary data wrapped in JSON, the call takes ten to thirty seconds, and a single refusal can return a perfectly valid HTTP 200 with no picture inside. That mismatch is why so many copied templates look fine in a screenshot and fall over at row three.

Five Failures Worth Planning For

Nearly every broken image workflow fails in one of these five places:

  1. Base64 never becomes a file. The API returns image bytes as a long text string. Without a conversion step, you upload a string to storage and wonder why the preview is blank.
  2. Empty responses that look healthy. A blocked prompt can return status 200 with no image part at all. The next node runs on nothing.
  3. Burst traffic. Forty items sent at once exceed the per-minute limit, and half of them fail with a 429.
  4. Messy prompt input. Spreadsheet cells with quotes, line breaks, or trailing spaces break hand-built JSON bodies.
  5. No storage step. n8n prunes old execution data by default, so an image that only exists inside an execution eventually disappears.

A frustrated builder looking at a workflow canvas with one failed step outlined

What a Reliable Setup Needs

The fix is boring, and that is the point. A dependable workflow has a validation step after the API call, a conversion step that produces a real file, a storage step that returns a permanent URL, and pacing between calls. Everything else in this article is a variation on those four pieces.

💡 Build with one item first. Run the whole chain on a single row with the Manual Trigger. Add the loop and the schedule only after one image lands in storage with the right file name.

Choosing a Google Image Model

Naming Without the Confusion

Google's naming moves fast. Nano Banana started as the nickname for Gemini 2.5 Flash Image, and Pro, 2, and Lite variants followed. On the API side each nickname maps to a model ID, and those IDs change more often than the nicknames do. Store the ID in a single field of your first Edit Fields node and reference it everywhere. When a better model ships, you change one value instead of editing five nodes.

PicassoIA lists the whole family, which makes it a convenient place to compare outputs before you wire anything: Nano Banana, Nano Banana 2, Nano Banana 2 Lite, Nano Banana Pro, and Gemini 2.5 Flash Image.

Three printed photographs and a ripe banana arranged on a concrete table

Picking the Right Tier

ModelBest use in n8nWhat to know
Nano BananaFast drafts and photo edits with reference imagesAccepts several reference images, outputs JPG or PNG
Gemini 2.5 Flash ImageThe model ID most HTTP Request setups call firstSame family as Nano Banana, quick turnaround
Nano Banana 2Iterative edits and consistent characters across scenesUp to 14 reference images, 1K to 4K output, 15 aspect ratios
Nano Banana 2 LiteLarge batches where speed matters mostSpeed-first variant of the second generation
Nano Banana ProFinal art for print or hero placementsBuilt for 4K output

A practical rule: draft with the cheap tier and regenerate only the approved winners with the Pro tier. A second branch in the same workflow can handle that upgrade automatically once a row is marked approved.

The Core Workflow, Node by Node

The base workflow has seven nodes. Build them in this order and test after each one:

  1. Manual Trigger while you build, replaced later by a Schedule or Webhook trigger
  2. Edit Fields, renamed Prompt Fields
  3. HTTP Request, renamed Gemini Image
  4. Code, renamed Extract Image
  5. Convert to File
  6. S3-compatible upload (Cloudflare R2, AWS S3, or any similar bucket)
  7. Edit Fields or Google Sheets to record the final URL

Trigger and Prompt Fields

Start with the Manual Trigger and an Edit Fields node that creates four fields: prompt, aspect_ratio, slug, and model. Use 16:9 for blog headers and 1:1 for product shots. Keep the slug lowercase with hyphens, because it becomes the file name.

Clean the prompt at this stage with an expression such as {{ $json.prompt.trim() }}. Trailing spaces and stray line breaks from a spreadsheet are a surprisingly common reason for odd results.

The Gemini HTTP Request Call

Add an HTTP Request node, set the method to POST, and use this URL, with the model ID read from your model field:

https://generativelanguage.googleapis.com/v1beta/models/{{ $json.model }}:generateContent

For authentication, pick the Google Gemini(PaLM) Api credential if your n8n version lists it for the HTTP Request node. If it does not, use Header Auth with the header name from Google's API documentation. Then turn on Send Body, choose JSON, and build the body as an expression so quotes inside a prompt can never break it:

{{ JSON.stringify({
  contents: [{ parts: [{ text: $json.prompt }] }],
  generationConfig: {
    responseModalities: ["TEXT", "IMAGE"],
    imageConfig: { aspectRatio: $json.aspect_ratio }
  }
}) }}

Under Options, raise the timeout to 120000 ms. Image calls are slower than text calls, and the default will cut off a healthy request.

💡 n8n also ships a native Google Gemini node, and its image operations have been changing between versions. Check the operation list in your own install. The HTTP Request approach shown here works in every version and exposes the full response, which is what makes the validation step possible.

Hands typing on a keyboard in front of a blurred monitor showing short lines of code

Turning Base64 Into a File

The response nests the picture inside candidates[0].content.parts, next to any text the model decided to add. The image part carries an inlineData object with a mimeType and a base64 data string. Do not assume the image is the first part. Find it.

Add a Code node in Run Once for Each Item mode:

const parts = $json.candidates?.[0]?.content?.parts ?? [];
const img = parts.find(p => p.inlineData);
if (!img) {
  const reason = $json.promptFeedback ?? $json.candidates?.[0]?.finishReason ?? 'unknown';
  throw new Error('No image returned: ' + JSON.stringify(reason));
}
return {
  json: {
    image_b64: img.inlineData.data,
    mimeType: img.inlineData.mimeType,
    slug: $('Prompt Fields').item.json.slug
  }
};

Throwing an error on a missing image is deliberate. It turns a silent failure into a visible one, and it lets the retry and error-output settings from the next section do their work.

Next comes Convert to File with the operation Move Base64 String to File. Set the base64 input field to image_b64 and name the file {{ $json.slug }}.png. Gemini image output generally arrives as PNG, and you can read mimeType if you want to be strict about the extension. Finally, send the file to your bucket with the S3 node and write the public URL back to wherever your content lives.

A hand sliding a freshly printed mountain lake photograph out of a desktop printer

Three Templates Worth Copying

n8n's template library has many community workflows built around Nano Banana and Gemini images, and browsing a few is a fast way to see different layouts. Quality varies, so check each one against the five failures above. The three skeletons below are the ones that come up most often.

Template One: Header Image Batch

Use this when a content team needs a header image for every post in a spreadsheet.

Flow: Schedule Trigger → Google Sheets (rows where status is empty) → Loop Over Items (batch size 2) → Prompt Fields → Gemini Image → Extract Image → Convert to File → S3 upload → Google Sheets (write image_url and status = done) → Wait (6 seconds) → back to the loop.

Build the prompt from the post title plus a fixed style suffix so every header shares a look: {{ $json.title }}, wide editorial photograph, natural window light, 35mm lens, shallow depth of field, no text. Keep the suffix in one place and forty images will feel like they belong to the same site.

The status column matters more than it looks. Rows marked done are skipped on the next run, so a crashed run resumes where it stopped instead of paying for the same images twice.

Two colleagues reviewing a wall of sixteen printed blog header photographs

Template Two: Product Photo Variants

This one edits an existing photo and changes the setting around it. The request is the same as before with one extra part: the source photo as base64. Download the photo with an HTTP Request node, pass it through Extract From File using Move File to Base64 String, and add it next to the text part:

parts: [
  { text: $json.prompt },
  { inlineData: { mimeType: 'image/jpeg', data: $json.photo_b64 } }
]

Then loop four prompts over each product: a marble counter in morning light, a pale oak table, folded linen, and an outdoor stone ledge. Always include the sentence Keep the product exactly unchanged and change only the surroundings. Without it, image models love to redesign the label.

A white ceramic mug and a leather wallet on an oak board in a small studio setup

Template Three: Webhook to Social Post

A Webhook trigger receives a topic and a platform. A Basic LLM Chain with a Google Gemini chat model writes a photographic prompt, the image call follows, and the finished URL goes back to whoever asked.

Image calls can run ten to thirty seconds. If a proxy in front of n8n cuts requests at 30 or 60 seconds, answer the webhook immediately with a job ID and post the finished URL to a callback address afterward. Otherwise the caller sees a timeout while n8n happily finishes the job and bills you for it.

Retries, Rate Limits, and Costs

Retry and Pacing Settings

Retries and pacing decide whether a 200-row run finishes overnight or stalls at row 12. Set these on the nodes themselves:

SettingValueWhy
Retry On Fail (Gemini Image)On, Max Tries 3Transient 429 and 5xx errors usually clear on their own
Wait Between Tries5000 ms or moreGives the per-minute limit time to reset
Timeout (HTTP Request option)120000 msImage calls are slower than text calls
On ErrorContinue (using error output)Failed rows go to a separate branch instead of stopping the run
Loop Over Items batch size2 to 5Keeps bursts under the limit
Wait node between batches5 to 10 secondsSpreads calls across the minute

Route the error output to a Sheets update that writes failed plus the error message. Retrying failed rows later becomes a one-click filter, and patterns show up fast, such as one prompt phrase that trips the safety filter every time.

A calculator, printed spreadsheet, pencil, and kitchen timer seen from above

Estimating the Bill

Google listed Gemini 2.5 Flash Image at roughly $0.039 per image at launch. Check the current pricing page before you budget, but the math is simple: 500 header images at that rate come to about $19.50, and every retry that produces an image counts again. Higher tiers cost more per image. Three habits keep spend down:

  • Test prompts on PicassoIA first. Nano Banana 2 is listed there with unlimited generations, so rewording a prompt twelve times costs nothing.
  • Retry failures only, never whole batches.
  • Draft cheap, finish expensive. Use the lighter tier for drafts and regenerate only approved rows on the Pro tier.

Prompt Patterns That Hold Up

Let an LLM Write the Prompts

A spreadsheet row that says Remote work setup is not a prompt. Add a Basic LLM Chain before the image call, attach a Google Gemini chat model, and give it a fixed instruction: turn the topic into one photographic prompt of 50 to 70 words, with subject, setting, light direction, lens, and texture details, and return only the prompt. Gemini 3.5 Flash and Gemini 3 Flash both suit this job, because the task is short and speed matters more than depth.

💡 Log the generated prompt next to the image URL in your sheet. When an image disappoints, you can see exactly what the model was asked.

Photography Terms the Model Respects

Image models tend to respond well to a photographer's vocabulary. Use this order: subject and action, setting, light direction, camera and lens, surface texture, mood.

ElementWeak wordingStronger wording
Lightbrightsoft window light from the left, late morning
Lensnice camera85mm at f/1.8, shallow depth of field
Anglegood anglelow angle, looking slightly upward
Texturedetailedvisible wood grain, fabric weave, paper fibers
Textwrite a titleno text in the frame

Ask for no text by default. Generated lettering is the most common reason an otherwise good header image gets rejected, and it is far easier to add a real title in your design tool afterward.

A photographer's workbench with a vintage film camera, light meter, and sketch notebook

How to Use Nano Banana on PicassoIA

Prompts are cheaper to fix before they live inside a workflow. Nano Banana on PicassoIA belongs to the same family your HTTP node calls, so a prompt that works there is a strong candidate for automation.

  1. Open the Nano Banana page on PicassoIA.
  2. Paste the prompt exactly as your Edit Fields node would produce it, style suffix included.
  3. Add reference photos in the Image Input field if your workflow edits existing images. The model accepts several at once.
  4. Pick JPG or PNG as the output format.
  5. Generate three versions, changing one phrase at a time: the light, the lens, or the setting.
  6. Copy the winning wording back into n8n.

Move up to Nano Banana 2 when you need more control. It adds 15 aspect ratio options including 16:9, 9:16, and 4:5, 1K, 2K, and 4K resolution, up to 14 reference images, and optional Google Search grounding. The aspect ratio setting maps directly to the aspectRatio field in your request body. For speed-first batches there is Nano Banana 2 Lite, and Nano Banana Pro handles final 4K renders.

Polish Results Before Publishing

Even strong outputs benefit from a finishing pass. Real-ESRGAN and Crystal Upscaler enlarge images for hero placements, and Bria Remove Background cuts product shots out for catalog pages. If a style does not fit Google's models, compare Seedream 4.5, Flux 2 Pro, and Imagen 4 with the same prompt before changing your workflow. A ten-minute comparison beats a week of prompt tweaking.

A smiling woman at a cafe window table with a laptop showing a generated forest landscape

Run Your First Batch on Picasso IA

You now have the whole chain: a validated request, real files, storage, pacing, retries, and prompts worth automating. Build it with one row, then ten, then the full sheet.

Before you do, spend fifteen minutes on Picasso IA with your five most important prompts. Try them on Nano Banana 2, compare the results with Nano Banana Pro, and keep the wording that wins. Then paste those prompts into your Edit Fields node and let n8n handle the volume. Browse every model at picassoia.com/en/all-models and start with a header image for your next post.

Share this article