n8n

How to Generate OpenAI Images to Drive and Sheets?

Turn short chat prompts into AI images, store them in Google Drive, and log every result in Google Sheets with links and thumbnails. Great for marketing teams that need fresh visuals fast and want clear tracking of outputs and spend.

A chat based trigger captures the prompt and sends it to the OpenAI image API. The response can include one or many images, which are split and handled one by one. Each image is converted from base64 into a file, named with a timestamp, and uploaded to a selected Google Drive folder. The Drive link and a thumbnail image formula are written to a Google Sheet alongside the original prompt. Usage data from the run is aggregated and saved to a second sheet so you can monitor tokens and cost per prompt. A manual test trigger is included for quick checks before going live.

You will need an OpenAI API key and Google access for Drive and Sheets. Choose the Drive folder and the Sheets document where you want to save results. Expect faster image production, a clean asset library, and simple budget tracking for creative work. Ideal for social posts, ad mockups, blog art, and concept boards that need fast turnaround.

What are the key features?

  • Chat based trigger collects the prompt text for image creation.
  • HTTP call to the OpenAI image API generates JPEG files from the prompt.
  • Split and loop over the data array to process one or many images.
  • Convert base64 image data to a file and set a timestamped name.
  • Upload each file to a selected Google Drive folder and capture links.
  • Append the Drive link, prompt, and a thumbnail formula to Google Sheets.
  • Aggregate usage data and log tokens and cost to a second sheet.
  • Manual test trigger for safe debugging before live use.

What are the benefits?

  • Reduce manual image handling from 30 minutes to 2 minutes per batch
  • Streamline asset logging by 90 percent with automatic sheet updates
  • Improve data accuracy by removing copy and paste errors for links and thumbnails
  • Connect OpenAI, Google Drive, and Google Sheets in one simple flow
  • Handle single or multiple image outputs without extra setup
  • Track prompt level spend and tokens for better budget control

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with OpenAI, Google Drive and Google Sheets. See the Tools Required section above for links to create accounts with these services.
  3. Open the HTTP Request node and connect your OpenAI credential. If not set, click Credential to connect with, choose Create new credential, and follow the on screen steps to add your API key from your OpenAI account.
  4. Double click the Google Drive node. In the Credential dropdown, choose your Google Drive OAuth credential or create a new one and follow the on screen steps. Select the Drive and pick a folder for uploads.
  5. Open both Google Sheets nodes. In each, connect your Google Sheets OAuth credential or create a new one. Choose the correct document and sheet tabs for images and for cost logging.
  6. In the HTTP Request node, confirm the prompt field maps to the chat input value and that output format is set to JPEG.
  7. Open the Split Out and Loop Over Items nodes and confirm the data field is set to process the images array.
  8. In Convert to File, check that the source property is the base64 field from the API response and that the file name uses the timestamp expression.
  9. In the Google Sheets node for images, confirm the columns map to image link, prompt, and the thumbnail IMAGE formula using the Drive thumbnail link.
  10. In the Google Sheets node for cost, verify the columns capture prompt, datetime, and usage values from the API response.
  11. Click Test workflow to run with the manual trigger. Check that an image file appears in Google Drive and that a new row is added in both sheets.
  12. If the upload fails, recheck Google OAuth scopes and folder access. If the sheet thumbnail shows an error, confirm the Drive link is correct. If the OpenAI call fails, verify your API key and billing status.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

Google Sheets

Sign up

Free: $0 (Google Sheets API usage has no additional cost; quota limits apply)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Credits:
Created by darrell_tw_. X Threads Instagram Website

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.