> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyfast.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# kling-v2-1

> Kling 2.1 图生视频旧版 API。

## 图生视频

### 创建任务

`POST /kling/v1/videos/image2video`

<div className="kling-api-example-panel">
  ```bash cURL theme={null}
  curl --request POST \
    --url https://www.anyfast.ai/kling/v1/videos/image2video \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "model_name": "kling-2.1",
      "image": "https://example.com/start.png",
      "image_tail": "https://example.com/end.png",
      "prompt": "人物转身并露出微笑",
      "negative_prompt": "模糊，变形",
      "duration": "5",
      "mode": "pro",
      "watermark_info": {"enabled": false}
    }'
  ```

  ```json 200 theme={null}
  {"id":"860260753860210752","task_id":"860260753860210752","object":"video","model":"kling-v2-1","status":"","progress":0,"created_at":1773130665}
  ```
</div>

## 请求体

<ParamField body="model_name" type="string" required>固定为 `kling-2.1`。</ParamField>
<ParamField body="image" type="string" required>首帧图片 URL 或原始 Base64。</ParamField>
<ParamField body="image_tail" type="string">可选尾帧；首尾帧生成仅支持 1080p `pro` 模式。</ParamField>
<ParamField body="prompt" type="string">正向提示词，最长 2500 字符。</ParamField>
<ParamField body="negative_prompt" type="string">负向提示词，最长 2500 字符。</ParamField>
<ParamField body="mode" type="string" default="std">`std` 为 720p，`pro` 为 1080p。</ParamField>
<ParamField body="duration" type="string" default="5">可选 `5` 或 `10` 秒。</ParamField>
<ParamField body="watermark_info" type="object">通过 `enabled` 控制是否同时生成含水印结果。</ParamField>

### 图片要求

支持公开 URL 或不含 data URI 前缀的原始 Base64。支持 JPG、JPEG、PNG；文件不超过 10 MB，宽高均不小于 300 px，宽高比为 1:2.5 到 2.5:1。

## 查询任务（单个）

`GET /kling/v1/videos/image2video/{task_id}`

```bash cURL theme={null}
curl --request GET \
  --url https://www.anyfast.ai/kling/v1/videos/image2video/TASK_ID \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

<ParamField path="task_id" type="string" required>创建接口返回的任务 ID。</ParamField>

任务状态为 `submitted`、`processing`、`succeed` 或 `failed`。成功结果位于 `data.task_result.videos`，失败原因位于 `data.task_status_msg`；视频项包含 `id`、`url`、`watermark_url` 和 `duration`。

```json 200 theme={null}
{
  "code": 0,
  "message": "SUCCEED",
  "request_id": "request-id",
  "data": {
    "task_id": "task-id",
    "task_status": "succeed",
    "task_status_msg": "",
    "watermark_info": {"enabled": false},
    "task_result": {"videos": [{"id": "video-id", "url": "https://example.com/result.mp4", "watermark_url": "", "duration": "5"}]},
    "final_unit_deduction": "string",
    "final_balance_deduction": {"quota": "string", "list_price": "string"},
    "created_at": 1722769557708,
    "updated_at": 1722769657708
  }
}
```

<Warning>生成结果 URL 会在 30 天后清理，请及时转存。</Warning>

<Note>Kling 2.1 不提供文生视频，也不支持音频、指定音色、多镜头、运动笔刷、运镜控制和 `cfg_scale`。</Note>

<script src="/feedback.js" />
