What this workflow does
This workflow takes a chat message that describes an image and turns it into real picture files.
It stops the user from doing slow, error-prone work by making images, saving them in Google Drive, and logging all details in Google Sheets automatically.
The result is saved images with clear info and tracked costs, all without much effort from the user.
The main problem solved is saving time and avoiding mistakes when managing AI-generated images.
It works by catching a chat prompt, sending it to OpenAI’s image generation API, then handling each returned image file step by step.
Who should use this workflow
Anyone who makes AI images from chat text and wants to avoid doing boring manual work.
It fits engineers, makers, or small teams who upload files to Google Drive and track them in Sheets.
The workflow works well for users who want costs tracked and data centrally stored.
It needs a Google Drive and Sheets account plus OpenAI API access.
Tools and services used
- OpenAI API: Generates AI images from text prompts.
- Google Drive: Stores image files in organized folders.
- Google Sheets: Saves image URLs, prompt text, and cost data.
- n8n workflow automation: Connects services with nodes including Chat Trigger, HTTP Request, and others.
Beginner step-by-step: How to use this workflow in n8n
Import and prepare
- Download the workflow file from this page.
- Open the n8n editor.
- Click the menu and select “Import from File”.
- Choose the downloaded workflow file to load it in.
Configure credentials and settings
- Add OpenAI API credentials in n8n settings.
- Add Google Drive and Google Sheets OAuth2 credentials.
- Update the Google Drive folder ID in the Google Drive node if needed.
- Update Google Sheets document ID and sheet names in the Google Sheets nodes.
Test and activate
- Trigger the workflow using the Chat Trigger by sending a sample chat message describing an image.
- Check if images appear in Google Drive and rows append in Google Sheets.
- If all works, go back to editor and activate the workflow for production use.
This activates your workflow to run automatically when new chat image prompts arrive.
No need to build from zero, only minor updating of IDs and credentials.
If self hosting n8n, consider self-host n8n for production readiness.
Inputs, Processing, and Outputs
Inputs
- The workflow starts when a chat message arrives containing the image description.
- The message data is the main input for the subsequent API call.
Processing Steps
- Send the prompt to OpenAI image generation API with parameters for model, size, format, and quality.
- Split the array of returned image data to process each image separately.
- Loop over each image one at a time to avoid upload conflicts.
- Generate a unique filename using the current timestamp string.
- Convert the base64 encoded image JSON into a binary file ready for upload.
- Upload the image file to a specific Google Drive folder with dynamic file naming.
- Enrich metadata by adding Google Drive file IDs and web links.
- Log prompt text, full image URL, and thumbnail into a Google Sheets spreadsheet.
- Aggregate token usage from the API response to calculate estimated costs.
- Append usage data including tokens spent and billing estimates to a separate Google Sheets tab.
Outputs
- Image files saved in Google Drive folder with unique names.
- Rows in Google Sheets including prompt, file link, thumbnail image, and cost data.
- Clear tracking of what was generated, when, and how much it cost.
Handling errors and edge cases
If the OpenAI API key is missing or wrong, the workflow will fail at the HTTP Request node step due to authentication error.
Check credentials and re-enter the correct API key.
If Google Drive uploads are missing or scattered, verify that the folder ID in the Google Drive node is correct and accessible by the Google account used.
Wrong folder ID causes files to upload somewhere else or fail.
If rows do not append to Google Sheets, ensure the document ID and sheet names match the spreadsheet setup, and the columns expected exist.
Typos in sheet names or mismatched columns cause append errors.
Customization ideas
- Change image size or quality in the HTTP Request node by editing the parameters like
sizeorquality. - Set how many images are generated per prompt by changing the
nnumber. - Use dynamic Google Drive folder creation based on date or other rules to organize uploads better.
- Add more columns or fields to Google Sheets to save extra metadata like file ID or creation timestamps.
- Add an email node (Gmail or SMTP) after upload to send image links automatically to a team or user.
Summary and Result
→ This workflow gets a text chat prompt to generate AI images.
→ Automated file upload and metadata logging keeps everything tracked without manual steps.
→ Users save lots of time and avoid errors in managing AI generated images.
→ Detailed cost monitoring helps control API usage spend.
