What this workflow does
Before configuring anything, understand what happens when you run the workflow.
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).
Filtered items enter a loop that handles them one by one, respecting the request limits of the free API tier.
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.
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.
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.
The JPG file is uploaded to the Google Drive folder configured in the Upload Image to Drive node.
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.
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.
Click the link below to open the official template for this workflow:
The link above will be replaced with the real URL before this tutorial is published.
With the spreadsheet open, click File โ Make a copy. Give it a name and choose a destination folder in Drive.
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 |
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.
Open the link below in a new tab and sign in with the Google account you'll use in n8n.
In the left sidebar, click "Get API Key".
Click "Create API Key". Select an existing Google Cloud project or click "Create API key in new project".
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.
In n8n, go to Settings โ Credentials โ + Add Credential.
Search for Google Sheets and select "Google Sheets OAuth2 API".
Click "Sign in with Google" and authorize access with the account that owns the spreadsheet. The credential is saved automatically.
Click + Add Credential. Search for Google Drive and select "Google Drive OAuth2 API".
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.
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).
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.
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.
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.
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.
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.
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.
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.
In n8n, click the "Execute Workflow" button in the top-right corner.
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.
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!
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.
Open the list of available models. Look for ones that list "image generation" in their capabilities and copy the exact Model code.
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.
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.
key field under Query Parameters โ not in the URL field or the request body. Also check for any extra spaces in the key.Image Generated? โ with a question mark, a space before the G, and the correct capitalization. Case and spaces matter.Only Unprocessed filter depends on the exact column name. Confirm the column is named exactly Image Generated? โ no extra spaces, with the question mark.