Overview
Generate high-fidelity images with Kling using prompt, aspect ratio, resolution, and optional reference-image controls.
Primary Endpoint
/api/v1/userKlingImage/startCreate asynchronous Kling Image tasks. Omitted model preserves Kling Image 3.0. Kling Image 4.0 supports independent images (single, n=1–9), connected series (series, series_amount=2–10), ecommerce long images and webpage long images. A 4.0 request creates one task containing all outputs in order; 3.0 creates one task per image. Reference IDs are image_1, image_2, etc., usable as @image_1 in the prompt. 4.0 pricing = reference count × configured input-image rate + output count × configured output rate (resolution and long-image type/length select the rate). Series use series_amount; long images always output one image. Quotes and charging use the same configured rates. Any generation failure follows the existing full-task refund flow. All outputs are transferred to storage. 4.0 negative instructions belong in prompt; negative_prompt is supported by 3.0 only. Actual media size, dimensions, duration, format and applicable frame-rate limits are checked against the selected provider interface before charging or creating any task. Client metadata is not authoritative. Invalid or unreadable media returns HTTP 400 with the failing field, measured value and expected range; direct API requests are not automatically resized or transcoded and do not inherit lower website upload limits. Media inspection errors preserve HTTP status and business code: 400 INVALID_MEDIA for confirmed invalid media, 400 MEDIA_RESOURCE_UNAVAILABLE for inaccessible or expired sources, 400 MEDIA_PROBE_LIMIT for the server source inspection budget, 429 MEDIA_PROBE_BUSY for local queue saturation, 503 MEDIA_PROBE_UNAVAILABLE for transient network/upstream failures, 504 MEDIA_PROBE_TIMEOUT for inspection timeouts, and 500 MEDIA_PROBE_FAILED for internal processing failures. All media checked for this request share a 280-second deadline, including queueing, Range probing and full-download fallback. Even valid assets can exceed this processing deadline. Timeout cancels remaining inspection and cleanup completes before returning; no automatic retry, charge, task creation or generation-provider submission occurs on failed inspection. ### Request - Send a valid bearer token. The server evaluates the operation in the authenticated caller's access context. - Send an `application/json` body. Required fields: `name`, `prompt`. - API-token callers may include `webhook_url` and `webhook_token` for best-effort terminal-state notifications; ordinary JWT/cookie calls ignore these fields. ### Behavior - This is an asynchronous operation: a successful submission creates a task and returns before processing finishes. - Persist the returned task identifier and use the corresponding detail or list operation to observe progress. - Treat the detail endpoint as the source of truth even when webhook delivery is enabled. ### Response - A `200` response confirms task acceptance; it does not by itself mean media generation has completed. - Retain the returned identifier and wait for a documented terminal status before using output URLs. - JSON object responses, including error responses, normally carry a top-level `trace_id` string for this request; include it when contacting support. It is not a task identifier. - Do not infer undocumented fields or statuses; clients should tolerate additional response properties. ### Errors - `401` — Unauthorized - Invalid or missing JWT token. - `422` — Content moderation rejected the `input_images`. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`. - `429` — MEDIA_PROBE_BUSY - Local media inspection queue is full or its wait deadline elapsed. - `500` — MEDIA_PROBE_FAILED - Internal media inspection failure; not a media specification violation. - `503` — MEDIA_PROBE_UNAVAILABLE (transient media inspection failure, retry allowed). - `504` — MEDIA_PROBE_TIMEOUT - Media connection, download, inspection or the shared 280-second request inspection deadline elapsed; retry is allowed. This is a processing timeout, not a media specification violation. ### Related Operations - `GET /api/v1/userKlingImage/list` — List Kling image tasks. - `GET /api/v1/userKlingImage/detail/{id}` — Get Kling image task details. - `DELETE /api/v1/userKlingImage/{id}` — Delete a Kling image task. Authentication: set header Authorization: Bearer <token> (supports user JWT or sk_ API token).
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ai_sharing_consent | object | No | Consent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged. |
| ai_sharing_consent.version | enum: 2026-11-12 | Yes | - |
| ai_sharing_consent.recipients | array<string> | Yes | - |
| name | string | Yes | Task name |
| prompt | string | Yes | Image generation prompt. For 4.0 single/series, English characters/50000 + non-English characters/21000 must be at most 1; long images use divisors 166000 and 71000. |
| model | enum: kling-image-3.0 | kling-image-4.0 | No | Select the model; omitted model keeps the 3.0 behavior.; default: "kling-image-3.0" |
| creation_mode | enum: text-to-image | image-edit | No | Optional compatibility field for history and mode reporting; callers may omit it. The server ignores any supplied value and records `image-edit` when `input_images` contains a valid HTTP(S) image URL, otherwise `text-to-image`. It is not forwarded to the model provider. |
| input_images | array<string> | No | Public reference image URLs. 3.0 accepts up to 1. 4.0 single/series accept up to 10 JPG/JPEG/PNG images, each at most 30 MB, both sides at least 300 px, aspect ratio 2:5–5:2. Ecommerce requires 1–3. Webpage accepts at most 2, one subject and one style reference; webpage_reference_type selects the first image role, and the second uses the other role. |
| aspect_ratio | enum: auto | 1:1 | 16:9 | 9:16 | 4:3 | 3:4 | 2:3 | 3:2 | 21:9 | No | Defaults to 9:16 for 3.0, auto for 4.0. Long images do not forward aspect_ratio. |
| resolution | enum: 1k | 2k | 4k | 8k | No | 3.0 supports 1k/2k, default 1k. 4.0 single/series support 2k/4k/8k, default 2k. Long images support 1k/2k, default 1k. |
| n | integer | No | Independent image count. Must be 1 for series and long images.; minimum: 1; maximum: 9 |
| output_type | enum: single | series | ecommerce | webpage | No | 4.0 output type; 3.0 accepts single only. Ecommerce requires 1–3 reference images. Webpage accepts 0–2. Long images produce one flattened image, not HTML.; default: "single" |
| webpage_reference_type | enum: subject_refer_image | style_refer_image | No | Role of the first webpage reference. If a second image is supplied, its role is the other type. Each role allows at most one image. Ignored outside webpage output.; default: "subject_refer_image" |
| series_amount | integer | No | Fixed connected-series image count. Auto count is not supported by this API so the price is known before charging.; minimum: 2; maximum: 10; default: 4 |
| length | enum: short | medium | long | No | Ecommerce long-image length. Not forwarded for other output types.; default: "medium" |
| minor_suspected_skip | boolean | No | Confirm retry after the suspected-minor soft block; hard blocks remain enforced.; default: false |
| webhook_url | string | No | HTTPS URL to receive task.completed / task.failed notifications. Best-effort delivery, single attempt, no retries; clients should treat the detail API as the source of truth.; maxLength: 2048 |
| webhook_token | string | No | Optional plaintext token returned in the X-A2e-Webhook-Token header so receivers can verify the request originated from a2e.; maxLength: 256 |
Request schema and conditional rules
{
"allOf": [
{
"type": "object",
"properties": {
"ai_sharing_consent": {
"type": "object",
"description": "Consent receipt for newer native apps. Legacy native requests may omit this field and continue without a consent record. If present, null, malformed, expired or incomplete receipts return AI_SHARING_CONSENT_REQUIRED before generation. Valid receipts cover all actual AI recipients, including safety providers and intermediaries, and constrain later fallback. Content safety checks remain required for native requests. Web and legacy API behavior is unchanged.",
"required": [
"version",
"recipients"
],
"properties": {
"version": {
"type": "string",
"enum": [
"2026-11-12"
]
},
"recipients": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"A2E",
"Alibaba Cloud",
"Kuaishou"
]
}
}
},
"name": {
"type": "string",
"description": "Task name"
},
"prompt": {
"type": "string",
"description": "Image generation prompt. For 4.0 single/series, English characters/50000 + non-English characters/21000 must be at most 1; long images use divisors 166000 and 71000."
},
"model": {
"type": "string",
"enum": [
"kling-image-3.0",
"kling-image-4.0"
],
"default": "kling-image-3.0",
"description": "Select the model; omitted model keeps the 3.0 behavior."
},
"creation_mode": {
"type": "string",
"enum": [
"text-to-image",
"image-edit"
],
"description": "Optional compatibility field for history and mode reporting; callers may omit it. The server ignores any supplied value and records `image-edit` when `input_images` contains a valid HTTP(S) image URL, otherwise `text-to-image`. It is not forwarded to the model provider."
},
"input_images": {
"type": "array",
"items": {
"type": "string"
},
"description": "Public reference image URLs. 3.0 accepts up to 1. 4.0 single/series accept up to 10 JPG/JPEG/PNG images, each at most 30 MB, both sides at least 300 px, aspect ratio 2:5–5:2. Ecommerce requires 1–3. Webpage accepts at most 2, one subject and one style reference; webpage_reference_type selects the first image role, and the second uses the other role."
},
"aspect_ratio": {
"type": "string",
"enum": [
"auto",
"1:1",
"16:9",
"9:16",
"4:3",
"3:4",
"2:3",
"3:2",
"21:9"
],
"description": "Defaults to 9:16 for 3.0, auto for 4.0. Long images do not forward aspect_ratio."
},
"resolution": {
"type": "string",
"enum": [
"1k",
"2k",
"4k",
"8k"
],
"description": "3.0 supports 1k/2k, default 1k. 4.0 single/series support 2k/4k/8k, default 2k. Long images support 1k/2k, default 1k."
},
"n": {
"type": "integer",
"minimum": 1,
"maximum": 9,
"description": "Independent image count. Must be 1 for series and long images."
},
"output_type": {
"type": "string",
"enum": [
"single",
"series",
"ecommerce",
"webpage"
],
"default": "single",
"description": "4.0 output type; 3.0 accepts single only. Ecommerce requires 1–3 reference images. Webpage accepts 0–2. Long images produce one flattened image, not HTML."
},
"webpage_reference_type": {
"type": "string",
"enum": [
"subject_refer_image",
"style_refer_image"
],
"default": "subject_refer_image",
"description": "Role of the first webpage reference. If a second image is supplied, its role is the other type. Each role allows at most one image. Ignored outside webpage output."
},
"series_amount": {
"type": "integer",
"minimum": 2,
"maximum": 10,
"default": 4,
"description": "Fixed connected-series image count. Auto count is not supported by this API so the price is known before charging."
},
"length": {
"type": "string",
"enum": [
"short",
"medium",
"long"
],
"default": "medium",
"description": "Ecommerce long-image length. Not forwarded for other output types."
},
"minor_suspected_skip": {
"type": "boolean",
"default": false,
"description": "Confirm retry after the suspected-minor soft block; hard blocks remain enforced."
}
},
"required": [
"name",
"prompt"
]
},
{
"$ref": "#/components/schemas/WebhookInput"
}
]
}Response Fields
- code: enum: 0
- data: array<object>
- data[]._id: string
- Task ID for detail and batch polling.
- data[].name: string
- data[].prompt: string
- data[].is_downloaded: boolean
- data[].is_previewed: boolean
- data[].current_status: string
- Persisted task state; use the concrete task family schema for its allowed values and terminal states.
- data[].createdAt: string
- data[].updatedAt: string
- data[].expirationDate: string
- data[].remainingDays: number
- data[].isExpired: boolean
- data[].coins: number
- data[].hasRefundCoin: boolean
- Whether charged credits were refunded.
- data[].failed_code: string
- data[].failed_message: string
- data[].failed_reason: string
- Public failure category when available.
- data[].creation_mode: string
- data[].image_url: string
- data[].image_urls: array<string>
- data[].result_image_url: string
- data[].result_image_urls: array<string>
- data[].input_images: array<string>
- data[].output_type: enum: single | series | ecommerce | webpage
- data[].series_amount: integer
- data[].n: integer
- data[].length: string
- data[].webpage_reference_type: string
- data[].model: enum: kling-image-3.0 | kling-image-4.0
- data[].refund_pending: boolean
- True means refund pending resolution and takes precedence over hasRefundCoin. Explicit false is preserved; omitted when unknown, including legacy records without a stored flag.
- trace_id: string
- Trace ID of this HTTP request. Include it when contacting support about this request. It is generated per request and is not a task identifier; use the returned task `_id` to query results.
Request Example
curl -X POST "https://www.a2e.com.cn/api/v1/userKlingImage/start" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "My Task",
"prompt": "high quality, clear, cinematic"
}'Related Endpoints
/api/v1/userKlingImage/detail/{id}Get Kling image task details
/api/v1/userKlingImage/startStart Kling Image generation
/api/v1/userKlingImage/listList Kling image tasks
/api/v1/userKlingImage/batchDetailBatch get Kling image task details
/api/v1/userKlingImage/{id}Delete a Kling image task
Responses
Task created successfully
Unauthorized - Invalid or missing bearer token
Content moderation rejected the `input_images`. Code `1003` means confirmed minor content. Code `1004` means suspected minor content. For `1004`, confirm the input and retry with `minor_suspected_skip: true`.
MEDIA_PROBE_BUSY - Local media inspection queue is full or its wait deadline elapsed.
MEDIA_PROBE_FAILED - Internal media inspection failure; not a media specification violation.
MEDIA_PROBE_UNAVAILABLE (transient media inspection failure, retry allowed).
MEDIA_PROBE_TIMEOUT - Media connection, download, inspection or the shared 280-second request inspection deadline elapsed; retry is allowed. This is a processing timeout, not a media specification violation.