Magic Hour is an AI video and image generation platform. You submit a job, we render it, and you download the result. This guide gets you to your first output in a few minutes. What you’ll do:
  1. Create an API key
  2. Install an SDK (optional)
  3. Generate your first asset

1. Create your account

  1. Visit the Magic Hour Developer Hub and sign in.
  2. Click Create API Key. Create API Key
  3. Name the key, then click Create key. Create API Key Modal
  4. Copy the API key and save it. Copy API Key

2. Install SDK (Optional)

SDKs reduce boilerplate. Skip to the Step 3 if you’re not planning on using our SDKs.
pip install magic_hour

3. Generate your first asset

The .generate function is only available in the following SDKs:
  • Python SDK v0.36.0 or later.
  • Node SDK v0.37.0 or later.
We are working on adding it to the other SDKs. If you need it in an SDK that is not listed above, please contact us.
from magic_hour import Client
import time
import os
import urllib.request

client = Client(token="YOUR_API_KEY") # change to your API key

result = client.v1.ai_image_generator.generate(
    image_count=1,
    orientation="landscape",
    style={
        "prompt": "Epic anime art of wizard casting a cosmic spell in the sky that says 'Magic Hour'"
    },
    wait_for_completion=True, # wait for the render to complete
    download_outputs=True, # download the outputs to local disk
    download_directory="outputs", # save the outputs to the "outputs" directory
)

print(f"created image with id {result.id}, spent {result.credits_charged} credits. Outputs are saved at {result.downloaded_paths}")
🎉 Congratulations! You have successfully created an image and a video on Magic Hour!

Next Steps

  • Explore the API Reference: Learn how to generate and edit videos and images programmatically. API Reference →
  • Use the Web App: Try more tools and experiment interactively at magichour.ai.
  • Handle Results at Scale: Set up webhooks to process results async and avoid polling.
  • Join the Community: Get help, share projects, and see what others are building in Discord.
  • Stay Updated: Check out the Changelog for new products and API updates.
Prefer fast iteration inside your editor? Install this documentation as an MCP server to get contextual help while integrating the Magic Hour API. Learn more.