Skip to main content

What is the Magic Hour API?

Magic Hour API provides programmatic access to AI-powered video, image, and audio generation tools. Instead of using the web interface manually, you can build these capabilities directly into your applications, workflows, and products.

Why Use the API?

The API enables you to:
  • Build AI features into your products - Embed video and image generation in your applications
  • Automate content workflows - Process large batches of media without manual intervention
  • Scale your operations - Handle high-volume generation with enterprise-grade infrastructure
  • Integrate with existing systems - Connect AI generation to your current tech stack
  • Create custom experiences - Build unique user interfaces and workflows on top of our AI models
Example use cases:
  • Social media apps that auto-generate content for users
  • Marketing platforms with automated video creation
  • E-commerce sites with AI product visualization
  • Gaming platforms with dynamic avatar generation
  • Education apps with custom learning materials

API vs Web App

Understanding the relationship between the API and web application: 🌐 Web App (magichour.ai):
  • Full suite of 100+ AI tools and features
  • User-friendly interface with templates and presets
  • New features launch here first
  • Perfect for creators and individual use
⚡ API (docs.magichour.ai):
  • Core popular tools available programmatically
  • Built for developers and applications
  • Same underlying AI models as web app
  • Features added after web app validation
Shared Dashboard: All API-generated content automatically appears in your magichour.ai dashboard, where you can view, manage, and share your creations.

How the API Works

Magic Hour APIs use an asynchronous processing model. Unlike typical REST APIs that return results immediately, AI generation takes time, so the workflow follows these steps:

The Three Steps

1. Submit (Create)
  • Send a request to create a video, image, or audio
  • Receive a job ID immediately (no waiting)
  • Job enters the processing queue
2. Monitor (Poll or Webhook)
  • Polling: Periodically check job status using the job ID
  • Webhooks: Receive automatic notifications when job completes
  • Track progress through status updates
3. Download
  • Retrieve the generated file using a secure download URL
  • URLs are temporary (expire after 24 hours)
  • Save the result to your storage
Asynchronous Processing: Jobs don’t complete instantly. Always implement status monitoring (polling or webhooks) before attempting to download results.

Create vs Generate

The SDKs provide two ways to interact with the API:

create() - Full Control

The create() function gives you complete control over the workflow:
Best for:
  • Fine-grained control over polling intervals
  • Custom status monitoring logic
  • Integration with existing job management systems
  • Advanced error handling and retry logic

generate() - Simplified Workflow

The generate() function handles everything automatically:
Best for:
  • Quick integrations and prototyping
  • Simple use cases with single job processing
  • Applications that can wait synchronously
  • Minimal boilerplate code
SDK Requirement: The generate() function requires Python SDK v0.36.0+ or Node SDK v0.37.0+.
When to use each:
  • Use create() for production apps with webhook integration, concurrent job processing, or custom monitoring needs
  • Use generate() for scripts, simple integrations, or when you want minimal code

Integration Approaches

Approach 1: Synchronous (Simple)

Good for:
  • Scripts and command-line tools
  • Single job processing
  • Testing and development
Pros: Simple code, easy to understand
Cons: Application blocks while waiting, not scalable

Approach 2: Polling (Moderate)

Good for:
  • Background job processing
  • Applications that can handle wait times
  • Simple queue-based systems
Pros: More control, works without webhooks
Cons: Requires periodic polling, uses resources while waiting

Approach 3: Webhooks (Production)

Good for:
  • Production applications
  • High-volume processing
  • Real-time user notifications
  • Efficient resource usage
Pros: Real-time notifications, efficient, scalable
Cons: Requires webhook endpoint setup

Webhook Integration Guide

Complete guide to setting up webhooks for production use

Development Workflow

Step 1: Start Simple

Begin with the generate() function to prototype:

Step 2: Add Error Handling

Handle failures gracefully:

Step 3: Move to Production

Switch to create() + webhooks for production:

Testing Without Credits

Use the mock server to develop and test without consuming credits:
Mock Server: Returns realistic sample data without processing jobs or charging credits. Perfect for development and testing.

Processing Times

Processing time varies significantly by endpoint. See customer-observed median (p50) end-to-end times, including queueing, before setting polling intervals and timeouts.

View processing times by endpoint

Compare rolling 30-day median times for video, image, and audio APIs.
Processing times are not an SLA. They vary with input duration and resolution, current queue load, model complexity, file size, and format. Always implement timeout handling.

Next Steps

Choose your path based on your needs:

Quick Start

Make your first API call in 3 minutes

Complete Integration Guide

Production-ready integration patterns

Webhook Setup

Real-time notifications for production apps

API Reference

Complete endpoint documentation

Questions? Join our Discord community or email support@magichour.ai