# Vidu/Img2Video

Image-to-video model

## Asynchronous Task Submission

### Endpoint

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

### Input

| Parameter                     | Type   | Required | Description                                                                                                                                                                                                                                                      |
| :---------------------------- | :----- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| model                         | string | Yes      | Model name, options: `viduq2-pro`, `viduq2-turbo` <br> - viduq2-pro: New model, better quality, rich in details <br> - viduq2-turbo: New model, better quality, fast generation                                                                                  |
| input.first_frame_url         | string | Yes      | First frame image, supports image URL or Base64 encoding                                                                                                                                                                                                         |
| input.prompt                  | string | No       | Text prompt for guiding video generation, up to 2000 characters.                                                                                                                                                                                                  |
| parameters.vidu_type          | string | Yes      | Vidu API type, here is `img2video`                                                                                                                                                                                                                                |
| parameters.duration           | int    | No       | Video duration <br> viduq2-pro default is 5, options: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 <br> viduq2-turbo default is 5, options: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10                                                                                                        |
| parameters.seed               | int    | No       | Random seed, default 0 means using a random number                                                                                                                                                                                                                |
| parameters.resolution         | string | No       | Resolution, viduq2: 540p/720p/1080p, viduq1: 1080p, vidu2.0/1.5: 360p/720p/1080p, default value depends on the model                                                                                                                                               |
| parameters.movement_amplitude | string | No       | Movement amplitude, options: `auto`, `small`, `medium`, `large`, default `auto`                                                                                                                                                                                   |
| parameters.bgm                | bool   | No       | Whether to add background music, default `false`                                                                                                                                                                                                                  |

**Notes:**
- Images support png, jpeg, jpg, webp formats
- Image ratio should be less than 1:4 or 4:1
- Image size should not exceed 50 MB
- Example Base64 encoding format: `data:image/png;base64,{base64_encode}`

### Request Example

⚠️ If you are using Windows, it is recommended to use Postman or other API call 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-pro",
    "input": {
      "first_frame_url": "https://umodelverse-inference.cn-wlcb.ufileos.com/ucloud-maxcot.jpg",
      "prompt": "make it dance."
    },
    "parameters": {
      "vidu_type": "img2video",
      "duration": 5,
      "resolution": "1080p",
      "movement_amplitude": "auto",
      "bgm": true
    }
  }'
```

### Output

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

### Response Example

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

## Check Task Status

### Endpoint

`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 of the asynchronous task     |
| output.task_status   | string  | Task status: `Pending`, `Running`, `Success`, `Failure` |
| output.urls          | array   | List of video result URLs                      |
| 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 | Video duration (seconds)                       |
| request_id           | string  | Unique identifier of the request               |

### Response Example

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