APIMODELSAPIMODELS
Документация API

apimodels.app

Docs/Kling Image API
KI

Kling Image API

AI image generation supporting text-to-image, image-to-image, multi-image reference, and style transfer.

Quick Start

1
Get your API key from the Console
2
Choose a Kling image model
3
Send POST request to create task
4
Poll GET request for image result

Authentication

Add Authorization header with Bearer token to all requests:

Authorization: Bearer YOUR_API_KEY

Available Models

ModelAPI NameOperationsPrice (up to 60% off)
Kling V2kling-v2text2img / img2img / multi-img0.076 / 0.151 / 0.302
Kling V2 Newkling-v2-newStyle transfer img2img0.151
Kling V2.1kling-v2-1text2img / multi-img0.076 / 0.302
Kling V3 Imagekling-v3-imagetext2img / img2img (1K/2K)0.151
Kling Multi-Imagekling-multi-imageMulti-image reference0.302
Kling Omni-Imagekling-image-o1text2img / img editing / multi-img (1K/2K)1.80

Pricing (up to 60% off)

ModelOperationCredits/image
kling-v2text2img0.076
kling-v2img2img0.151
kling-v2multi-img0.302
kling-v2-newStyle transfer img2img0.151
kling-v2-1text2img0.076
kling-v2-1multi-img0.302
kling-v3-imagetext2img / img2img (1K/2K)0.151
kling-multi-imageMulti-image reference0.302
kling-image-o1text2img / img editing / multi-img (1K/2K)1.80

Endpoints

POST/api/v1/images/generations

Create a Kling image generation task. Routes to text-to-image, image-to-image, multi-image reference, or style transfer based on the model parameter.

GET/api/v1/images/generations?task_id=xxx

Query task status and get image URL

Request Parameters

Text-to-Image / Image-to-Image

modelrequiredstring
"kling-v2", "kling-v2-1", "kling-v3-image", "kling-image-o1", etc.
promptrequiredstring
Text prompt, max 2500 characters (required for text-to-image)
image_urlstring
Reference image URL for image-to-image
negative_promptstring
Negative prompt
image_referencestring
"subject" or "face"
image_fidelitynumber
Image fidelity [0, 1]
human_fidelitynumber
Human fidelity [0, 1]
resolutionstring
"1k" or "2k"
nnumber
Number of images, 1-9, default 1
aspect_ratiostring
"16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9"
callback_urlstring
Webhook URL for completion notification

Multi-Image Reference (kling-multi-image)

modelrequiredstring
"kling-multi-image"
multi_model_namestring
"kling-v2" or "kling-v2-1", default "kling-v2-1"
subject_image_listrequiredarray
Array of { subject_image: "url" }, max 4 images
scene_imagestring
Scene reference image URL
style_imagestring
Style reference image URL
promptstring
Text prompt
nnumber
Number of images, 1-9, default 1
aspect_ratiostring
"16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9"
callback_urlstring
Webhook URL for completion notification

Code Examples

curl -X POST https://api.apimodels.app/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v3-image",
    "prompt": "A majestic snow-capped mountain at sunrise with golden light",
    "aspect_ratio": "16:9",
    "resolution": "2k",
    "n": 1
  }'

Response Format

Create Task Response

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "clxxx...",
    "state": "pending",
    "model": "kling-image-gen/kling-v3"
  }
}

Success Response

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "clxxx...",
    "state": "completed",
    "model": "kling-image-gen/kling-v3",
    "resultUrls": ["https://...image.png"],
    "createTime": 1705123450000,
    "completeTime": 1705123500000
  }
}

Failed Response

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "clxxx...",
    "state": "failed",
    "model": "kling-image-gen/kling-v3",
    "failMsg": "Content policy violation"
  }
}

Webhook Callback (callback_url)

Pass callback_url in the create request. When the task reaches the completed or failed terminal state, our server sends a single HTTP POST to that URL with Content-Type: application/json (no signing header). Delivery is retried up to 3 times (exponential backoff 1s/2s/4s, 10s per attempt); if still unsuccessful, a background job keeps retrying for up to 30 minutes until your endpoint returns 2xx.

Payload Structure

POST {your callback_url}
Content-Type: application/json

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "clxxx...",
    "model": "kling-image-gen/kling-v3",
    "state": "completed" | "failed",
    "param": "<JSON string>",            // request params, JSON.parse once
    "resultJson": "<JSON string> | null", // result object, JSON.parse once
    "failCode": null | "CONTENT_MODERATION | INVALID_INPUT | INSUFFICIENT_BALANCE | UPSTREAM_BUSY | UPSTREAM_FAILED | TIMEOUT | INTERNAL_ERROR | OTHER",
    "failMsg": null | "string",
    "retryable": true | false,           // present when state=failed: safe to retry/fallback
    "costTime": 12345,                    // duration in ms
    "completeTime": 1705123500000,        // ms epoch
    "createTime": 1705123450000           // ms epoch
  }
}

Note: data.param and data.resultJson are both JSON strings — call JSON.parse once on each.

Image task: shape after JSON.parse(data.resultJson)

{
  "resultUrls": [
    "https://r2.apimodels.app/images/xxx.png"
  ]
}

resultUrls is an array of Cloudflare R2-hosted image URLs. Multi-image runs return more than one. When state=failed, resultJson is typically null or {"resultUrls":[]} — do not assume a link is present.

Node.js receiver example

app.post('/webhook/kling-image', express.json(), (req, res) => {
  const { taskId, state, resultJson, failMsg } = req.body.data
  if (state === 'completed') {
    const { resultUrls } = JSON.parse(resultJson)
    console.log('image ready', taskId, resultUrls[0])
  } else {
    console.warn('image failed', taskId, failMsg)
  }
  res.status(200).end()                 // must be 2xx, otherwise we retry
})

Notes

  • -A task stops retrying only after a 2xx response — once delivered it is never pushed again.
  • -Callbacks are not signed today. Embed a random token in your callback_url path and verify it on receipt.
  • -Use a public HTTPS endpoint that responds within 10 seconds (per-attempt timeout).

Task States

pendingTask queued, waiting to process
processingImage is being generated
completedImage generation successful
failedImage generation failed

Error Codes

400Bad Request - Missing or invalid parameters
401Unauthorized - Invalid API key
402Payment Required - Insufficient credits
404Not Found - Task ID not found
500Internal Server Error

Important Notes

  • *Image files are stored for 30 days, download promptly
  • *All prices are per image; multiply by n for total cost
  • *Prompt supports max 2500 characters
  • *Multi-image reference supports up to 4 subject images
  • *Poll every 5-10 seconds to check status
  • *kling-v2-new style transfer resolution matches input image

FAQ

How do I use the Kling image API?

POST /api/v1/images/generations with a Kling model and a prompt (plus reference images for editing), then poll GET ?task_id=. Same endpoint and key as every other image model.