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

client = Client(token=getenv("API_TOKEN"))
res = client.v1.image_to_video.generate(
    assets={"image_file_path": "/path/to/1234.png"},
    end_seconds=5.0,
    name="Image To Video video",
    resolution="720p",
    wait_for_completion=True,
    download_outputs=True,
    download_directory="outputs"
)
{
  "id": "cuid-example",
  "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<float>
required

The total duration of the output video in seconds.

Supported durations depend on the chosen model:

  • Default: 5-60 seconds (either 5 or 10 for 480p).
  • Seedance: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
  • Kling 2.5 Audio: 5, 10
  • Sora 2: 4, 8, 12, 24, 36, 48, 60
  • Veo 3.1 Audio: 4, 6, 8, 16, 24, 32, 40, 48, 56
  • Veo 3.1: 4, 6, 8, 16, 24, 32, 40, 48, 56
  • Kling 1.6: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
Required range: 2 <= x <= 60
Example:

5

assets
object
required

Provide the assets for image-to-video. Sora 2 only supports images with an aspect ratio of 9:16 or 16:9.

name
string
default:Image To Video - dateTime

Give your video a custom name for easy identification.

Example:

"My Image To Video video"

model
enum<string>
default:default

The AI model to use for video generation.

  • default: Our recommended model for general use (Kling 2.5 Audio). Note: For backward compatibility, if you use default and end_seconds > 10, we'll fall back to Kling 1.6.
  • seedance: Great for fast iteration and start/end frame
  • kling-2.5-audio: Great for motion, action, and camera control
  • sora-2: Great for story-telling, dialogue & creativity
  • veo3.1-audio: Great for dialogue + SFX generated natively
  • veo3.1: Great for realism, polish, & prompt adherence
  • kling-1.6: Great for dependable clips with smooth motion
Available options:
default,
seedance,
kling-2.5-audio,
veo3.1,
veo3.1-audio,
sora-2,
kling-1.6
Example:

"kling-2.5-audio"

resolution
enum<string>

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

  • Default: Supports 480p, 720p, and 1080p.
  • Seedance: Supports 480p, 720p, 1080p.
  • Kling 2.5 Audio: Supports 720p, 1080p.
  • Sora 2: Supports 720p.
  • Veo 3.1 Audio: Supports 720p, 1080p.
  • Veo 3.1: Supports 720p, 1080p.
  • Kling 1.6: Supports 720p, 1080p.
Available options:
480p,
720p,
1080p
Example:

"720p"

style
object

Attributed used to dictate the style of the output

Response

Success

Success

id
string
required

Unique ID of the video. Use it with the Get video Project API to fetch status and downloads.

Example:

"cuid-example"

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