Skip to main content

Automated AI media creation with MagicHour AI and GPT-4 prompt optimization

Workflow preview

Workflow preview
100%
Automated AI media creation with MagicHour AI and GPT-4 prompt optimization preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow automates AI powered image and video generation using MagicHour.ai's API, enhanced by GPT 4.1 for intelligent prompt optimization. It processes webhook requests, refines prompts using...

Best for

  • Content Creation automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, @n8n/n8n-nodes-langchain.openai, n8n-nodes-base.respondtowebhook, n8n-nodes-base.if, n8n-nodes-base.wait, n8n-nodes-base.httprequest, n8n-nodes-base.stickynote, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by inderjeet Bhambra.

Original n8n.io source

1.1 Workflow description

Title
Automated AI media creation with MagicHour AI and GPT-4 prompt optimization
Workflow name
Automated AI media creation with MagicHour AI and GPT-4 prompt optimization

This workflow automates AI-powered image and video generation using MagicHour.ai's API, enhanced by GPT-4.1 for intelligent prompt optimization. It processes webhook requests, refines prompts using AI, generates media content, and returns the final output.

Who's it for

Content creators, marketers, social media managers, and developers who need automated AI media generation at scale. Perfect for teams building applications that require on-demand image or video creation without manual intervention.

How it works

The workflow receives a webhook POST request containing generation parameters (type, orientation, style, duration). GPT-4.1 analyzes and optimizes the user's prompt based on the request type (image or video), then sends it to MagicHour.ai's API. The workflow monitors the generation status through polling loops, downloads the completed media, and returns it via webhook response. Error handling ensures failed requests are captured and reported.

Requirements

  • n8n instance (self-hosted or cloud)
  • MagicHour.ai account with API access (Bearer token)
  • OpenAI API account for GPT-4.1 access
  • Basic understanding of webhooks and JSON

How to set up

Configure credentials:

  • Add MagicHour.ai Bearer token in HTTP Request nodes (ai-image-generator, text-to-video, Get Image Details, Get Video Details)
  • Add OpenAI API credentials in both Generate Image Prompt and Generate video Prompt nodes

Activate the workflow:

  • Enable the workflow to activate the webhook endpoint
  • Copy the webhook URL from the Webhook trigger node

Test the workflow:

Download the n8n-magichour HTML tester Click here to download

For image generation, send a POST request with this structure:

{
  "action": "generate",
  "type": "image",
  "parameters": {
    "name": "My Image",
    "image_count": 1,
    "orientation": "landscape",
    "style": {
      "prompt": "A serene mountain landscape at sunset",
      "tool": "realistic"
    }
  }
}

For video generation, use:

{
  "action": "generate",
  "type": "video",
  "parameters": {
    "name": "My Video",
    "end_seconds": 5,
    "orientation": "landscape",
    "resolution": "1080p",
    "style": {
      "prompt": "A dog running through a field"
    }
  }
}

How to customize the workflow

Adjust AI prompt optimization: Modify the system prompts in Generate Image Prompt or Generate video Prompt nodes to change how GPT-4.1 refines user inputs. Current prompts enforce strict character limits and avoid unauthorized content.

Change polling intervals: Modify the Wait nodes to adjust how frequently the workflow checks generation status (useful for longer video renders).

Modify response format: Update the Respond to Webhook node to customize the output structure sent back to the caller.

Add multiple output formats: Extend Download Image/Video nodes to save files to cloud storage (Google Drive, S3) instead of just returning via webhook.

Implement queue management: Add a database node before MagicHour.ai calls to queue requests and prevent API rate limiting.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 2 - Generate Image Prompt

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 3 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 4 - If

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 5 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 6 - Get Image Details

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 7 - If1

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 8 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - If2

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 10 - Download Image

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 11 - Generate video Prompt

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 12 - Edit Fields2

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Get Data from Webhook

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 14 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - If3

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 18 - Get Error Details

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - ai-image-generator

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 21 - text-to-video

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 22 - Wait1

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 23 - Get Video Details

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 24 - If4

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Showing the first 24 of 25 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Automated AI media creation with MagicHour AI and GPT-4 prompt optimization
Complexity advanced
Nodes 25
Categories Content Creation, Multimodal AI
Author inderjeet Bhambra
Published 17 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9853/9853.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automated AI media creation with MagicHour AI and GPT-4 prompt optimization do?

This workflow automates AI powered image and video generation using MagicHour.ai's API, enhanced by GPT 4.1 for intelligent prompt optimization. It processes webhook requests, refines prompts using...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Content Creation, Multimodal AI use case.