﻿> ## Documentation Index
>
> Fetch the complete documentation index at: https://kling.ai/document-api/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Multi-Shot

> Source: https://kling.ai/document-api/api/image/common/subject-completion
> Locale: en
> Current Tab: AI Multi-Shot
> Sibling Tabs: AI Multi-Shot / Outpainting
> This content is optimized for LLMs. In-page tabs are expanded and UI-only controls are omitted.

---

## Create Task

### API Overview

- Method: `POST`
- Path: `/v1/general/ai-multi-shot`
- Auth: `Authorization: Bearer <API_KEY>`
- Content-Type: `application/json`

### Headers

| Field | Type | Required | Default | Enum | Description |
|---|---|---:|---|---|---|
| `Content-Type` | string | Yes | `application/json` | - | Data Exchange Format |
| `Authorization` | string | Yes | - | - | Authentication information, refer to API authentication |

### Request Body

| Field Path | Type | Required | Default | Enum | Description |
|---|---|---:|---|---|---|
| `element_frontal_image` | string | Yes | - | - | The frontal side of element image |
| `callback_url` | string | No | - | - | The callback notification address for the result of this task. If configured, the server will actively notify when the task status changes |
| `external_task_id` | string | No | - | - | Customized Task ID |

#### Request Body Field Notes

- `element_frontal_image`: Supports inputting image Base64 encoding or image URL (ensure accessibility).
- `element_frontal_image`: Supported image formats: .jpg / .jpeg / .png
- `element_frontal_image`: Image file size cannot exceed 10MB, and the width and height dimensions shall not be less than 300px, and the aspect ratio should be between 1:2.5 ~ 2.5:1
- `callback_url`: For the specific message schema, see [Callback Protocol](https://kling.ai/document-api/api/get-started/callbacks)
- `external_task_id`: Users can provide a customized task ID, which will not overwrite the system-generated task ID but can be used for task queries
- `external_task_id`: Please note that the customized task ID must be unique within a single user account

### Request Example

```bash
curl --request POST \
  --url https://api-singapore.klingai.com/v1/general/ai-multi-shot \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "element_frontal_image": "https://v1-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-1.png",
    "external_task_id": "",
    "callback_url": ""
  }'
```

### Response Example

```json
{
  "code": 0, // Error code; Specific definitions can be found in "Error Code"
  "message": "string", // Error message
  "request_id": "string", // Request ID, generated by the system, used to track requests and troubleshoot problems
  "data": {
    "task_id": "string", // Task ID, generated by the system
    "task_status": "string", // Task status, Enum values: submitted, processing, succeed, failed
    "task_info": { //Task creation parameters
      "external_task_id": "string" //Customer-defined task ID
    },
    "created_at": 1722769557708, // Task creation time, Unix timestamp, unit: ms
    "updated_at": 1722769557708 //Task update time, Unix timestamp, unit: ms
  }
}
```

---

## Query Task (Single)

### API Overview

- Method: `GET`
- Path: `/v1/general/ai-multi-shot/{id}`
- Auth: `Authorization: Bearer <API_KEY>`
- Content-Type: `application/json`

### Headers

| Field | Type | Required | Default | Enum | Description |
|---|---|---:|---|---|---|
| `Content-Type` | string | Yes | `application/json` | - | Data Exchange Format |
| `Authorization` | string | Yes | - | - | Authentication information, refer to API authentication |

### Path Params

| Field | Type | Required | Default | Enum | Description |
|---|---|---:|---|---|---|
| `task_id` | string | Yes | - | - | Task ID for AI Multi-Shot. Fill the value directly in the request path. |

### Request Example

```bash
curl --request GET \
  --url https://api-singapore.klingai.com/v1/general/ai-multi-shot/{task_id} \
  --header 'Authorization: Bearer <token>'
```

### Response Example

```json
{
  "code": 0, // Error code; Specific definitions can be found in "Error Code"
  "message": "string", // Error message
  "request_id": "string", // Request ID, generated by the system, used to track requests and troubleshoot problems
  "data": {
    "task_id": "string", // Task ID, generated by the system
    "task_status": "string", // Task status, Enum values: submitted, processing, succeed, failed
    "task_status_msg": "string", // Task status message, displaying the failure reason when the task fails (such as triggering the platform's content risk control, etc.)
    "task_info": { // Task creation parameters
      "external_task_id": "string" // Customer-defined task ID
    },
    "task_result": {
      "images": [
        {
          "index": 0, // Image result index, 0-2
          "url_1": "string", // URL for generated image, anti-hotlinking format (To ensure information security, generated images/videos will be cleared after 30 days. Please make sure to save them promptly.)
          "url_2": "string", // URL for generated image, anti-hotlinking format (To ensure information security, generated images/videos will be cleared after 30 days. Please make sure to save them promptly.)
          "url_3": "string" // URL for generated image, anti-hotlinking format (To ensure information security, generated images/videos will be cleared after 30 days. Please make sure to save them promptly.)
        }
      ]
    },
    "final_unit_deduction": "string", // Final unit deduction for the task
    "final_balance_deduction": { // Balance deduction information
      "quota": "string", // Balance deduction discount price
      "list_price": "string" // Balance deduction list price
    },
    "created_at": 1722769557708, // Task creation time, Unix timestamp, unit: ms
    "updated_at": 1722769557708 // Task update time, Unix timestamp, unit: ms
  }
}
```

---

## Query Task (List)

### API Overview

- Method: `GET`
- Path: `/v1/general/ai-multi-shot`
- Auth: `Authorization: Bearer <API_KEY>`
- Content-Type: `application/json`

### Headers

| Field | Type | Required | Default | Enum | Description |
|---|---|---:|---|---|---|
| `Content-Type` | string | Yes | `application/json` | - | Data Exchange Format |
| `Authorization` | string | Yes | - | - | Authentication information, refer to API authentication |

### Query Params

| Field | Type | Required | Default | Enum | Description |
|---|---|---:|---|---|---|
| `pageNum` | int | No | `1` | - | Page number |
| `pageSize` | int | No | `30` | - | Number of items per page |

#### Query Params Field Notes

- `pageNum`: Value range: [1, 1000]
- `pageSize`: Value range: [1, 500]

### Request Example

```bash
curl --request GET \
  --url 'https://api-singapore.klingai.com/v1/general/ai-multi-shot?pageNum=1&pageSize=30' \
  --header 'Authorization: Bearer <token>'
```

### Response Example

```json
{
  "code": 0, // Error code; Specific definitions can be found in "Error Code"
  "message": "string", // Error message
  "request_id": "string", // Request ID, generated by the system, used to track requests and troubleshoot problems
  "data": [
    {
      "task_id": "string", // Task ID, generated by the system
      "task_status": "string", // Task status, Enum values: submitted, processing, succeed, failed
      "task_status_msg": "string", // Task status message, displaying the failure reason when the task fails (such as triggering the platform's content risk control, etc.)
      "task_info": { //Task creation parameters
        "external_task_id": "string" //Customer-defined task ID
      },
      "task_result": {
        "images": [
          {
            "index": 0, // Image result index, 0-2
            "url_1": "string", // URL for generated image, anti-hotlinking format (Please note that for information security, generated images/videos will be deleted after 30 days. Please save them promptly.)
            "url_2": "string", // URL for generated image, anti-hotlinking format (Please note that for information security, generated images/videos will be deleted after 30 days. Please save them promptly.)
            "url_3": "string" //URL for generated image, anti-hotlinking format (Please note that for information security, generated images/videos will be deleted after 30 days. Please save them promptly.)
          }
        ]
      },
      "final_unit_deduction": "string", // Final unit deduction for the task
      "final_balance_deduction": { // Balance deduction information
        "quota": "string", // Balance deduction discount price
        "list_price": "string" // Balance deduction list price
      },
      "created_at": 1722769557708, // Task creation time, Unix timestamp, unit: ms
      "updated_at": 1722769557708 //Task update time, Unix timestamp, unit: ms
    }
  ]
}
```
