# Kling/v3

Text-to-Video & Image-to-Video Model. The mode is determined by whether the `image` parameter is provided.

## Submit Task (Asynchronous)

### Endpoint

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

### Input

| Parameter                     | Type    | Required | Description |
| :--------------------------- | :------ | :------- | :---------- |
| model                        | string  | Yes      | Model name, here it is `kling-v3` |
| input.prompt                 | string  | Conditional | Prompt, up to 2500 characters. Must not be empty when `multi_shot` is `false` |
| input.negative_prompt        | string  | No       | Negative prompt, up to 2500 characters |
| parameters.image             | string  | No       | Reference image (first frame). If not provided → text-to-video; if provided → image-to-video. Supports Base64 or URL (must be accessible).<br>For Base64, do NOT include prefixes like `data:image/png;base64,`.<br>- Supported formats: `.jpg`, `.jpeg`, `.png`<br>- Max size: 10MB<br>- Min resolution: 300px; aspect ratio between 1:2.5 ~ 2.5:1 |
| parameters.image_tail        | string  | No       | End frame image. Must be used together with `image`. Supports URL or Base64, same requirements as `image` |
| parameters.mode              | string  | No       | Generation mode. `std`: standard (720P); `pro`: professional (1080P). Default `std` |
| parameters.aspect_ratio      | string  | No       | Aspect ratio: `16:9`, `9:16`, `1:1`. Default `16:9`. Ignored in image-to-video mode (uses input image ratio) |
| parameters.duration          | int     | No       | Video duration (seconds), range: `3` ~ `15`, default `5` |
| parameters.sound             | string  | No       | Whether to generate sound. Options: `on`, `off`, default `off` |
| parameters.multi_shot        | bool    | No       | Enable multi-shot mode. Default `false`.<br>When `true`, `prompt` is ignored; when `false`, `shot_type` and `multi_prompt` are ignored |
| parameters.shot_type         | string  | Conditional | Shot type, required when `multi_shot` is `true`. Available: `customize` |
| parameters.multi_prompt      | array   | Conditional | Multi-shot prompt list. Required when `multi_shot=true` and `shot_type=customize`.<br>- 1–6 shots<br>- Each ≤512 chars<br>- Each shot duration ≥1s and ≤ total duration<br>- Sum of durations must equal total duration<br>Each item includes:<br>- `index` (int)<br>- `prompt` (string)<br>- `duration` (string) |
| parameters.watermark_enabled | bool    | No       | Whether to generate watermarked output |
| parameters.external_task_id  | string  | No       | Custom task ID. Does not override system ID, but can be used for querying. Must be unique per user |

### Request Examples

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

**Text-to-Video (no `image`):**

```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": "kling-v3",
    "input": {
      "prompt": "A beautiful sunset over the ocean with waves gently crashing"
    },
    "parameters": {
      "mode": "pro",
      "aspect_ratio": "16:9",
      "duration": 5,
      "sound": "on"
    }
  }'
```

**Image-to-Video (with `image` as first frame):**

```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": "kling-v3",
    "input": {
      "prompt": "The image comes to life with gentle movement"
    },
    "parameters": {
      "mode": "pro",
      "duration": 5,
      "image": "https://example.com/first_frame.jpg"
    }
  }'
```

**First + Last Frame Control:**

```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": "kling-v3",
    "input": {
      "prompt": "A girl walking through a garden"
    },
    "parameters": {
      "mode": "pro",
      "duration": 5,
      "image": "https://example.com/first_frame.jpg",
      "image_tail": "https://example.com/last_frame.jpg"
    }
  }'
```

**Multi-shot Generation:**

```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": "kling-v3",
    "parameters": {
      "mode": "pro",
      "aspect_ratio": "16:9",
      "duration": 5,
      "multi_shot": true,
      "shot_type": "customize",
      "multi_prompt": [
        {"index": 1, "prompt": "A person walking through a misty forest at dawn", "duration": "2"},
        {"index": 2, "prompt": "A car speeding down a rainy street, headlights glowing", "duration": "3"}
      ],
      "sound": "on"
    }
  }'
```

### Output

| Parameter      | Type   | Description                         |
| :------------- | :----- | :---------------------------------- |
| output.task_id | string | Unique identifier of the async task |
| request_id     | string | Unique identifier of 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 of the async 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 when failed                      |
| usage.duration       | integer | Video duration (seconds)                                |
| request_id           | string  | Unique identifier of the request                        |

### Response Example (Success)

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

### Response Example (Failure)

```json
{
  "output": {
    "task_id": "task_id",
    "task_status": "Failure",
    "submit_time": 1756959000,
    "finish_time": 1756959019,
    "error_message": "error_message"
  },
  "usage": {
    "duration": 5
  },
  "request_id": ""
}
```

## Error Codes

| Error Code | Description            |
| :--------- | :--------------------- |
| 006001094  | Insufficient resources |
| 006001095  | Task response error    |
| 006001099  | Task creation error    |
