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
- 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
- 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
- Polling: Periodically check job status using the job ID
- Webhooks: Receive automatic notifications when job completes
- Track progress through status updates
- Retrieve the generated file using a secure download URL
- URLs are temporary (expire after 24 hours)
- Save the result to your storage
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:
- 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:
- 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+.- 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
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
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
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 thegenerate() function to prototype:
Step 2: Add Error Handling
Handle failures gracefully:Step 3: Move to Production
Switch tocreate() + 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
Typical processing times based on actual usage data (median times):| Content Type | Median Processing Time | Recommended Polling Interval | Example Tools |
|---|---|---|---|
| Fast Image | 2-15 seconds | Every 2-3 seconds | Face Editor, Photo Colorizer, Face Swap Photo, AI Image Generator, Background Remover, Clothes Changer, AI Meme, QR Code, AI Headshot |
| Medium Image | 15-30 seconds | Every 3-5 seconds | Photo Editor, AI Image Editor, AI Selfie, Image Upscaler, AI GIF |
| Simple Video | 30 seconds - 2 minutes | Every 5 seconds | Text to Video (v1), Image to Video (v1), Auto Subtitle Generator |
| Standard Video | 2-4 minutes | Every 5-10 seconds | Face Swap Video (v2), Lip Sync, Talking Photo (v3), Image to Video, Animation, Text to Video (v2) |
| Complex Video | 8-11 minutes | Every 10-15 seconds | Video to Video (v2, v3), Talking Photo (v2) |
| Long Video | 60+ minutes | Every 30 seconds | Video to Video (v1) — very long videos |
| Audio | 3-12 seconds | Every 2-3 seconds | Voice Changer (3s), Voice Generator (10s), Voice Cloner (12s) |
Processing times are median values and can vary based on:
- Video/image length and resolution
- Current server load
- Complexity of the requested operation
- Input file size and format
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 [email protected]