Video / Kling

Kling Image Generation

Overview

Kling Image Generation7 Model, Text-to-Image, Reference image-to-Image, reference subject image, image and image.Request Body and task,ModelendpointPath, field.

ModelCapability (, Reference image, supported image ), first「ModelCapabilitylocalized example text」localized example text.Model supported Parameter will return ParameterError,will.

localized example textDescription
localized example texttask:task booking returntaskId, Pollingor
localized example textimage images
Reference imagesupported URL or Base64, single image exceeds 30MB
Promptexceeds 2500 characters

Base URL: https://mm-internal-cn.leonecloud.com ()

---## Authentication

with endpoint in Request in API Key:```
Authorization: Bearer {YOUR_API_KEY}


---

## ModelCapabilitylocalized example text| Model | endpointPath | localized example text| localized example text| Reference image | reference subject| image|
|------|---------|--------|---------|--------|---------|------|
| `kling-image-v3` | `/api/v2/open/aigc/kling-image-v3` | `1k` / `2k` | supported`auto` | 1 images| ✅ | ❌ |
| `kling-image-v3-omni` | `/api/v2/open/aigc/kling-image-v3-omni` | `1k` / `2k` / `4k` | supported`auto` (default) | multiple images | ✅ | ✅ up to 9 images|
| `kling-image-o1` | `/api/v2/open/aigc/kling-image-o1` | `1k` / `2k` | supported`auto` (default) | multiple images | ❌ | ❌ |
| `kling-image-v2.1` | `/api/v2/open/aigc/kling-image-v2.1` | **no Parameter** | supported`auto` | 1 images| ❌ | ❌ |
| `kling-image-v2.1-ref` | `/api/v2/open/aigc/kling-image-v2.1-ref` | **no Parameter** | supported`auto` | **Required 1-4 images** | ❌ | ❌ |
| `kling-image-v4` | `/api/v2/open/aigc/kling-image-v4` | **`2k` / `4k` / `8k`** | supported`auto` (default) | multiple images | ✅ | ✅ **up to 10 images** |
| `kling-image-v4-long` | `/api/v2/open/aigc/kling-image-v4-long` | `1k` / `2k` | **no Parameter** | multiple images | ❌ | ❌ 1 images|

**localized example text**

- `kling-image-v4` **with`1k` localized example text**, localized example text`2k`.Model`1k` will.
- `kling-image-v2.1` and`kling-image-v2.1-ref` **with Parameter**, localized example text`resolution` will return ParameterError.
- `aspectRatio: "auto"` only `kling-image-v3-omni` / `kling-image-o1` / `kling-image-v4` supported, Model will ( will default).
- image:`kling-image-v3-omni` 9 images,`kling-image-v4` 10 images.
- `kling-image-v4-long` 1 images image,`n > 1` or`seriesAmount` will.

---

## Quick Start

**Text-to-Image**
```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/kling-image-v3" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": ",, and",
"resolution": "2k",
"aspectRatio": "1:1",
"n": 2
}'


**Reference image-to-Image**
```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/kling-image-v3-omni" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "reference images image, Scenario,",
"imageUrls": ["https://example.com/mug.png"],
"resolution": "2k",
"aspectRatio": "auto"
}'


**image**
```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/kling-image-v3-omni" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": ", consistent",
"imageUrls": ["https://example.com/mug.png"],
"resolution": "2k",
"resultType": "series",
"seriesAmount": 4
}'


**Kling 4.0 image:localized example text`@id` in Prompt asset**
```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/kling-image-v4" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "localized example text@mug in the as subject, in@desk, image",
"imageUrls": [
"https://example.com/mug.png",
"https://example.com/desk.png"
],
"refImageIds": ["mug", "desk"],
"resolution": "4k",
"resultType": "series",
"seriesAmount": 6
}'


**image:**
```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/kling-image-v4-long" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "as@product in the,, and use Scenario",
"imageUrls": ["https://example.com/coffee-machine.png"],
"refImageIds": ["product"],
"skill": "ecommerce",
"length": "medium",
"resolution": "2k"
}'


**Query Task**
```bash

curl -X GET "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/task_20261120182953_bx5gm0k5" \
-H "Authorization: Bearer your_api_key_here"


---

## Endpoints

| Method | Path | localized example text|
|--------|------|------|
| POST | `/api/v2/open/aigc/{Model}` | create Image Generationtask,`{Model}` Capability|
| GET | `/api/v2/open/aigc/{taskId}` | query task|
| POST | `/api/v2/open/aigc/batch` | Query Task (up to 100 )|
| GET | `/api/v2/open/balance` | Query Account Balance |

---

## Create Task

**POST** `/api/v2/open/aigc/{Model}`

**Content-Type**: `application/json`

### Request Parameters

| Parameter | Type | Required | Description |
|------|------|------|------|
| prompt | string | Yes | Prompt, exceeds 2500 characters|
| negativePrompt | string | No | Prompt, exceeds 2500 characters.**onlyText-to-Image**, Description|
| imageUrls | string[] | No | Reference image, supported URL or Base64, single image exceeds 30MB|
| image | string[] | No | `imageUrls`, etc.; when when`imageUrls` as|
| sceneImage | string | No | ScenarioReference image, **only `kling-image-v2.1-ref` supported** |
| styleImage | string | No | Reference image,**only `kling-image-v2.1-ref` supported** |
| elementIds | string[] | No | reference subject ID ( subject asset ), only supported reference subject Model can use|
| resolution | string | No |, value rangeModel, Capability|
| aspectRatio | string | No |:`16:9` / `9:16` / `1:1` / `4:3` / `3:4` / `3:2` / `2:3` / `21:9`, Model supported`auto` |
| n | integer | No | image images, 1-9, default 1.`resultType` as`series` when field no|
| resultType | string | No | `single` (default)/ `series`.onlysupported image Model can use|
| seriesAmount | integer | No | image images, default 4.Model (Capability).only `resultType=series` when|
| refImageIds | string[] | No | and`imageUrls` asset, Prompt`@localized example text` localized example text.**only Kling 4.0 imagesupported** |
| styleRefImage | string | No | Reference image,**only `kling-image-v4-long` supported**, up to 1 images|
| subjectRefImage | string | No | subject Reference image,**only `kling-image-v4-long` supported**, up to 1 images|
| skill | string | No | image Type:`webpage` /`ecommerce` localized example text.**`kling-image-v4-long` Required**, Model can|
| length | string | No |:`short` / `medium` / `long`, **only `kling-image-v4-long` supported** |
| callbackUrl | string | No | Callback notification URL after the task is complete |
| taskNickname | string | No | task, in|

### localized example text`negativePrompt`

Promptonly in**Text-to-Image** (not Reference image) when.Reference image when field will,**will**.when, recommended`prompt`.

supported`negativePrompt` Model:`kling-image-v3`, `kling-image-v2.1`.Model supported Parameter.

### localized example text`refImageIds` (Kling 4.0 image)

Kling 4.0 imagesupported in Prompt`@localized example text` images Reference image, image Scenario:```json
{
 "prompt": "localized example text@person localized example text@scene Scenario",
 "imageUrls": ["https://example.com/person.png", "https://example.com/scene.png"],
 "refImageIds": ["person", "scene"]
}
  • refImageIds andimageUrls, in task.
  • If omitted refImageIds when asset will and, no in Prompt.

image (kling-image-v4-long)

imageimages image, multiple imagesimage.

skilllocalized example textReference imagelength
webpageimageOptional, supportedstyleRefImage reference,subjectRefImage subjectlocalized example text
ecommercelocalized example textrecommendedprovide 1-3 images imageshort 2-5,medium 6-10,long 11-18
  • skill as Required, If omitted will return ParameterError.
  • output 1 images,n > 1 andseriesAmount.
  • withaspectRatio Parameter, localized example textskill and.

Response Parameters

ParameterTypeDescription
codeintStatus Code, 0 indicates success
msgstringMessage
data.taskIdstringTask ID, used to query task status
data.statusstringTask Status, task bookingSuccessasprocessing
data.createdAtstringCreated Time

Response Example

Success

{
 "code": 0,
 "msg": "success",
 "data": {
 "taskId": "task_20261120182953_bx5gm0k5",
 "status": "processing",
 "createdAt": "2026-11-20 18:29:53"
 }
}

ParameterError (supported )

{
 "code": 10002,
 "msg": "Model supported, Optional: 2k / 4k / 8k",
 "data": null
}

ParameterError (image supported multiple images)

{
 "code": 10002,
 "msg": "Modelonly 1 images image",
 "data": null
}
image images returned when applicable10002, Errorwill Model range (kling-image-v3-omni as 2-9,kling-image-v4 as 2-10).

Query Task Status

GET /api/v2/open/aigc/{taskId}

Response Example

in

{
 "code": 0,
 "msg": "success",
 "data": {
 "taskId": "task_20261120182953_bx5gm0k5",
 "status": "processing",
 "createdAt": "2026-11-20 18:29:53",
 "updatedAt": "2026-11-20 18:29:55"
 }
}

Success

{
 "code": 0,
 "msg": "success",
 "data": {
 "taskId": "task_20261120182953_bx5gm0k5",
 "status": "success",
 "result": [
 "https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/2026/11/20/output_001.png",
 "https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/2026/11/20/output_002.png"
 ],
 "createdAt": "2026-11-20 18:29:53",
 "updatedAt": "2026-11-20 18:30:41"
 }
}

status:processing in /success Success / failed Failure.FailurewhenerrorMsg localized example text.


Batch Query Task Status

POST /api/v2/open/aigc/batch

up to query 100 task.


Callback Notification

Create TaskwhencallbackUrl, task(Success or Failure) will POST Request.

Headers

Content-Type: application/json
X-Funcloud-Event: task.completed
X-Funcloud-Signature: {localized example text}

Body

{
 "event": "task.completed",
 "taskId": "task_20261120182953_bx5gm0k5",
 "status": "success",
 "result": ["https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/output_001.png"],
 "errorMsg": "",
 "timestamp": "2026-11-20T18:30:41+08:00",
 "signature": "a1b2c3d4e5f6..."
}

Billing

image images, Model and.

images:Scenarioimages
imagen (If omitted 1)
image (resultType=series)seriesAmount (If omitted 4)
image (kling-image-v4-long)as 1
imagen and,seriesAmount and——,.

when images, taskSuccess after, Failure.localized example text.


Error Codes

codeDescription
0Success
10002Parametermissing or malformed
10005API Key invalid or missing
30003Task not found
40001Insufficient balance
60001Model not
90003Internal server error

Best Practices

1. Polling Strategy

  • First 30 seconds:query every 3 seconds
  • After 30 seconds:query every 5 seconds

recommendedCallback NotificationPolling.

2. Modellocalized example text| localized example text| Model| |------|---------| | Text-to-Image / image reference| kling-image-v3 | | image reference+ image| kling-image-v3-omni | | height (8K)| kling-image-v4 | | image, Prompt asset| kling-image-v4 | | subject+ Scenario + Reference image| kling-image-v2.1-ref | | / image| kling-image-v4-long |

Updated 2026-11-20