Magic Hour’s API allows you to upload various types of assets needed for video generation. This guide explains how to manage these assets effectively.

Supported asset types

The follow file extensions are supported by our APIs:

Video

mp4, m4v, mov, webm

Audio

mp3, mpeg, wav, aac, aiff, flac

Image

png, jpg, jpeg, webp, avif, jp2, tiff, bmp
gif extension is only supported by face swap API’s video_file_path field.

Available options for assets

You have two options when it come to using input files:
  • Pass a URL as the input (simplest)
  • Upload to our storage (do not require hosting files yourself)

Passing a file URL

This is the simplest method if you have the files hosted somewhere. When calling our APIs, you can simply pass the URL as the video_file_path, image_file_path, or audio_file_path. For Example
{
  "assets": {
    "video_file_file": "https://cdn.yourwebsite.com/video.mp4"
  }
}
The URL can be an authenticated url, as long as we can validate the file extension is supported.

Upload to Magic Hour storage

To upload assets for video generation, you’ll need to follow these steps:
  1. Request upload URLs for your assets, you need to specify the file extension and the type of the file.
  2. Upload the files to the provided URLs by sending a PUT request.
  3. Use the file_path value from the original upload url response in your API calls.
The following code samples provide a full example of how to upload a video file to Magic Hour storage.
The upload file 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 requests

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

file_path = client.v1.files.upload_file("/path/to/your/image.jpg")

# now you can use `file_path` in your API calls for
# `video_file_path`, `image_file_path`, or `audio_file_path

Uploaded file lifecycle

Uploaded files are automatically cleaned up after 7 days.
You can reference the value in .items.[].file_path in multiple API calls before the file is cleaned up.
If you have use cases where having more permanent storage is required, please reach out to our team at support@magichour.ai.