# OpenAI/Sora2-I2V

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, here it is `openai/sora-2/image-to-video`    |
| input.first_frame_url| string | Yes      | URL of the first frame image, can be URL or Base64       |
| input.prompt         | string | No       | Prompt for guiding video generation                      |
| parameters.duration  | int    | No       | Video generation duration (seconds), options are `4`, `8`, `12`, default is `4` |

### Request Example
⚠️ If you are 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": "openai/sora-2/image-to-video",
    "input": {
      "first_frame_url": "https://umodelverse-inference.cn-wlcb.ufileos.com/ucloud-maxcot.jpg",
      "prompt": "The image is coming to life"
    },
    "parameters": {
      "size": "720x1280",
      "duration": 4
    }
  }'
```

### 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"
}
```

## Query 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 for the asynchronous task           |
| output.task_status    | string  | Task status: `Pending`, `Running`, `Success`, `Failure` |
| output.urls           | array   | List of URLs of video results                         |
| output.submit_time    | integer | Task submission timestamp                             |
| output.finish_time    | integer | Task completion timestamp                             |
| output.error_message  | string  | Error message if task failed                          |
| usage.duration        | integer | Task execution duration (seconds)                     |
| request_id            | string  | Unique identifier for 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": 4
  },
  "request_id": ""
}
```