Skip to main content
POST
/
v1
/
text-to-video
Python
from magic_hour import Client
from os import getenv

client = Client(token=getenv("API_TOKEN"))
res = client.v1.text_to_video.generate(
    end_seconds=5.0,
    orientation="landscape",
    style={"prompt": "a dog running"},
    name="Text To Video video",
    resolution="720p",
    wait_for_completion=True,
    download_outputs=True,
    download_directory="outputs"
)
{
  "id": "cuid-example",
  "estimated_frame_cost": 450,
  "credits_charged": 450
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <api_key>, where <api_key> is your API key. To get your API key, go to Developer Hub and click "Create new API Key".

Body

application/json

Body

end_seconds
number
required

The total duration of the output video in seconds.

The value must be greater than or equal to 5 seconds and less than or equal to 60 seconds.

Note: For 480p resolution, the value must be either 5 or 10.

Required range: 5 <= x <= 60
Example:

5

orientation
enum<string>
required

Determines the orientation of the output video

Available options:
portrait,
landscape,
square
Example:

"landscape"

style
object
required
name
string
default:Text To Video - dateTime

The name of video. This value is mainly used for your own identification of the video.

Example:

"Text To Video video"

resolution
enum<string>

Controls the output video resolution. Defaults to 720p if not specified.

480p and 720p are available on Creator, Pro, or Business tiers. However, 1080p require Pro or Business tier.

Options:

  • 480p - Supports only 5 or 10 second videos. Output: 24fps. Cost: 120 credits per 5 seconds.
  • 720p - Supports videos between 5-60 seconds. Output: 30fps. Cost: 300 credits per 5 seconds.
  • 1080p - Supports videos between 5-60 seconds. Output: 30fps. Cost: 600 credits per 5 seconds.
Available options:
480p,
720p,
1080p
Example:

"720p"

Response

Success

id
string
required

Unique ID of the video. This value can be used in the get video project API to fetch additional details such as status

Example:

"cuid-example"

estimated_frame_cost
integer
required
deprecated

Deprecated: Previously represented the number of frames (original name of our credit system) used for video generation. Use 'credits_charged' instead.

The amount of frames used to generate the video. If the status is not 'complete', the cost is an estimate and will be adjusted when the video completes.

Example:

450

credits_charged
integer
required

The amount of credits deducted from your account to generate the video. If the status is not 'complete', this value is an estimate and may be adjusted upon completion based on the actual FPS of the output video.

If video generation fails, credits will be refunded, and this field will be updated to include the refund.

Example:

450

I