Bulk AI Video Generation with Freepik Minimax Hailuo & Google Suite Integration

Go to Workflow
0 views
Built by Robert Breen Robert Breen
Created on June 05, 2026

Description

This n8n workflow automates bulk AI video generation using Freepik's Image-to-Video API powered by Minimax Hailuo-02-768p. It reads video prompts from a Google Sheet, generates multiple variations of each video using Freepik's AI, handles asynchronous video processing with intelligent polling, and automatically uploads completed videos to Google Drive with organized file names. This is perfect for content creators, marketers, or video producers who need to generate multiple AI videos in bulk and store them systematically.

Key Features:
Bulk video generation from Google Sheets prompts
Multiple variations per prompt (configurable duplicates)
Asynchronous processing with smart status polling
Automatic retry mechanism for processing delays
Direct upload to Google Drive with organized naming
Freepik Minimax Hailuo-02 AI-powered video generation (768p quality)
Intelligent wait/retry system for video rendering

Step-by-Step Implementation Guide

Prerequisites
Before setting up this workflow, you'll need:

n8n instance (cloud or self-hosted)
Freepik API account with Video Generation access
Google account with access to Sheets and Drive
Google Sheet with your video 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 with Video Generation permissions
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 video generation prompts)
Column B: Name (identifier for file naming)
Example data:
| Prompt | Name |
|-------------------------------------------------|---------------|
| A butterfly landing on a flower in slow motion | butterfly-01 |
| Ocean waves crashing on rocky coastline | ocean-waves |
| Time-lapse of clouds moving across blue sky | clouds-timelapse |
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 videos
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:

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"

Duplicate Rows2 (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 Over Items (Split in Batches)
Processes items in batches to manage API rate limits
Options**: Keep default settings
Reset**: false

Create Video (HTTP Request)
Method**: POST
URL**: https://api.freepik.com/v1/ai/image-to-video/minimax-hailuo-02-768p
Authentication**: Generic → HTTP Header Auth
Credentials**: Select your "Header Auth account"
Send Body**: true
Body Parameters**:
Name: prompt
Value: ={{ $json.Prompt }}

Get Video URL (HTTP Request)
Method**: GET
URL**: https://api.freepik.com/v1/ai/image-to-video/minimax-hailuo-02-768p/{{ $json.data.task_id }}
Authentication**: Generic → HTTP Header Auth
Credentials**: Select your "Header Auth account"
Timeout**: 120000 (2 minutes)
Purpose**: Polls the API for video completion status

Switch (Switch Node)
Purpose**: Routes workflow based on video generation status
Conditions**:
Completed: {{ $json.data.status }} equals COMPLETED
Failed: {{ $json.data.status }} equals FAILED
Created: {{ $json.data.status }} equals CREATED
In Progress: {{ $json.data.status }} equals IN_PROGRESS

Wait (Wait Node)
Amount**: 30 seconds
Purpose**: Waits before re-checking video status
Webhook ID**: Auto-generated for resume functionality

Download Video as Base64 (HTTP Request)
Method**: GET
URL**: ={{ $json.data.generated[0] }}
Purpose**: Downloads completed video file

Upload to Google Drive1 (Google Drive)
Operation**: Upload
Name**: =video - {{ $('Get prompt from google sheet').item.json.Name }} - {{ $('Duplicate Rows2').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 "Duplicate Rows2" code to create more variations
Update File Naming: Change the naming pattern in the Google Drive upload node
Adjust Wait Time: Modify the Wait node duration based on typical processing times
Add Video Parameters: Enhance the Create Video request with additional Freepik parameters

Step 7: Test the Workflow

Ensure your Google Sheet has test data
Click Execute Workflow on the manual trigger (if present)
Monitor the execution flow - note that video generation takes time
Watch the Switch node handle different status responses
Verify videos are uploaded to Google Drive when completed

Step 8: Production Deployment

Set up error handling for API failures and timeouts
Configure appropriate batch sizes based on your Freepik API limits
Add logging for successful uploads and failed generations
Consider webhook triggers for automated execution
Set up monitoring for stuck or failed video generations

Freepik Video API Details

Video Generation Process:
Submit Request: Send prompt to generate video
Get Task ID: Receive task_id for tracking
Poll Status: Check generation status periodically
Download: Retrieve completed video URL

Status Types:
CREATED: Video generation task created
IN_PROGRESS: Video is being generated
COMPLETED: Video ready for download
FAILED: Generation failed

Model Specifications:
Model**: minimax-hailuo-02-768p
Resolution**: 768p
Duration**: Typically 5-10 seconds
Format**: MP4

Example Enhanced Parameters:
{
"prompt": "{{ $json.Prompt }}",
"duration": 5,
"aspect_ratio": "16:9",
"fps": 24
}

Workflow Flow Summary

Start → Read prompts from Google Sheets
Duplicate → Create multiple runs for variations
Loop → Process items in batches
Generate → Submit video generation request to Freepik
Poll → Check video generation status
Switch → Route based on status:
Completed → Download video
Processing/Created → Wait and retry
Failed → Handle error
Download → Retrieve completed video file
Upload → Save to Google Drive with organized naming
Continue → Process next batch

Troubleshooting Tips

Common Issues:
Long Processing Times**: Video generation can take 2-5 minutes per video
Timeout Errors**: Increase timeout in "Get Video URL" node
Rate Limits**: Reduce batch size and add longer waits between requests
Failed Generations**: Check prompt complexity and API limits
Upload Failures**: Verify Google Drive folder permissions

Error Handling:
Add Try/Catch nodes around API calls
Implement exponential backoff for retries
Log failed generations to Google Sheets
Set up email notifications for critical failures

Performance Optimization:
Adjust wait times based on typical generation duration
Use smaller batch sizes for more reliable processing
Monitor API usage and costs in Freepik dashboard

Cost Considerations

Freepik API:
Video generation typically costs more than image generation
Check your plan's video generation limits
Monitor usage through Freepik dashboard
Consider upgrading for higher volume needs

Processing Time:
Each video can take 2-5 minutes to generate
Plan workflow execution time accordingly
Consider running during off-peak hours for large batches

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.

Nodes Used (4)

Code
n8n-nodes-base.code
Google Drive
n8n-nodes-base.googleDrive
Google Sheets
n8n-nodes-base.googleSheets
HTTP Request
n8n-nodes-base.httpRequest