PixVerse: Image-to-video from first and last frames API reference

Updated at:

The PixVerse model for first and last frames generates a smooth video transition based on a first frame image, a last frame image , and a text prompt .

ImportantThis document applies only to the China (Beijing) region. Use an API key from this region.

Activate the service

  1. Go to the Alibaba Cloud Model Studio console, search for PixVerse, find the PixVerse model card, and click Activate Now.
  2. In the pop-up window, confirm the activation and authorization.

Scope

To ensure successful invocations, make sure that the model, Endpoint URL, and API key all belong to the same region. Invocations across different regions will fail.

NoteThe sample code in this topic applies to the China (Beijing) region.

HTTP invocation

Generating a video from the first and last frames is a time-consuming task that usually takes 1 to 5 minutes. Therefore, the API uses asynchronous invocation. The process involves two core steps: Create a task -> Poll for the result, as described below:

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

Replace {WorkspaceId} with your actual workspace ID.

Note

  • After the task is created, use the task_id returned by the API to query the results. The task_id is valid for 24 hours. Do not create the task repeatedly; simply poll for the results.

Request parameters

Request headers

Content-Type string (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)

Asynchronous processing configuration parameter. HTTP requests support asynchronous mode only, and it must be set to enable.

ImportantIf this request header is missing, the error "current user api does not support synchronous calls" is returned.

Request body

model string (Required)

The model name.

Valid values:

  • pixverse/pixverse-c1-kf2v
  • pixverse/pixverse-v6-kf2v
  • pixverse/pixverse-v5.6-kf2v

Model selection

  • For dynamic scenarios such as fights, magic effects, and high-speed motion, use c1.
  • For general scenarios, use v6. If you are using v5.6, we recommend that you upgrade to v6.

input object (Required)

The basic input information, which includes the first frame image, last frame image, and prompt.

Properties

prompt string (Required)

The text prompt. It describes the transition from the first frame to the last frame.

Both Chinese and English are supported. Each Chinese character or letter is counted as one character. The character encoding is UTF-8. Any excess characters are automatically truncated.

  • pixverse/pixverse-c1-kf2v: Up to 5,000 characters.
  • pixverse/pixverse-v6-kf2v: Up to 5,000 characters.
  • pixverse/pixverse-v5.6-kf2v: Up to 2,048 characters.

media array (Required)

The list of media resources, which includes the first and last frame images.

Each element in the array is a media object that contains the type and url fields.

Properties

type string (Required)

The media type.

  • first_frame: The first frame image.
  • last_frame: The last frame image.

Image limits:

  • First frame image: Exactly one image.
  • Last frame image: Exactly one image.

url string (Required)

The publicly accessible URL of the image.

Image limits:

  • Format: JPG, PNG, or WEBP.
  • Resolution: The width and height must not exceed 10,000 pixels.
  • File size: Up to 20 MB.

parameters object (Required)

The video generation parameters, such as the video resolution, duration, and whether to generate audio.

Properties

resolution string (Required)

ImportantThe resolution directly affects the cost. Before you make a call, confirm the model price.

The resolution of the generated video.

Valid values: 360P, 540P, 720P, or 1080P.

duration integer (Required)

ImportantThe duration directly affects the cost. Before you make a call, confirm the model price.

The duration of the generated video in seconds.

  • pixverse/pixverse-c1-kf2v: The value is an integer in the range [1, 15].

  • pixverse/pixverse-v6-kf2v: The value is an integer in the range [1, 15].

  • pixverse/pixverse-v5.6-kf2v:

    • If the resolution is 360P, 540P, or 720P, the value can be 5, 8, or 10.
    • If the resolution is 1080P, the value can be 5 or 8.

audio boolean (Optional)

ImportantThe audio setting directly affects the cost. Before you make a call, confirm the model price.

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.

  • false: The default value. A silent video is generated.
  • true: A video with sound is generated.

watermark boolean (Optional)

Specifies whether to add a watermark. The watermark is located in the lower-right corner of the video and displays the fixed text "AI Generated".

  • false: The default value. No watermark is added.
  • true: A watermark is added.

seedinteger(Optional)

The random number seed. The value must be in the range [0, 2147483647].

If this parameter is not specified, the system automatically generates a random seed. To improve the reproducibility of the generation results, you can set a fixed seed value.

Note that because model generation is probabilistic, using the same seed does not guarantee that the results are identical every time.

Generate a video from first and last frames

Supported models: pixverse/pixverse-c1-kf2v, pixverse/pixverse-v6-kf2v, and pixverse/pixverse-v5.6-kf2v.

# 调用时请将 {WorkspaceId} 替换为真实的业务空间ID。
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "pixverse/pixverse-c1-kf2v",
    "input": {
        "media": [
            {
                "type": "first_frame",
                "url": "https://wanx.alicdn.com/material/20250318/first_frame.png"
            },
            {
                "type": "last_frame",
                "url": "https://wanx.alicdn.com/material/20250318/last_frame.png"
            }
        ],
        "prompt": "一只小猫从窗台向下跳跃,轻盈地落在沙发上,然后好奇地环顾四周。"
    },
    "parameters": {
        "resolution": "720P",
        "duration": 5,
        "watermark": true
    }
}'

Python SDK

import dashscope
import os
from dashscope import DashScopeError

# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
client = dashscope.Client(api_key=os.getenv("DASHSCOPE_API_KEY"))

media = [{'type': 'first_frame', 'url': 'https://wanx.alicdn.com/material/20250318/first_frame.png'}, {'type': 'last_frame', 'url': 'https://wanx.alicdn.com/material/20250318/last_frame.png'}]

def sample_async_call():
    # 异步提交视频生成任务
    try:
        job = client.videos.jobs.create(model='pixverse/pixverse-c1-kf2v',
                                        media=media,
                                        prompt='一只小猫从窗台向下跳跃,轻盈地落在沙发上,然后好奇地环顾四周。',
                                        resolution='720P',
                                        duration=5,
                                        watermark=True)
        print(job)
        print("task_id: %s" % job.task_id)
    except DashScopeError as e:
        print(f"HTTP返回码:{e.status_code}")
        print(f"错误码:{e.code}")
        print(f"错误信息:{e.message}")
        print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
        return

    # 查询任务状态
    try:
        snapshot = client.videos.jobs.fetch(job.task_id)
        print(snapshot.status)
    except DashScopeError as e:
        print(f"HTTP返回码:{e.status_code}")
        print(f"错误码:{e.code}")
        print(f"错误信息:{e.message}")
        print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")

    # 等待任务完成
    try:
        done = client.videos.jobs.wait(job)
        print(done)
        print(done.video_url)
    except DashScopeError as e:
        print(f"HTTP返回码:{e.status_code}")
        print(f"错误码:{e.code}")
        print(f"错误信息:{e.message}")
        print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")

if __name__ == '__main__':
    sample_async_call()

Response parameters

output object

The task output information.

Properties

task_id string

The task ID. Valid for queries for 24 hours.

task_status string

The status of the task.

Enumeration values

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • CANCELED
  • UNKNOWN: The task does not exist or its status is unknown.

request_idstring

Unique request identifier for tracing and troubleshooting.

codestring

Error code. Returned only for failed requests. See Error codes.

messagestring

Detailed error message. Returned only for failed requests. See Error codes.

Successful response

Save the task_id, which is used to query the task status and results.

{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

Error response

Task creation failed. See Error codes.

{
    "code": "InvalidApiKey",
    "message": "No API-key provided.",
    "request_id": "7438d53d-6eb8-4596-8835-xxxxxx"
}

Step 2: Query the result by task ID

Beijing region: GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}

Note

  • Polling recommendation: Video generation takes several minutes. We recommend using a polling mechanism and setting a reasonable query interval (for example, 15 seconds) to obtain the results.
  • Task status transitions: PENDING (Queuing) → RUNNING (Processing) → SUCCEEDED (Success) / FAILED (failed).
  • task_id validity: 24 hours. Once it expires, the results can no longer be queried, and the API returns the task status UNKNOWN.
  • RPS limits: The default RPS of the query API is 20. For more frequent queries or event notifications, we recommend configuring asynchronous task callbacks.
  • More operations: For operations such as batch queries and task cancellation, see Manage asynchronous tasks.

Request parameters

Request headers

Authorization string (Required)

Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.

Path parameters

task_id string (Required)

The ID of the task.

Query the task result

Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID.

curl -X GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Response parameters

outputobject

The task output information.

Properties

task_id string

The task ID. Valid for queries for 24 hours.

task_status string

The status of the task.

Enumeration values

  • PENDING
  • RUNNING
  • SUCCEEDED
  • FAILED
  • CANCELED
  • UNKNOWN: The task does not exist or its status is unknown.
State transitions during polling:
  • PENDING → RUNNING → SUCCEEDED or FAILED.
  • The initial query status is usually PENDING or RUNNING.
  • When the status changes to SUCCEEDED, the response contains the generated video URL.
  • If the status is FAILED, check the error message and retry the task.

submit_time string

The time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.

scheduled_time string

The time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.

end_time string

The time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.

video_urlstring

The video URL. This parameter is returned only when the task_status is SUCCEEDED.

The video format is MP4 with H.264 encoding. The video link does not expire. However, we recommend that you do not use it for long-term storage. Download the video promptly.

orig_prompt string

The original input prompt, corresponding to the request parameter prompt.

codestring

Error code. Returned only for failed requests. See Error codes.

messagestring

Detailed error message. Returned only for failed requests. See Error codes.

usage object

The statistics of the output information. Only successful results are counted.

Properties

duration integer

The total duration of the generated video, which is used for billing.

size string

The resolution of the generated video.

fps integer

The frame rate of the generated video.

SR string

The resolution tier of the generated video.

audio boolean

Indicates whether the generated video contains sound.

video_count integer

The number of generated videos. The value is fixed at 1.

request_idstring

Unique request identifier for tracing and troubleshooting.

Task successful

{
    "request_id": "40799260-689c-4c44-9d7c-xxxxxx",
    "output": {
        "task_id": "408b6c3b-27c9-43dd-b928-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2026-03-20 13:47:42.916",
        "scheduled_time": "2026-03-20 13:47:42.949",
        "end_time": "2026-03-20 13:48:41.896",
        "orig_prompt": "一只小猫从窗台向下跳跃,轻盈地落在沙发上,然后好奇地环顾四周。",
        "video_url": "https://media.pixverseai.cn/xxx.mp4"
    },
    "usage": {
        "duration": 5,
        "size": "1280*960",
        "fps": 24,
        "video_count": 1,
        "audio": false,
        "SR": "720"
    }
}

Task failed

If the task execution fails, task_status is set to FAILED, and an error code and message are provided. See Error codes for troubleshooting.

{
    "request_id": "e5d70b02-ebd3-98ce-9fe8-759d7d7b107d",
    "output": {
        "task_id": "86ecf553-d340-4e21-af6e-a0c6a421c010",
        "task_status": "FAILED",
        "code": "InvalidParameter",
        "message": "The size is not match xxxxxx"
    }
}

Task query expired

The task_id is valid for queries within 24 hours. After it expires, queries are no longer possible and the following error message is returned.

{
    "request_id": "a4de7c32-7057-9f82-8581-xxxxxx",
    "output": {
        "task_id": "502a00b1-19d9-4839-a82f-xxxxxx",
        "task_status": "UNKNOWN"
    }
}

Error codes

If the model call fails and returns an error message, see Error codes for resolution.

FAQ

Q: Does the order of the first and last frames in the media array matter?

A: The media array must contain two objects, with their type fields set to first_frame (first frame) and last_frame (last frame), respectively. The order does not affect the result because the system automatically detects them based on the type field.

Q: Do the first and last frame images need to have the same resolution?

A: No, they do not. The first and last frames can have different resolutions. The system handles this automatically.

The aspect ratio of the output video is approximately the same as that of the first frame. The resolution is automatically adjusted to a similar total pixel count based on the selected resolution setting, such as 720P.