# Sora-2

A video model. This API uses a different invocation method from `submit`, but is consistent with the official `openai` API interface. There is no difference in model functionality.

## Submit Async Task

### Endpoint

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

### Input

| Parameter | Type | Required | Description |
|:---------|:-----|:---------|:------------|
| model | string | Yes | Model name, here it is `sora-2` |
| prompt | string | Yes | Prompt used to guide video generation |
| size | string | No | Output video size. <br>Supported resolutions: <br>- `720x1280`<br>- `1280x720`<br> |
| duration | string | No | Video duration in seconds. Supported values: `4`, `8`, `12` |
| input_reference | string | No | First-frame image |

### Request Example
⚠️ If you are using Windows, it is recommended to use Postman or another API client tool.
```shell
curl -X POST "https://api-us-ca.umodelverse.ai/v1/videos" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F prompt="She turns around and smiles, then slowly walks out of the frame." \
  -F model="sora-2" \
  -F size="1280x720" \
  -F seconds="8" \
  -F input_reference="@sample_720p.jpeg;type=image/jpeg"
```

### Output

| Parameter | Type   | Description                                                    |
| :-------- | :----- | :------------------------------------------------------------- |
| id        | string | Unique identifier of the async task                            |
| object    | string | Object type                                                    |
| model     | string | Model name                                                     |
| status    | string | Task status: `queued`, `in_progress`, `completed`, or `failed` |
| progress  | int    | Task progress                                                  |
| size      | string | Resolution                                                     |
| seconds   | string | Duration                                                       |

### Response Example

```json
{
    "id": "video_456",
    "object": "video",
    "model": "sora-2",
    "status": "queued",
    "progress": 0,
    "created_at": 1712698600,
    "size": "720x1280",
    "seconds": "8"
}
```

## Query Task Status

### Endpoint

`https://api-us-ca.umodelverse.ai/v1/videos/<task_id>`

### Request Example

```shell
curl --location 'https://api-us-ca.umodelverse.ai/v1/videos/video_6982fa1cd4f081908b619dc53cfc2435' \
-H "Authorization: Bearer $OPENAI_API_KEY"
```

### Output

| Parameter | Type   | Description                                                    |
| :-------- | :----- | :------------------------------------------------------------- |
| id        | string | Unique identifier of the async task                            |
| object    | string | Object type                                                    |
| model     | string | Model name                                                     |
| status    | string | Task status: `queued`, `in_progress`, `completed`, or `failed` |
| progress  | int    | Task progress                                                  |
| size      | string | Resolution                                                     |
| seconds   | string | Duration                                                       |

### Response Example (Success)

```json
{
  "id": "video_456",
  "object": "video",
  "model": "sora-2",
  "status": "queued",
  "progress": 0,
  "created_at": 1712698600,
  "size": "720x1280",
  "seconds": "8"
}
```

### Response Example (Failure)

```json
{
  "error": {
    "message": "error",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}
```

## Download Video

### Endpoint

`https://api-us-ca.umodelverse.ai/v1/videos/<task_id>/content`

### Request Example

```shell
curl --location 'https://api-us-ca.umodelverse.ai/v1/videos/<task_id>/content' \
-H "Authorization: Bearer $OPENAI_API_KEY"
--output video.mp4
```

### Normal Response

Returns a binary stream.

### Error Response

```json
{
    "error": {
        "message": "task is not completed yet, current status: Pending",
        "type": "invalid_request_error"
    }
}
```

## remix

### Endpoint

`https://api-us-ca.umodelverse.ai/v1/videos/<task_id>/remix`

### Request Example

```shell
curl -X POST "https://api-us-ca.umodelverse.ai/v1/videos/<task_id>/remix" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Cyberpunk style"
  }'
```

### Normal Response

```json
{
  "id": "video_456",
  "object": "video",
  "model": "sora-2",
  "status": "queued",
  "progress": 0,
  "created_at": 1712698600,
  "size": "720x1280",
  "seconds": "8",
  "remixed_from_video_id": "video_123"
}
```

### Error Response

```json
{
    "error": {
        "message": "Invalid param: prompt is required",
        "type": "invalid_request_error",
        "param": "6217f8ed-396d-434a-9b78-96775c0d2f99",
        "code": "param_error"
    }
}
```
