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.
Copy
from magic_hour import Clientimport timeimport osimport urllib.requestclient = Client(token="YOUR_API_KEY") # change to your API keyresult = 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!