Skip to main content
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.

Skip local setup — open the Google Colab cookbook

Try every API from your browser with only an API key.
What you’ll accomplish:
  1. Create an API key - Get credentials to authenticate with our API
  2. Set up your development environment - Install SDK and create project files
  3. Generate your first output - Make an API call and download the result
Credit Cost: Pick the example that matches your goal. The image tab costs about 5 credits; the face swap video tab costs about 200 credits for the sample clip. New accounts get 400 free credits plus 100 daily credits if you claim them in the web app.

1. Create your API key

Why: API keys authenticate your requests and track your usage.
  1. Open the API Keys section of the Developer Hub and sign in.
  2. Click Create key, give it a name (e.g., “My First Project”), and create it.
  3. Copy the API key immediately — you won’t be able to see it again.

Need the full walkthrough?

See screenshots, permissions, and key-management guidance in the Authentication guide.
Store your API key as an environment variable:
Never commit API keys to version control. Always use environment variables or secure credential management.

2. Set up your development environment

Why: SDKs handle authentication, polling, and file downloads automatically, reducing boilerplate code.

Create your project directory

Install the SDK

Want to test your integration without spending credits? The SDKs include a mock server that returns sample responses instantly.

3. Generate your first output

What we’re doing: Submit a generation job, wait for Magic Hour to render it, then download the result. Choose the example that matches what you want to build:

Copy the code and run it

SDK version required for generate(): Use Python SDK v0.36.0+ or Node SDK v0.37.0+. Older versions do not include this helper. Go and Rust use the manual create/poll/download pattern shown below.
  1. Choose an example tab, then copy the code from your preferred language tab below.
Create an image from a text prompt. This is the cheapest way to verify your setup end to end.Why these parameters:
  • image_count: 1 - Generate one image (costs 5 credits)
  • aspect_ratio: "16:9" - Widescreen (landscape) output; also supports 1:1 and 9:16
  • resolution: "1k" - Request an explicit supported resolution instead of deprecated auto
  • wait_for_completion: true - SDK polls until done
  • download_outputs: true - Automatically download to local disk
  • download_directory: "." - Save to the current directory
Expected output for Python and Node.js:
Expected output for Go, Rust, and cURL:
  1. Paste it into your file (main.py, main.js, main.go, etc.)
  2. Run the code:

Troubleshooting

Common Issues

FileNotFoundError when using a custom download_directory The SDK saves outputs into download_directory but does not create the folder for you. The default (".") always works. If you point it at a folder that doesn’t exist yet (e.g. "outputs"), create it first:
Error: MAGIC_HOUR_API_KEY environment variable not set Solution: Set your API key as an environment variable. See Environment Variables in the Authentication guide for platform-specific setup steps.

HTTP Error Codes

If you encounter HTTP errors, here’s what they mean: For persistent errors: Contact support@magichour.ai with your project ID.
🎉 Congratulations! You have successfully created your first Magic Hour project.

Next Steps

  • Explore the API Reference: Learn how to generate and edit videos and images programmatically. API Reference →
  • Explore Face Swap Video: See parameter details, pricing, and production patterns in the Face Swap Video guide.
  • Try All APIs in Google Colab: Run our complete cookbook with sample code for all 22 APIs. Just add your API key and start experimenting.
  • 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.