The Vidu first and last frame video generation model creates a smoothly transitioning video based on a first frame image , a last frame image, and a text prompt .
Activate the service
Go to the Alibaba Cloud Model Studio console, search for Vidu, find the Vidu model card, and click Activate Now. In the pop-up window, confirm the activation and authorization.
Scope
To ensure successful calls, make sure that the model, Endpoint URL, and API key all belong to the same region. Cross-region calls will fail.
- Select a model: Confirm the region where the model is located.
- Select a URL: Select the corresponding regional Endpoint URL. HTTP URLs are supported.
- Configure an API key: Select a region and obtain an API key. Then, configure the API key as an environment variable (to be unpublished and merged into API key configuration).
HTTP calls
Because first and last frame video generation tasks take a long time (typically 1 to 5 minutes), the API uses asynchronous invocation. The entire process involves two core steps: Create a task -> Poll for the result. The procedure is as follows:
Step 1: Create a task and get the task ID
Beijing region: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
- After the task is created, use the returned
task_idto query the result. Thetask_idis valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result. - For guidance for beginners, see Call APIs with Postman or cURL.
Request parametersRequest headersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable.Request bodymodelstring (Required)The model name. For more information about available models, see the Model List.Static field: vidu/viduq3-turbo_start-end2video.input object (Required)Basic input information, including the first frame, last frame image, and prompt.
Properties prompt string (Required)The text prompt. It describes the transition process from the first frame to the last frame.Both Chinese and English are supported. Each Chinese character or letter counts as one character. The maximum length is 5,000 characters. Any excess characters are automatically truncated.Example: A kitten jumps down from the windowsill, lands lightly on the sofa, and then looks around curiously.For more information about how to write prompts, see Vidu Video Generation Prompt Guide.media array (Required)A list of media resources, including the first and last frame images.Each element in the array is a media object that contains type and url fields.
Properties type string (Required)The media type. The static field is:
string (Required)The publicly accessible URL of the image.
object (Required)Video generation parameters, such as video resolution and duration.
Properties resolution string (Required)The resolution of the generated video. The optional values are:
integer (Required)The duration of the generated video, in seconds.
boolean (Optional)Supported models: vidu/viduq3-pro_start-end2video, vidu/viduq3-turbo_start-end2video.Specifies whether to generate a video with sound. If this parameter is enabled, the model automatically generates matching background music or sound effects based on the video content.
boolean (Optional)Specifies whether to add a watermark. The watermark is located in the lower-right corner of the video and displays the text "Generated by AI".
integer(Optional)A random number seed. The value can be an integer from 0 to 2147483647.If this parameter is not specified, the system automatically generates a random seed. To improve the reproducibility of the generated results, set a fixed seed value.Note that because model generation is probabilistic, using the same seed does not guarantee that the results will be identical every time.Example: 12345. |
|
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query the result by task ID
Beijing region: GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
- Polling recommendation: Video generation takes several minutes. We recommend that you use a polling mechanism and set a reasonable query interval, such as 15 seconds, to obtain the result.
- Task status flow: PENDING (In queue) -> RUNNING (Processing) -> SUCCEEDED (Successful) / FAILED (Failed).
- task_id validity: 24 hours. After this period, you cannot query the result, and the API returns the task status as
UNKNOWN. - RPS limit: The default records per second (RPS) for the query API is 20. For higher-frequency queries or event notifications, you can configure an asynchronous task callback.
- More operations: For operations such as batch queries and task cancellation, see Manage asynchronous tasks.
Request parametersRequest headersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.URL path parameterstask_idstring (Required)The ID of the task. |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours |
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.video_urlstringThe video URL. This parameter is returned only when task_status is SUCCEEDED.The video is in MP4 format (H.264 encoding). The video link is valid for 24 hours. We recommend that you download it promptly.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.objectStatistics for the output information. This parameter is counted only for successful results.
Properties duration integerThe total billable video duration in seconds. Example: 5.output_video_durationintegerThe duration of the output video in seconds. Example: 5.size stringThe resolution of the output video. Example: 828*624.fps integerThe frame rate of the output video. Example: 24.SR stringThe resolution tier of the output video. Example: 540.audio booleanIndicates whether the output video has sound. Example: false.video_count integerThe number of output videos. This is a static field with a value of 1.stringUnique request identifier for tracing and troubleshooting. |
|
Error codes
If a model call fails and returns an error message, see Error messages to resolve the issue.
FAQ
Q: Is there a required order for the first and last frames in the media array?
A: Yes, there is. The media array must contain two type=image objects. The first element represents the first frame, and the second element represents the last frame.