Skip to main content

Documentation Index

Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Kling 2.1 is a tiered Kuaishou video model for image-to-video generation and master-quality text-to-video generation. Use this page when you are ready to call the API after trying the model in the APIXO playground.
CapabilityValue
Model IDkling-2-1
Modesstandard-image-to-video, pro-image-to-video, master-text-to-video, master-image-to-video
Prompt length1-5000 characters
Duration5 or 10 seconds
Reference imagesNone for master-text-to-video; exactly 1 for standard-image-to-video and master-image-to-video; 1-2 for pro-image-to-video
Aspect ratios16:9, 9:16, 1:1 for master-text-to-video only
Output formatMP4 URLs in resultJson.resultUrls

Endpoint and authentication

Base URL:
https://api.apixo.ai/api/v1
MethodEndpointPurpose
POST/generateTask/kling-2-1Submit a generation task
GET/statusTask/kling-2-1?taskId={taskId}Poll task status and retrieve results
All requests require your APIXO API key:
Authorization: Bearer YOUR_API_KEY
Submit requests also require:
Content-Type: application/json

Copy-paste async quickstart

This minimal request submits a standard image-to-video task and returns a taskId.
curl -X POST "https://api.apixo.ai/api/v1/generateTask/kling-2-1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "standard-image-to-video",
      "prompt": "animate this still life scene with subtle camera movement",
      "duration": 5,
      "image_urls": [
        "https://example.com/source.jpg"
      ]
    }
  }'
Successful response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Save the taskId; you need it to poll for the final result.

Poll for result

curl -X GET "https://api.apixo.ai/api/v1/statusTask/kling-2-1?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Processing response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
Success response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/xxx.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965710132,
    "costTime": 99203
  }
}
Failed response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates upstream policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9203
  }
}
Parse resultJson after state becomes success:
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;

Request body

Standard image-to-video

{
  "request_type": "async",
  "input": {
    "mode": "standard-image-to-video",
    "prompt": "animate this still life scene with subtle camera movement",
    "duration": 5,
    "image_urls": [
      "https://example.com/source.jpg"
    ],
    "negative_prompt": "blur, low quality",
    "cfg_scale": 0.6
  }
}

Pro image-to-video

{
  "request_type": "async",
  "input": {
    "mode": "pro-image-to-video",
    "prompt": "city skyline timelapse from day to night",
    "duration": 10,
    "image_urls": [
      "https://example.com/start.jpg",
      "https://example.com/end.jpg"
    ],
    "cfg_scale": 0.4
  }
}

Master text-to-video

{
  "request_type": "async",
  "input": {
    "mode": "master-text-to-video",
    "prompt": "a futuristic drone flying through neon-lit streets at night",
    "duration": 5,
    "aspect_ratio": "9:16",
    "negative_prompt": "grainy, noisy, static",
    "cfg_scale": 0.3
  }
}

Master image-to-video

{
  "request_type": "async",
  "input": {
    "mode": "master-image-to-video",
    "prompt": "turn this product photo into a premium cinematic reveal",
    "duration": 5,
    "image_urls": [
      "https://example.com/product.jpg"
    ]
  }
}

Parameters

request_type
string
default:"async"
Result delivery mode. Use async for polling with statusTask, or callback for webhook delivery.
callback_url
string
Required when request_type is callback. Must be a public HTTPS URL that can receive the final task payload. See Webhooks.
input
object
required
Kling 2.1 input parameters.

Response format

Submit task response

POST /generateTask/kling-2-1 returns a task ID when the task is accepted:
code
integer
API status code. 200 means the task was accepted.
message
string
Human-readable status message.
data.taskId
string
Unique task identifier used with the status endpoint.

Status response fields

taskId
string
Unique task identifier.
state
string
Current task state: pending, processing, success, or failed.
resultJson
string
JSON string containing the generated video URLs. Present when state is success.
failCode
string
Machine-readable failure code. Present when state is failed.
failMsg
string
Human-readable failure message. Present when state is failed.
createTime
integer
Task creation timestamp in Unix milliseconds.
completeTime
integer
Task completion timestamp in Unix milliseconds. Present after completion.
costTime
integer
Processing duration in milliseconds. Present after successful completion and often present after failure.

Webhook callback mode

Use callback mode when your backend should receive the final result automatically instead of polling.
curl -X POST "https://api.apixo.ai/api/v1/generateTask/kling-2-1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "master-text-to-video",
      "prompt": "a futuristic drone flying through neon-lit streets at night",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }'
The callback payload uses the same unified response format as the status endpoint. See Webhooks for delivery requirements and retry behavior.

Billing

Kling 2.1 is billed per generated video. The selected mode determines the tier, and duration determines the unit price.
ModeTier5 seconds10 seconds
standard-image-to-videoStandard$0.20 / video$0.40 / video
pro-image-to-videoPro$0.35 / video$0.70 / video
master-text-to-videoMaster$1.00 / video$2.00 / video
master-image-to-videoMaster$1.00 / video$2.00 / video
For current route and market comparison pricing, see Pricing.

Latency and polling

Actual latency may vary by prompt complexity, selected tier, input image size, route, and current queue load.
DurationTypical generation timeRecommended first pollPoll interval
5 seconds60s-90s60s after task creation5s-10s
10 seconds90s-120s60s after task creation5s-10s
For production video workloads, use callback mode to avoid frequent polling. Result URLs are stored through APIXO and are generally available for 15 days, so download important outputs promptly.
Rate limits and concurrency can vary by account, API key, and route. If you receive 429, slow down requests and retry with backoff. For account-level details, see System APIs.

Errors and troubleshooting

HTTP errors

CodeMeaningWhat to do
400Invalid request body, missing required field, unsupported mode, or rejected inputFix the request before retrying
401Missing or invalid API keyCheck the Authorization header
402Insufficient balance or quotaAdd balance or switch account/key
403Key or route cannot access the modelCheck permissions and routing settings
429Rate limit or concurrency limit reachedRetry with exponential backoff
500Server errorRetry with backoff
502Upstream service errorRetry with backoff
504Upstream timeoutRetry or use callback mode for long-running jobs

Task failure codes

Exact failCode values can vary because upstream errors are normalized before they are returned.
Fail codeMeaningWhat to do
Missing required parameterA required field such as input, mode, prompt, duration, image_urls, or callback_url is missingAdd the missing field
Invalid parameter typeA field has the wrong JSON typeCheck prompt, duration, image_urls, aspect_ratio, negative_prompt, and cfg_scale
Invalid parameter valueA field has an unsupported valueCheck mode, duration, aspect_ratio, and cfg_scale
Param length exceededPrompt, negative prompt, or image count exceeds the backend limitShorten text or reduce image count
ImageNotAccessAn input image URL could not be fetchedUse a public, direct HTTP(S) image URL
SensitiveContent, PromptInvalid, ProhibitedContentDetected, NSFWPrompt, input image, or output failed safety checksChange the prompt or image
RateLimitedUpstream rate limit was reachedRetry with backoff
TimeoutUpstream service timed outRetry, reduce input complexity, or use callback mode
Unknown errorUpstream service returned an unmapped errorRetry with backoff or contact support with the taskId

Common request issues

SymptomLikely causeFix
mode is rejectedThe mode is missing or not one of the four supported valuesUse standard-image-to-video, pro-image-to-video, master-text-to-video, or master-image-to-video
Text-to-video rejects image_urlsmaster-text-to-video does not allow reference imagesRemove image_urls
Image-to-video rejects the requestRequired image is missing or too many images were sentSend exactly 1 image for standard/master image modes, or 1-2 images for pro mode
aspect_ratio appears ignoredThe field only applies to master-text-to-videoUse master-text-to-video when aspect ratio control is required
Image URL fails before generationThe backend validates public URL reachabilityUse a direct, reachable HTTP(S) URL and avoid private or localhost links
See Error Codes for the full error reference.