Tutorial โ€” AI Image Generator for YouTube
Complete tutorial

AI image generator
for dark YouTube channels

Set up an automated workflow that creates images from prompts in your spreadsheet โ€” no coding required.

7 nodes
2 OAuth credentials
Unlimited images
Zero code

What this workflow does

Before configuring anything, understand what happens when you run the workflow.

๐Ÿ“‹ Spreadsheet
โ†’
๐Ÿ” Filter
โ†’
๐Ÿ” Loop
โ†’
๐Ÿงน Sanitize
โ†’
๐ŸŽจ Gemini API
โ†’
๐Ÿ–ผ Base64 โ†’ JPG
โ†’
โ˜๏ธ Drive
โ†’
โœ… Spreadsheet
1
Reads your spreadsheet

The workflow opens your Google Sheet and fetches all rows that have a prompt filled in and have not yet been processed (column Image Generated? not equal to Yes).

2
Processes one item at a time

Filtered items enter a loop that handles them one by one, respecting the request limits of the free API tier.

3
Sanitizes the filename New

The Sanitize Filename node converts the image_name value into a safe filename: all lowercase, spaces and special characters replaced with _, capped at 60 characters. The result is used as the JPG filename in Drive.

4
Generates the image with AI

The prompt is sent via HTTP request to Google Gemini. The API returns the image encoded in base64 inside the field candidates[0].content.parts[0].inlineData.data.

5
Decodes base64 to JPG New

The Decode Base64 to JPG node converts the binary data returned by Gemini into a ready-to-upload JPG file, using the sanitized filename from the previous step.

6
Saves to Google Drive

The JPG file is uploaded to the Google Drive folder configured in the Upload Image to Drive node.

7
Updates the spreadsheet

The row is updated with Yes, the image link, the Drive file ID, and the direct download link. If generation fails, the row is marked ERRO for later review and the loop continues.

8
Waits 60 seconds and repeats

The workflow waits 60 seconds between each image to respect the free Gemini API quota, then automatically moves to the next item in the loop.

โœฆ

Summary: fill in prompts in the spreadsheet, run the workflow, and the flow creates, converts, and organizes everything in Drive on its own. Only 3 fields need to be configured by you.

โ„น

3 required configuration fields: spreadsheet URL (Getting Image Prompts node), Gemini API Key (Gemini: Generate Image node), and Drive folder URL (Upload Image to Drive node).

Setting up your spreadsheet

The workflow reads data from a specific spreadsheet. Make a copy of the template and set up the columns correctly.

1
Access the spreadsheet template

Click the link below to open the official template for this workflow:

https://docs.google.com/spreadsheets/d/YOUR_LINK_HERE
โ„น

The link above will be replaced with the real URL before this tutorial is published.

2
Make a copy to your account

With the spreadsheet open, click File โ†’ Make a copy. Give it a name and choose a destination folder in Drive.

๐Ÿ“ธ
Screenshot needed
Google Sheets screen โ€” File menu โ†’ Make a copy
3
Column structure

Your spreadsheet must have exactly these columns. Do not rename them โ€” the workflow matches by exact column name:

Column What to put Type
image_name A unique name to identify the image. E.g. opening_scene_ep1. Used as the filename in Drive. Required
prompt_image Image description in English. E.g. A dark forest at night, cinematic lighting Required
Image Generated? Leave blank โ€” auto-filled with Yes or ERRO Auto
Image Link Leave blank โ€” filled with the Drive view link (webViewLink) Auto
Google Drive ID Leave blank โ€” filled with the internal Drive file ID Auto
Google Drive Download Link Leave blank โ€” filled with the direct download link (webContentLink) Auto
4
Copy the spreadsheet URL

With the spreadsheet open, copy the full address from the browser's address bar. You'll need it in n8n.

โœฆ

The URL must start with https://docs.google.com/spreadsheets/d/. Copy everything, including the /edit... at the end.

Creating your key in Google AI Studio

For Gemini to generate images, it needs an access key. It's free and takes less than 2 minutes to create.

โ„น

In this workflow, the Gemini API Key is configured directly inside the HTTP node "Gemini: Generate Image" โ€” you do not need to create a separate credential for it in n8n. Never share this key with anyone.

1
Go to Google AI Studio

Open the link below in a new tab and sign in with the Google account you'll use in n8n.

https://aistudio.google.com
2
Click "Get API Key"

In the left sidebar, click "Get API Key".

๐Ÿ“ธ
Screenshot needed
AI Studio sidebar with the "Get API Key" item highlighted
3
Create a new key

Click "Create API Key". Select an existing Google Cloud project or click "Create API key in new project".

4
Copy and save your key

The generated key looks like this: AIzaSyXXXXXXXXXXXXXXXXXXXXXXXX. Click Copy and save it somewhere safe.

โš 

Save this key now. Once you close this dialog, you cannot view it again โ€” you'll have to delete it and create a new one.

Setting up credentials in n8n

You'll configure 2 OAuth credentials: one to read and write to the spreadsheet, and one to upload images to Drive. The Gemini key goes directly in the HTTP node โ€” no credential needed.

โš 

Set up credentials before importing the workflow. That way the nodes will find them ready to use.

A
Google Sheets OAuth2 API
Read & write to the spreadsheet
1

In n8n, go to Settings โ†’ Credentials โ†’ + Add Credential.

2

Search for Google Sheets and select "Google Sheets OAuth2 API".

3

Click "Sign in with Google" and authorize access with the account that owns the spreadsheet. The credential is saved automatically.

B
Google Drive OAuth2 API
Upload generated images
1

Click + Add Credential. Search for Google Drive and select "Google Drive OAuth2 API".

2

Click "Sign in with Google" and authorize with the same account used for Sheets.

โœฆ

Gemini does not need an OAuth credential. Authentication with Gemini is done via API Key, which you'll paste directly inside the "Gemini: Generate Image" node in Step 05.

Configuring the workflow nodes

Open each node that requires configuration and point it to your own resources. Only 3 nodes need editing โ€” the rest are ready to go.

โ„น

Quick summary: edit only Getting Image Prompts (spreadsheet URL), Gemini: Generate Image (API Key), and Upload Image to Drive (Drive folder URL). Everything else needs no changes.

1
Node "Getting Image Prompts"

Credential: Select the Google Sheets credential (credential A).

Document: Paste the full URL of your spreadsheet where the placeholder text "Paste your spreadsheet URL here" appears.

Sheet Name: Select the correct tab from the dropdown (e.g. Geracao Imagem).

๐Ÿ“ธ
Screenshot needed
Node "Getting Image Prompts" with Document and Sheet Name configured
2
Node "Sanitize Filename" New

This is a JavaScript code node that converts image_name into a safe filename. No configuration needed โ€” it's already set up and working out of the box.

โœฆ

The generated filename will look like opening_scene_ep1.jpg. Special characters, spaces, and accents are automatically removed.

3
Node "Gemini: Generate Image"

This node is an HTTP Request that calls the Gemini API directly โ€” it does not use an OAuth credential. Configure it as follows:

URL: already pre-filled with the correct endpoint (don't change it for now โ€” see Step 07 to switch the model).

Query Parameter "key": replace the text "I entered your API key here" with your real API key from Google AI Studio.

๐Ÿ“ธ
Screenshot needed
Node "Gemini: Generate Image" with the "key" field highlighted in query parameters
โš 

If this node shows a red error, check that the API Key was pasted in the key field under Query Parameters โ€” not in the URL field or the request body.

4
Node "Decode Base64 to JPG" New

Converts the image returned by Gemini (in base64) into a binary JPG file. No configuration needed โ€” the node automatically reads the correct field from the API response and uses the filename generated by Sanitize Filename.

5
Node "Upload Image to Drive"

Credential: Select the Google Drive credential (credential B).

Drive / Folder: In the destination folder field, paste the URL of the Google Drive folder where images will be saved, replacing the placeholder text "Paste your Google Drive folder URL here".

โœฆ

Create the destination folder in Drive before configuring this node. The folder URL has the format https://drive.google.com/drive/folders/FOLDER_ID.

6
Nodes "Update Sheet - Success" and "Update Sheet - Error"

Configure both the same way: Credential โ†’ Google Sheets (credential A), Document โ†’ spreadsheet URL, Sheet Name โ†’ correct tab.

On success, the node writes Yes, the image link, and the Drive data. On generation failure, the error node writes ERRO and the loop continues to the next item.

Running your first test

Everything is configured. Let's verify it's working with a single-image test run.

1
Add a test row

In your spreadsheet, add a row with the following data:

image_name:    test_01
prompt_image:  A beautiful mountain at sunset, ultra realistic, cinematic
Image Generated?: (leave blank)
โœฆ

Always write prompts in English. Gemini produces higher-quality images with English prompts.

2
Execute the workflow

In n8n, click the "Execute Workflow" button in the top-right corner.

๐Ÿ“ธ
Screenshot needed
"Execute Workflow" button highlighted in the n8n editor
3
Watch the execution

Nodes turn green as they process. The expected sequence is: Getting Image Prompts โ†’ Filter โ†’ Loop โ†’ Sanitize Filename โ†’ Gemini: Generate Image โ†’ Decode Base64 to JPG โ†’ Upload Image to Drive โ†’ Update Sheet - Success โ†’ Wait. The Gemini call may take 20 to 60 seconds. Wait until the workflow finishes completely.

4
Check the result

Go back to the spreadsheet. The test row should show Yes in the Image Generated? column, and links in the Image Link, Google Drive ID, and Google Drive Download Link columns. Click Image Link to view the image!

๐Ÿ“ธ
Screenshot needed
Spreadsheet with the test row filled in: Image Generated? = Yes and links visible

How to switch the AI model

The Gemini image generation model is still in preview โ€” Google may change the name or release better versions at any time.

โš 

If the workflow suddenly stops working without any changes on your end, the first thing to check is whether the model name is still valid. Preview models have a short shelf life.

1
Check the official documentation

Open the list of available models. Look for ones that list "image generation" in their capabilities and copy the exact Model code.

https://ai.google.dev/gemini-api/docs/models
2
Confirm in Google AI Studio

Test the model before applying: in AI Studio, select the model, send a simple prompt, and verify that an image is generated. Then click "Get Code" โ†’ REST to see the endpoint:

POST https://generativelanguage.googleapis.com/v1beta/models/MODEL-NAME:generateContent

Copy exactly the highlighted portion.

3
Update it in the n8n node

Open the Gemini: Generate Image node and find the URL field. The current configured model is:

https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent

Replace only the highlighted portion with the new model name. Keep the prefix and the :generateContent suffix intact.

โœฆ

Always test with one row before processing the full batch. Confirm the model works before consuming API quota.

Common issues and solutions

Something didn't work? Here are the most frequent errors and how to fix them.

The "Gemini: Generate Image" node turned red with a 429 error
Fix: You've hit the requests-per-minute limit on the free tier. Wait a few minutes and run again. The 60-second Wait node already prevents this under normal conditions, but large batches can exceed the daily limit.
The "Gemini: Generate Image" node returned an authentication error (401)
Fix: The API Key is incorrect or was pasted in the wrong place. Confirm it is in the key field under Query Parameters โ€” not in the URL field or the request body. Also check for any extra spaces in the key.
The spreadsheet doesn't appear in the "Sheet Name" dropdown
Fix: Make sure that (1) the URL is complete, (2) you're using the same Google account that has access to the spreadsheet, and (3) the spreadsheet is not in a restricted folder. Try the refresh icon next to the field.
The "Image Generated?" column stays blank after running
Fix: The column name must be exactly Image Generated? โ€” with a question mark, a space before the G, and the correct capitalization. Case and spaces matter.
The "Decode Base64 to JPG" node turned red
Fix: This usually means Gemini returned text instead of an image, or the configured model doesn't support image generation. Follow Step 07 to verify the model name. Check ai.google.dev/gemini-api/docs/models to confirm which models support image generation.
The Drive upload fails with a permission error
Fix: The destination folder must belong to the same Google account connected in the Drive credential. Try creating a new folder and selecting it in the node. Confirm that the folder URL was pasted in the correct field.
The workflow reprocesses rows that already have "Yes"
Fix: The Only Unprocessed filter depends on the exact column name. Confirm the column is named exactly Image Generated? โ€” no extra spaces, with the question mark.
The workflow takes a very long time to process many images
Fix: On the free tier, 10 images โ‰ˆ 10 minutes (60 s wait each). Process in smaller batches throughout the day, or consider a paid Gemini plan to reduce the wait time to 10โ€“15 seconds in the Wait node.

All set. Make great videos.

Fill in your prompts, run the workflow, and let AI do the work.

Open workflow in n8n Download spreadsheet template