Back to Templates
This n8n workflow automates the process of generating multiple AI-created images from a single prompt using OpenAI's DALL·E 2, then uploads the results directly to a Google Drive folder. It includes a loop to produce several image variations for the same prompt, making it ideal for creative projects, marketing materials, or content experimentation.
OpenAI API Key
Google Drive API
Add a Manual Trigger node to start the workflow manually when testing.
Add a Set node with two fields:
Prompt
→ The image description text.Name
→ The base name for the saved file.Example:
Name | Value |
---|---|
Prompt | Make an image of an attractive woman standing in New York City |
Name | woman-nyc |
Use this JavaScript to create three copies of the prompt (run 1, run 2, run 3):
const original = items[0].json;
return [
{ json: { ...original, run: 1 } },
{ json: { ...original, run: 2 } },
{ json: { ...original, run: 3 } },
];
#### Step 4 — Loop Over Items
Insert a **Split in Batches** node and set the batch size to `1`. This ensures each prompt variation runs through the image generation process individually. Connect this node so it runs after the **Duplicate Rows** node.
#### Step 5 — Generate Image
Add the **OpenAI Image Generation** node and configure it as follows:
- **Model**: `dall-e-2`
- **Prompt**: `={{ $json.Prompt }}`
- Leave other options at their defaults unless you want to specify image size or style.
- Connect your **OpenAI API** credentials created in Step 1.
This node will send the current prompt in the batch to OpenAI's DALL·E 2 model and return an AI-generated image.
#### Step 6 — Upload to Google Drive
Add a **Google Drive** node and configure it to store the generated image:
- **File Name**:
`={{ $('Set Image Prompt').item.json.Name }} - {{ $('Duplicate Rows').item.json.run }}`
- **Folder ID**: Select the target Google Drive folder where images should be saved.
- Connect your **Google Drive OAuth2 API** credentials.
The node will upload each generated image to your chosen Google Drive location, with a unique filename for each variation.
---
### Running the Workflow
1. Execute the workflow manually.
2. The process will:
- Loop through each prompt variation.
- Generate an image using OpenAI DALL·E 2.
- Upload the image to Google Drive with a unique name.
3. You will find all generated images in the selected Google Drive folder.
---
### Customization Tips
- Change the number of variations by editing the **Duplicate Rows** code.
- Adjust the prompt dynamically from other data sources like Google Sheets, webhooks, or forms.
- Schedule the workflow to run at specific times or trigger it via an API call.
---
**Created by Robert A. – Ynteractive**
Website: https://ynteractive.com
Email: [email protected]