KlingAPI

目前在线的 Kling 视频和 Kling Image 模型共用一个任务接口。表里的两种价格都从目录读取。

# 1. Submit a task (optional: add "webhook_url" with your own HTTPS endpoint)
TASK_ID=$(curl -sS --fail-with-body https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kuaishou/kling-4.0",
    "input": {
      "prompt": "a paper boat on a rainy street, dusk",
      "resolution": "720p",
      "duration": 5
    }
  }' | jq -r .id)

# 2. Poll until status is "succeeded" or "failed" (up to 10 min)
for _ in $(seq 1 200); do
  TASK=$(curl -sS --fail-with-body "https://api.kerox.ai/v1/tasks/$TASK_ID" \
    -H "Authorization: Bearer $KEROX_API_KEY")
  STATUS=$(echo "$TASK" | jq -r .status)
  [ "$STATUS" != "processing" ] && break
  sleep 3
done
echo "$TASK"
[ "$STATUS" = "succeeded" ] || exit 1
# 3. The same object comes back when you poll, and in your webhook
{
  "id": "task_01JD8X9B4Q2M7T8N3K5P6R1S0V",
  "object": "task",
  "model": "kuaishou/kling-4.0",
  "status": "succeeded",
  "outputs": [ { "type": "video", "url": "https://cdn.kerox.ai/t/task_01JD8X9B…/0.mp4" } ],
  "cost": { "currency": "USD", "status": "settled" }
}

这段是视频请求,分辨率 720p,时长 5 秒。只把模型 ID 换成视频那一行。图片那一行会拒绝 duration。

# 1. Submit a task (optional: add "webhook_url" with your own HTTPS endpoint)
TASK_ID=$(curl -sS --fail-with-body https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kuaishou/kling-image-4.0",
    "input": {
      "prompt": "minimalist ceramic vase on warm limestone in morning light"
    }
  }' | jq -r .id)

# 2. Poll until status is "succeeded" or "failed" (up to 10 min)
for _ in $(seq 1 200); do
  TASK=$(curl -sS --fail-with-body "https://api.kerox.ai/v1/tasks/$TASK_ID" \
    -H "Authorization: Bearer $KEROX_API_KEY")
  STATUS=$(echo "$TASK" | jq -r .status)
  [ "$STATUS" != "processing" ] && break
  sleep 3
done
echo "$TASK"
[ "$STATUS" = "succeeded" ] || exit 1
# 3. The same object comes back when you poll, and in your webhook
{
  "id": "task_01JD8X9B4Q2M7T8N3K5P6R1S0V",
  "object": "task",
  "model": "kuaishou/kling-image-4.0",
  "status": "succeeded",
  "outputs": [ { "type": "image", "url": "https://cdn.kerox.ai/t/task_01JD8X9B…/0.png" } ],
  "cost": { "amount": "0.0567", "currency": "USD", "status": "settled" }
}

Kling Image 模型只收提示词,不收 duration。图片模型用这一段请求。

三步接入

  1. 01

    拿 API Key

    登录控制台创建密钥,按需充值($5 起)。

    快速上手
  2. 02

    提交任务

    向 POST /v1/tasks 发送模型 ID 和统一参数,立即拿到任务 ID。

    任务与查询
  3. 03

    查询任务或等 Webhook

    轮询 GET /v1/tasks/{id},或在提交时带上 webhook_url 等待推送结果。

    Webhook

输出示例。

表里这些模型已经存好的示例。这个页面不会发起一次生成。

模型和 API 价格

所有线上模型都通过同一个 POST /v1/tasks 接口调用。

kuaishou/kling-4.0
$0.1570$0.1413 / 秒 · 720p−10%API 文档
kuaishou/kling-4.0-flash
$0.0940$0.0846 / 秒 · 720p−10%API 文档
kuaishou/kling-image-4.0
$0.0630起价 $0.0567 / 张−10%API 文档

划掉的数字是该模型上登记的厂商牌价,旁边是 Kerox 当前公开价。两个数字都在页面渲染时从目录读取。

相关页面。

常见问题

这里没有答案?

这一页有哪些 Kling 模型?

目前在线的 Kling 视频和 Kling Image 模型。完整名单在模型页。

这是厂商自己的 API 主机吗?

不是。你调用的是 Kerox 的 POST /v1/tasks,模型 ID 用表里的 Kling 那一列。

两个价格怎么对?

划掉的是厂商牌价,另一个是 Kerox 公开价。两个都来自目录。

Kling 任务失败还收费吗?

不收。冻结金额全额退回。详见价格和计费。

参数列表在哪?

每个模型的页面在 docs models 一节,从表里链过去。