AI Image Generation and Google Drive Storage from Google Sheets - n8n Workflow

Automate AI image generation from Google Sheets using this robust n8n workflow. Generate images via RapidAPI, upload them to Google Drive, and log results automatically using the n8n node structure.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

• Content marketers needing to generate large batches of visual assets.
• Automation engineers looking for advanced file handling and AI integration n8n templates.
• Users who manage product catalogs and need automated image variation creation.
• Anyone seeking a practical example of a robust, looping n8n workflow with built-in error handling.

Overview

This comprehensive n8n template solves the critical challenge of mass-generating AI visuals and ensuring organized storage. Instead of manually feeding prompts to an AI generator and then separately managing the resulting files, this n8n workflow uses Google Sheets as a centralized command hub. When the n8n trigger is activated, the workflow systematically reads unprocessed prompts, calls the Image-to-Image GPT API via a specialized HTTP Request n8n node, and manages the binary conversion. The resulting images are securely uploaded to Google Drive. The architecture of this n8n workflow includes critical error handling using the If n8n node and logging updates back to Google Sheets, providing a reliable and scalable solution for high-volume content generation.

How it Works

The n8n workflow initiates execution via the When clicking ‘Execute workflow’ manual n8n trigger. It immediately proceeds to the Google Sheets2 n8n node, which retrieves all relevant data rows containing image prompts.


  1. Looping and Filtering: The Loop Over Items n8n node ensures that each row is processed individually. The subsequent If2 n8n node acts as a gatekeeper, continuing only if a Prompt exists and the drive path column is currently empty (indicating the row is unprocessed).

  2. AI Generation: The HTTP Request1 n8n node sends the prompt and relevant image data to the external AI API endpoint on RapidAPI, designed for image generation. This n8n node is configured to continue on error.

  3. Image Preparation: The Code1 n8n node is essential for data transformation. It converts the base64 encoded image string received from the API into a binary data format (Buffer) that the Google Drive n8n node can utilize for file upload.

  4. Storage: The Google Drive1 n8n node uploads this newly created binary file (the AI-generated image) to the configured Drive folder.

  5. Status Update (Success): The Google Sheets1 n8n node updates the original Google Sheet row, marking it as processed by appending the generated Base64 data and the generation date, thus maintaining a complete audit trail within the n8n workflow.

  6. Error Logging: If the HTTP Request1 fails, the error path leads to the If1 n8n node, which detects the error state. Google Sheets4 then logs the error message back to the sheet, ensuring no data loss and smooth continuation of the main loop.

  7. Pacing: A Wait n8n node introduces a 10-second delay before the loop iterates to the next item, helping to manage API rate limits and prevent resource exhaustion.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and import it into your n8n instance via the 'New' menu -> 'Import from JSON'.

  2. Credentials Setup: You will need to configure credentials for two primary services:

Google Sheets/Drive: Update the Google Sheets2, Google Sheets1, Google Sheets4, and Google Drive1 n8n node connections to use your Google Service Account credentials, ensuring access to the target sheet and drive folder. Note: All Google n8n nodes use the same credential set in this template.
RapidAPI: Update the HTTP Request1 n8n node. Replace the placeholder value for the x-rapidapi-key header with your actual key from the RapidAPI service.

  1. Sheet Configuration: Ensure your Google Sheet has columns named 'Prompt' and 'drive path'. The n8n workflow uses 'Prompt' as input and 'drive path' for filtering/status logging.

  2. Execute: After setup, click the 'Execute workflow' n8n trigger button to begin processing your prompts.

Node Details


  • When clicking ‘Execute workflow’ (n8n Trigger): A manual n8n trigger used to start the execution of the entire batch process.

  • Google Sheets2: Reads data from the specified Google Sheet (Sheet1, gid=0). Function: Fetches prompts to be processed.

  • Loop Over Items (n8n node): Splits the incoming data rows into batches of one, allowing the n8n workflow to process each prompt sequentially.

  • If2 (n8n node): Flow control logic. Function: Checks if Prompt is not empty AND drive path is empty, ensuring only new items are processed by the n8n workflow.

  • HTTP Request1: Function: Connects to the external AI image generation API (RapidAPI). Key Configuration: Uses POST method, Multipart-Form Data, passing prompt and Image url fields.

  • Code1 (n8n node): Function: Converts the base64 string response (image_base64) from the API into a binary Buffer object with mimeType: 'image/jpeg', preparing it for Google Drive upload.

  • Google Drive1: Function: Uploads the binary image file created by the Code1 n8n node to the configured Google Drive folder.

  • Google Sheets1: Function: Updates the original Google Sheet row with the generated image's Base64 content, Prompt, and generation date after a successful upload.

  • If1 (n8n node): Function: Error check. Determines if the previous HTTP Request n8n node generated an error.

  • Google Sheets4: Function: Logs error information (error message and prompt) back to the Google Sheet if the AI generation failed.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by
Evoort Solutions
Evoort Solutions

Featured*