Skip to main content
POST
/
v1
/
ai-talking-photo
Python
from magic_hour import Client
from os import getenv

client = Client(token=getenv("API_TOKEN"))
res = client.v1.ai_talking_photo.generate(
    assets={
        "audio_file_path": "/path/to/1234.mp3",
        "image_file_path": "/path/to/1234.png",
    },
    end_seconds=15.0,
    start_seconds=0.0,
    name="Talking Photo image",
    wait_for_completion=True,
    download_outputs=True,
    download_directory="."
)
{
  "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

Provide the assets for creating a talking photo

start_seconds
number<float>
required

The start time of the input audio in seconds. The maximum duration allowed is 60 seconds.

Required range: x >= 0
Example:

0

end_seconds
number<float>
required

The end time of the input audio in seconds. The maximum duration allowed is 60 seconds.

Required range: x >= 0.1
Example:

15

assets
object
required

Provide the assets for creating a talking photo

name
string
default:Talking Photo - dateTime

Give your image a custom name for easy identification.

Example:

"My Talking Photo image"

style
object

Attributes used to dictate the style of the output

max_resolution
integer

Constrains the larger dimension (height or width) of the output video. Allows you to set a lower resolution than your plan's maximum if desired. The value is capped by your plan's max resolution.

Example:

1024

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