Generate AI Images in Bulk with Freepik, Google Sheets & Drive
Go to WorkflowDescription
This n8n workflow automates bulk AI image generation using Freepik's Text-to-Image API. It reads prompts from a Google Sheet, generates multiple variations of each image using Freepik's AI, and automatically uploads the results to Google Drive with organized file names. This is perfect for content creators, marketers, or designers who need to generate multiple AI images in bulk and store them systematically.
Key Features:
Bulk image generation from Google Sheets prompts
Multiple variations per prompt (configurable duplicates)
Automatic file naming and organization
Direct upload to Google Drive
Batch processing for efficient API usage
Freepik AI-powered image generation
Step-by-Step Implementation Guide
Prerequisites
Before setting up this workflow, you'll need:
n8n instance (cloud or self-hosted)
Freepik API account with Text-to-Image access
Google account with access to Sheets and Drive
Google Sheet with your prompts
Step 1: Set Up Freepik API Credentials
Go to Freepik API Developer Portal
Create an account or sign in
Navigate to your API dashboard
Generate an API key for Text-to-Image service
Copy the API key and save it securely
In n8n, go to Credentials → Add Credential → HTTP Header Auth
Configure as follows:
Name: "Header Auth account"
Header Name: x-freepik-api-key
Header Value: Your Freepik API key
Step 2: Set Up Google Credentials
Google Sheets Access:
Go to Google Cloud Console
Create a new project or select existing one
Enable Google Sheets API
Create OAuth2 credentials
In n8n, go to Credentials → Add Credential → Google Sheets OAuth2 API
Enter your OAuth2 credentials and authorize with spreadsheets.readonly scope
Google Drive Access:
In Google Cloud Console, enable Google Drive API
In n8n, go to Credentials → Add Credential → Google Drive OAuth2 API
Enter your OAuth2 credentials and authorize
Step 3: Create Your Google Sheet
Create a new Google Sheet: sheets.google.com
Set up your sheet with these columns:
Column A: Prompt (your image generation prompts)
Column B: Name (identifier for file naming)
Example data:
| Prompt | Name |
|-------------------------------------------|-------------|
| A serene mountain landscape at sunrise | mountain-01 |
| Modern office space with natural lighting | office-02 |
| Cozy coffee shop interior | cafe-03 |
Copy the Sheet ID from the URL (the long string between /d/ and /edit)
Step 4: Set Up Google Drive Folder
Create a folder in Google Drive for your generated images
Copy the Folder ID from the URL when viewing the folder
Note: The workflow is configured to use a folder called "n8n workflows"
Step 5: Import and Configure the Workflow
Copy the provided workflow JSON
In n8n, click Import from File or Import from Clipboard
Paste the workflow JSON
Configure each node as detailed below:
Node Configuration Details:
Start Workflow (Manual Trigger)
No configuration needed
Used to manually start the workflow
Get Prompt from Google Sheet (Google Sheets)
Document ID**: Your Google Sheet ID (from Step 3)
Sheet Name**: Sheet1 (or your sheet name)
Operation**: Read
Credentials**: Select your "Google Sheets account"
Double Output (Code Node)
Purpose**: Creates multiple variations of each prompt
JavaScript Code**:
const original = items[0].json;
return [
{ json: { ...original, run: 1 } },
{ json: { ...original, run: 2 } },
];
Customization**: Add more runs for additional variations
Loop (Split in Batches)
Processes items in batches to manage API rate limits
Options**: Keep default settings
Reset**: false
Create Image (HTTP Request)
Method**: POST
URL**: https://api.freepik.com/v1/ai/text-to-image
Authentication**: Generic → HTTP Header Auth
Credentials**: Select your "Header Auth account"
Send Body**: true
Body Parameters**:
Name: prompt
Value: ={{ $json.Prompt }}
Split Responses (Split Out)
Field to Split Out**: data
Purpose**: Separates multiple images from API response
Convert to File (Convert to File)
Operation**: toBinary
Source Property**: base64
Purpose**: Converts base64 image data to file format
Upload Image to Google Drive (Google Drive)
Operation**: Upload
Name**: =Image - {{ $('Get Prompt from Google Sheet').item.json.Name }} - {{ $('Double Output').item.json.run }}
Drive ID**: My Drive
Folder ID**: Your Google Drive folder ID (from Step 4)
Credentials**: Select your "Google Drive account"
Step 6: Customize for Your Use Case
Modify Duplicate Count: Edit the "Double Output" code to create more variations
Update File Naming: Change the naming pattern in the Google Drive upload node
Adjust Batch Size: Modify the Loop node settings for your API limits
Add Image Parameters: Enhance the HTTP request with additional Freepik parameters (size, style, etc.)
Step 7: Test the Workflow
Ensure your Google Sheet has test data
Click Execute Workflow on the manual trigger
Monitor the execution flow
Check that images are generated and uploaded to Google Drive
Verify file names match your expected pattern
Step 8: Production Deployment
Set up error handling for API failures
Configure appropriate batch sizes based on your Freepik API limits
Add logging for successful uploads
Consider webhook triggers for automated execution
Set up monitoring for failed executions
Freepik API Parameters
Basic Parameters:
prompt: Your text description (required)
negative_prompt: What to avoid in the image
guidance_scale: How closely to follow the prompt (1-20)
num_inference_steps: Quality vs speed trade-off (20-100)
seed: For reproducible results
Example Enhanced Body:
{
"prompt": "{{ $json.Prompt }}",
"negative_prompt": "blurry, low quality",
"guidance_scale": 7.5,
"num_inference_steps": 50,
"num_images": 1
}
Workflow Flow Summary
Start → Manual trigger initiates the workflow
Read Sheet → Gets prompts and names from Google Sheets
Duplicate → Creates multiple runs for variations
Loop → Processes items in batches
Generate → Freepik API creates images from prompts
Split → Separates multiple images from response
Convert → Transforms base64 to binary file format
Upload → Saves images to Google Drive with organized names
Complete → Returns to loop for next batch
Contact Information
Robert A Ynteractive
For support, customization, or questions about this workflow:
📧 Email: [email protected]
🌐 Website: https://ynteractive.com/
💼 LinkedIn: https://www.linkedin.com/in/robert-breen-29429625/
Need help implementing this workflow or want custom automation solutions? Get in touch for professional n8n consulting and workflow development services.