Sora 2 Pro

This guide shows how to generate videos using the Sora 2 Pro model via the Leonardo.AI REST API.

Sample Request

curl --request POST \
     --url https://cloud.leonardo.ai/api/rest/v2/generations \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <YOUR_API_KEY>' \
     --header 'content-type: application/json' \
     --data '
{
  "model": "sora-2-pro",
  "public": false,
  "parameters": {
    "prompt": "A koala and a cat playing together in a sunlit meadow",
    "quantity": 1,
    "width": 1280,
    "height": 720,
    "mode": "RESOLUTION_720",
    "duration": 4
  }
}
'

API Request Endpoint, Headers, Parameters

Endpoint

https://cloud.leonardo.ai/api/rest/v2/generations

Headers

--header "accept: application/json" \
--header "authorization: Bearer <YOUR_API_KEY>" \
--header "content-type: application/json"

Body Parameters

ParameterTypeDefinition
durationintegerOptional. Duration of the video in seconds. Accepts 4, 8, 12. Defaults to 4.
guidancesobjectOptional. Object defining guidance inputs (e.g. reference images, start/end frames) that influence the result.
guidances.start_framearrayOptional. Creative reinterpretation of vibe or structure from a reference image. Maximum 1 item. Each item includes image.id and image.type (INIT, GENERATION, UPLOADED, GENERATED, VARIATION).
heightintegerRequired. Height of the output in pixels. Accepts 720, 1280, 1024, 1792. Defaults to 720.
modestringOptional. Resolution mode for the generation. Accepts RESOLUTION_720, RESOLUTION_1080. Defaults to RESOLUTION_720.
modelstringRequired. Specifies the model used for generation. Set to sora-2-pro.
promptstringRequired. The prompt to use for the generation. Maximum 5000 characters.
publicbooleanOptional. Controls whether the generation is public (true) or private (false).
quantityintegerRequired. The number of outputs to generate. Defaults to 1. Range 1-1.
widthintegerRequired. Width of the output in pixels. Accepts 1280, 720, 1024, 1792. Defaults to 1280.

Dimensions

The API accepts the following width and height values (in pixels), per the v2 API schema:

ParameterAllowed values (px)
width1280, 720, 1024, 1792
height720, 1280, 1024, 1792

Defaults: width 1280, height 720.

The mode parameter accepts: RESOLUTION_720, RESOLUTION_1080.