# Vidu/Video Extension

Video Extension Extend Interface Description

## Asynchronous Task Submission

### Interface

`https://api-us-ca.umodelverse.ai/v1/tasks/submit`

### Input

| Parameter             | Type   | Required  | Description                                               |
| :-------------------- | :----- | :-------- | :-------------------------------------------------------- |
| model                 | string | Yes       | Model name, options: `viduq2-turbo`, `viduq2-pro`         |
| input.video_url       | string | No        | Video URL. Video duration should not be less than 4 seconds or exceed 1 minute |
| input.last_frame_url  | string | No        | Reference image for extending to the last frame, supports image URL or Base64 encoding |
| input.prompt          | string | No        | Prompt for extension, used to control the content of the extended video |
| parameters.vidu_type  | string | Yes       | Vidu interface type, should be `extend` for video extension |
| parameters.duration   | int    | No        | Extension duration (seconds), options 1-7, default 5      |
| parameters.resolution | string | No        | Video resolution, options: `540p`, `720p`, `1080p`, default `720p` |

**Notes:**
- `video_url`
  - The video link to be extended must be provided and accessible publicly.
- `last_frame_url` parameter
   - Supports Base64 encoding or image URL (ensured accessible);
   - Reference image supports png, jpeg, jpg, webp formats
   - Image ratio must be less than 1:4 or 4:1
   - Image size should not exceed 50 MB
   - Note: The byte length after base64 decode must be less than 10M, and the encoding must contain the appropriate content type string, such as `data:image/png;base64,{base64_encode}`

### Request Example (using video_url)

⚠️ If using Windows, it is recommended to use Postman or other API calling tools.

```shell
curl --location --globoff 'https://api-us-ca.umodelverse.ai/v1/tasks/submit' \
--header 'Authorization: <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "viduq2-turbo",
    "input": {
      "video_url": "https://umodelverse-inference.cn-wlcb.ufileos.com/maxcot-dance.mp4",
      "last_frame_url": "https://umodelverse-inference.cn-wlcb.ufileos.com/ucloud-maxcot.jpg",
      "prompt": "Continue the video with smooth camera movement"
    },
    "parameters": {
      "vidu_type": "extend",
      "duration": 5,
      "resolution": "720p"
    }
  }'
```

### Output

| Parameter       | Type   | Description                   |
| :-------------- | :----- | :---------------------------- |
| output.task_id  | string | Unique identifier for the asynchronous task |
| request_id      | string | Unique identifier for the request |

### Response Example

```json
{
  "output": {
    "task_id": "task_id"
  },
  "request_id": "request_id"
}
```

## Check Task Status

### Interface

`https://api-us-ca.umodelverse.ai/v1/tasks/status?task_id=<task_id>`

### Request Example

```shell
curl --location 'https://api-us-ca.umodelverse.ai/v1/tasks/status?task_id=<task_id>' \
--header 'Authorization: <YOUR_API_KEY>'
```

### Output

| Parameter            | Type    | Description                                         |
| :------------------- | :------ | :-------------------------------------------------- |
| output.task_id       | string  | Unique identifier for the asynchronous task         |
| output.task_status   | string  | Task status: `Pending`,`Running`,`Success`,`Failure` |
| output.urls          | array   | List of URLs for video results                      |
| output.submit_time   | integer | Task submission timestamp                           |
| output.finish_time   | integer | Task completion timestamp                           |
| output.error_message | string  | Error message returned upon failure                 |
| usage.duration       | integer | Duration of the extended video (seconds)            |
| request_id           | string  | Unique identifier for the request                   |

### Response Example

```json
{
  "output": {
    "task_id": "task_id",
    "task_status": "Success",
    "urls": ["https://xxxxx/xxxx-extended.mp4"],
    "submit_time": 1756959000,
    "finish_time": 1756959050
  },
  "usage": {
    "duration": 5
  },
  "request_id": ""
}
```