AI image generation supporting text-to-image, image-to-image, multi-image reference, style transfer, and image expand.
Add Authorization header with Bearer token to all requests:
Authorization: Bearer YOUR_API_KEY
| Model | API Name | Operations | Price (90% off) |
|---|---|---|---|
| Kling V2 | kling-v2 | text2img / img2img / multi-img | 0.076 / 0.151 / 0.302 |
| Kling V2 New | kling-v2-new | Style transfer img2img | 0.151 |
| Kling V2.1 | kling-v2-1 | text2img / multi-img | 0.076 / 0.302 |
| Kling V3 Image | kling-v3-image | text2img / img2img (1K/2K) | 0.151 |
| Kling Multi-Image | kling-multi-image | Multi-image reference | 0.302 |
| Kling Expand | kling-expand | Image outpainting | 0.151 |
| Kling Omni-Image | kling-image-o1 | text2img / img editing / multi-img (1K/2K) | 1.80 |
| Model | Operation | Credits/image |
|---|---|---|
kling-v2 | text2img | 0.076 |
kling-v2 | img2img | 0.151 |
kling-v2 | multi-img | 0.302 |
kling-v2-new | Style transfer img2img | 0.151 |
kling-v2-1 | text2img | 0.076 |
kling-v2-1 | multi-img | 0.302 |
kling-v3-image | text2img / img2img (1K/2K) | 0.151 |
kling-multi-image | Multi-image reference | 0.302 |
kling-expand | Image outpainting | 0.151 |
kling-image-o1 | text2img / img editing / multi-img (1K/2K) | 1.80 |
/api/v1/images/generationsCreate a Kling image generation task. Routes to text-to-image, image-to-image, multi-image reference, style transfer, or image expand based on the model parameter.
/api/v1/images/generations?task_id=xxxQuery task status and get image URL
curl -X POST https://apimodels.app/api/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
}'{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "pending",
"model": "kling-image-gen/kling-v3"
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "completed",
"model": "kling-image-gen/kling-v3",
"resultUrls": ["https://...image.png"],
"createTime": 1705123450000,
"completeTime": 1705123500000
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "failed",
"model": "kling-image-gen/kling-v3",
"failMsg": "Content policy violation"
}
}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.
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 | "string",
"failMsg": null | "string",
"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.
{
"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.
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
})pendingTask queued, waiting to processprocessingImage is being generatedcompletedImage generation successfulfailedImage generation failed400Bad Request - Missing or invalid parameters401Unauthorized - Invalid API key402Payment Required - Insufficient credits404Not Found - Task ID not found500Internal Server Error