Create your account

  1. Visit the Magic Hour Developer Hub (create an account if you don’t have one).
  2. Click Create API Key. Create API Key
  3. Add a descriptive name. Then click Create key. Create API Key Modal
  4. Copy the API key and save it. Copy API Key
The API key can only be viewed on creation.

Install SDK (Optional)

Skip to the next step if you’re not planning on using our SDKs.
pip install magic_hour

Generate an image or a video

You can install this documentation as an MCP server to get contextual help while integrating Magic Hour APIs into your application. Learn more
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!