Application Process
To use the API, you need to first apply for the corresponding service on the Sora Videos Generation API page. After entering the page, click the “Acquire” button, as shown in the image:
If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in. After logging in or registering, you will be automatically returned to the current page.
Upon your first application, there will be a free quota provided, allowing you to use the API for free.
Basic Usage
First, understand the basic usage method, which involves inputting the promptprompt, an array of reference image links image_urls, and the model model to obtain the processed result. The specific content is as follows:

accept: the format of the response result you want to receive, filled in asapplication/json, which means JSON format.authorization: the key to call the API, which can be selected directly after application.
model: the model for generating the video, mainlysora-2andsora-2-pro. Currently,sora-2andsora-2-proallow you to choose thesizeanddurationparameters for the video, wheresora-2-prosupports adurationof 25 seconds, whilesora-2only supports 10 and 15 seconds.size: the clarity of the video generation task, which can besmallorlarge.image_urls: the array of reference image links or Base64 encoded images to be uploaded.duration: the duration of the video generation task, which can be 10s, 15s, or 25s, with onlysora-2-prosupporting 25s.character_start/character_end: the start and end positions of the character in the frame (0-1), used to control the position of the subject.orientation: the aspect ratio, supportinglandscape,portrait, orsquare.prompt: the prompt.callback_url: the URL to which the result needs to be sent back.

success: the status of the video generation task at this time.task_id: the ID of the video generation task at this time.trace_id: the tracking ID of the video generation at this time.data: the result list of the video generation task at this time.id: the video ID of the video generation task at this time.video_url: the video link of the video generation task at this time.state: the status of the video generation task at this time.
data result.
Additionally, if you want to generate the corresponding integration code, you can directly copy the generated code, for example, the CURL code is as follows:
Image to Video Task
If you want to create an image to video task, the parameterimage_urls must first pass in the reference image links, allowing you to specify the following content:
- image_urls: the array of reference image links used for this image to video task.


Character Generation Video Task
If you want to generate a character video task, the parametercharacter_url must first be passed in with the video link needed to create the character. Note that the video must not contain real people, otherwise it will fail. You can specify the following content:
- character_url: The video link needed to create the character. Note that the video must not contain real people, otherwise it will fail.


Asynchronous Callback
Since the Sora Videos Generation API takes a relatively long time to generate, approximately 1-2 minutes, if the API does not respond for a long time, the HTTP request will keep the connection open, leading to additional system resource consumption. Therefore, this API also provides support for asynchronous callbacks. The overall process is: when the client initiates a request, an additionalcallback_url field is specified. After the client initiates the API request, the API will immediately return a result containing a task_id field information, representing the current task ID. When the task is completed, the generated video result will be sent to the client-specified callback_url in the form of a POST JSON, which also includes the task_id field, so that the task result can be associated by ID.
Let’s understand how to operate specifically through an example.
First, the Webhook callback is a service that can receive HTTP requests, and developers should replace it with the URL of their own HTTP server. For demonstration purposes, a public Webhook sample site https://webhook.site/ is used. Open this site to get a Webhook URL, as shown in the figure:
Copy this URL, and it can be used as a Webhook. The sample here is https://webhook.site/eb238c4f-da3b-47a5-a922-a93aa5405daa.
Next, we can set the callback_url field to the above Webhook URL, while filling in the corresponding parameters, as shown in the figure:

https://webhook.site/eb238c4f-da3b-47a5-a922-a93aa5405daa, as shown in the figure:
The content is as follows:
task_id field, and other fields are similar to the above text. This field can be used to associate tasks.
Error Handling
When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:400 token_mismatched: Bad request, possibly due to missing or invalid parameters.400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.401 invalid_token: Unauthorized, invalid or missing authorization token.429 too_many_requests: Too many requests, you have exceeded the rate limit.500 api_error: Internal server error, something went wrong on the server.

