Generate with Motion 2.0 Using Generated Images

Example for generating a video from a generated image

Follow this recipe to generate video using text:

The guide will recreate the following functionality in the Web UI via API.

Sample Request

curl --request POST \
     --url https://cloud.leonardo.ai/api/rest/v1/generations-image-to-video \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <YOUR_API_KEY>' \
     --header 'content-type: application/json' \
     --data '
{
  "imageType": "GENERATED",
  "isPublic": false,
  "resolution": "RESOLUTION_480",
  "imageId": "8815cca4-4cf7-4f21-aec4-00f8977f61d5",
  "prompt": "A cat roaring like a tiger",
  "frameInterpolation": true,
  "promptEnhance": true
}

πŸ“˜

Generating in 720p Resolution

To set resolution to 720p, apply RESOLUTION_720to the resolutionparameter.

πŸ“˜

Smooth Video

Applying frameInterpolation:trueis the same as applying Smooth Video from the Advanced Settings tab.

πŸ“˜

Image IDs of Generated Images

To get an image ID, first you need to generate an image using the Create a Generation of Images endpoint. You will get a Generation ID.

Then, use the generation ID as query parameter to the Get a Single Generation endpoint. You will get an array of images that looks like:

{
  "generations_by_pk": {
    "generated_images": [
      {
        "url": "https://cdn.leonardo.ai/users/ef8b8386-94f7-48d1-b10e-e87fd4dee6e6/generations/474e2e3a-4334-4c1d-bcbd-c73e4b86ba85/Leonardo_Lightning_XL_A_majestic_cat_in_the_snow_0.jpg",
        "nsfw": false,
        "id": "482a8f60-75cc-4911-94cf-10d624a62c76",
        "likeCount": 0,
        "motionMP4URL": null,
        "generated_image_variation_generics": []
      },
      {

In this case, the image ID is 482a8f60-75cc-4911-94cf-10d624a62c76.

Cost

The Image-to-Video endpoint costs 200 API Credits per 480p video, and 300 API Credits per 720p video.