> ## 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 2.6

> Kling 2.6 v2 文生视频、图生视频和任务查询 API。

Kling 2.6 使用模型专属的 v2 路径。不要发送 `model_name`、`mode` 或顶层字符串 `duration`。

> [tab] 文生视频
>
> ## 创建任务
>
> `POST /kling/v2/text-to-video/kling-2.6`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url https://www.anyfast.ai/kling/v2/text-to-video/kling-2.6 \
>   --header 'Authorization: Bearer YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "prompt": "一艘纸船穿过雨后的街道",
>     "settings": {"resolution": "720p", "duration": 5, "aspect_ratio": "16:9"}
>   }'
> ```
>
> ## 请求体
>
> **prompt** `string` *required*
>
> 视频描述。
>
> **settings** `object`
>
> 输出设置。
>
> **settings.resolution** `string`
>
> `720p` 或 `1080p`。
>
> **settings.duration** `integer`
>
> 数字类型的时长。使用 5 或 10 秒。
>
> **settings.aspect\_ratio** `string`
>
> `16:9`、`9:16` 或 `1:1`。
>
> ## 创建响应
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "request_id": "REQUEST_ID",
>   "data": {
>     "id": "TASK_ID",
>     "status": "submitted",
>     "create_time": 1781080778802,
>     "update_time": 1781080778802,
>     "external_id": "client-motion-task"
>   }
> }
> ```
>
> **data.id** `string`
>
> 用于统一查询接口的系统任务 ID。
>
> **data.status** `string`
>
> `submitted`、`processing`、`succeeded` 或 `failed`。

> [tab] 图生视频
>
> ## 创建任务
>
> `POST /kling/v2/image-to-video/kling-2.6`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url https://www.anyfast.ai/kling/v2/image-to-video/kling-2.6 \
>   --header 'Authorization: Bearer YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "contents": [
>       {"type": "prompt", "text": "人物转身看向窗外"},
>       {"type": "first_frame", "url": "https://example.com/frame.png"}
>     ],
>     "settings": {"resolution": "720p", "duration": 5}
>   }'
> ```
>
> ## 请求体
>
> **contents** `object[]` *required*
>
> 包含 `prompt` 和 `first_frame` 项。模型和工作流支持时可添加中间帧或尾帧。
>
> **contents\[].type** `string` *required*
>
> 例如 `prompt`、`first_frame`、`middle_frame` 或 `last_frame`。
>
> **contents\[].text** `string`
>
> `prompt` 项的提示词。
>
> **contents\[].url** `string`
>
> 公开图片 URL 或受支持的 Base64 图片。
>
> ## 创建响应
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "request_id": "REQUEST_ID",
>   "data": {"id": "TASK_ID", "status": "submitted"}
> }
> ```
>
> **data.id** `string`
>
> 用于统一查询接口的系统任务 ID。
>
> **data.status** `string`
>
> 初始任务状态。

> [tab] 查询任务
>
> ## 查询任务
>
> `GET /kling/v2/tasks?task_ids=TASK_ID`
>
> ```bash cURL theme={null}
> curl --request GET \
>   --url 'https://www.anyfast.ai/kling/v2/tasks?task_ids=TASK_ID' \
>   --header 'Authorization: Bearer YOUR_API_KEY'
> ```
>
> **task\_ids** `string` *required*
>
> 一个或多个系统任务 ID，用逗号分隔。
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "data": [
>     {
>       "id": "TASK_ID",
>       "status": "succeeded",
>       "outputs": [{"type": "video", "url": "https://example.com/video.mp4", "duration": "5.041"}]
>     }
>   ]
> }
> ```
>
> **data\[].id** `string`
>
> 系统任务 ID。
>
> **data\[].status** `string`
>
> `submitted`、`processing`、`succeeded` 或 `failed`。
>
> **data\[].create\_time** `integer`
>
> 任务创建时间，Unix 毫秒时间戳。
>
> **data\[].update\_time** `integer`
>
> 任务更新时间，Unix 毫秒时间戳。
>
> **data\[].outputs** `object[]`
>
> 生成结果。
>
> **data\[].outputs\[].type** `string`
>
> 结果类型，通常为 `video`。
>
> **data\[].outputs\[].url** `string`
>
> 临时生成视频 URL。
>
> **data\[].outputs\[].duration** `string`
>
> 生成视频时长，单位为秒。

> [tab] 动作控制
>
> ## 创建动作控制任务
>
> 生产环境动作控制使用模型专属的 v2 接口。
>
> `POST /kling/v2/motion-control/kling-2.6`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url https://www.anyfast.ai/kling/v2/motion-control/kling-2.6 \
>   --header 'Authorization: Bearer YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "contents": [
>       {"type": "prompt", "text": "保持人物一致并复现参考动作"},
>       {"type": "image", "url": "https://example.com/character.png"},
>       {"type": "video", "url": "https://example.com/motion.mp4"}
>     ],
>     "settings": {"character_orientation": "video", "audio": "off", "resolution": "720p"},
>     "options": {"external_task_id": "client-motion-task"}
>   }'
> ```
>
> ## 请求体
>
> **contents** `object[]` *required*
>
> 提示词、人物参考图和动作参考视频。
>
> **contents\[].type** `string` *required*
>
> 使用 `prompt`、`image` 或 `video`。
>
> **contents\[].url** `string` *required*
>
> 图片或视频项的公开 URL 或支持的原始 Base64。
>
> **settings.character\_orientation** `string` *required*
>
> 使用 `image` 或 `video`。
>
> **settings.audio** `string` (default: original)
>
> 使用 `original` 或 `off`。
>
> **settings.resolution** `string` (default: 720p)
>
> `720p` 或 `1080p`。
>
> **options.external\_task\_id** `string`
>
> 调用方任务 ID。
>
> **options.callback\_url** `string`
>
> HTTPS 回调地址。
>
> ## 创建响应
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "request_id": "REQUEST_ID",
>   "data": {"id": "TASK_ID", "status": "submitted"}
> }
> ```
>
> **code** `integer`
>
> 响应码；`0` 表示成功。
>
> **message** `string`
>
> 响应消息。
>
> **request\_id** `string`
>
> AnyFast 请求 ID。
>
> **data** `object`
>
> 已提交的动作控制任务。
>
> **data.id** `string`
>
> 用于任务查询接口的系统任务 ID。
>
> **data.status** `string`
>
> 初始任务状态，通常为 `submitted`。
>
> **data.create\_time** `integer`
>
> 任务创建时间，Unix 毫秒时间戳。
>
> **data.update\_time** `integer`
>
> 任务更新时间，Unix 毫秒时间戳。
>
> **data.external\_id** `string`
>
> 调用方提供的任务 ID。
>
> ## 查询响应
>
> 使用 `GET /kling/v2/tasks?task_ids=TASK_ID` 查询。
>
> ```bash cURL theme={null}
> curl --request GET \
>   --url 'https://www.anyfast.ai/kling/v2/tasks?task_ids=TASK_ID' \
>   --header 'Authorization: Bearer YOUR_API_KEY'
> ```
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "data": [
>     {
>       "id": "TASK_ID",
>       "status": "succeeded",
>       "create_time": 1781080778802,
>       "update_time": 1781080794151,
>       "outputs": [
>         {
>           "type": "video",
>           "url": "https://example.com/video.mp4",
>           "duration": "5.041"
>         }
>       ]
>     }
>   ]
> }
> ```
>
> **data\[].id** `string`
>
> 系统任务 ID。
>
> **data\[].status** `string`
>
> `submitted`、`processing`、`succeeded` 或 `failed`。
>
> **data\[].create\_time** `integer`
>
> 任务创建时间，Unix 毫秒时间戳。
>
> **data\[].update\_time** `integer`
>
> 任务更新时间，Unix 毫秒时间戳。
>
> **data\[].outputs** `object[]`
>
> 生成结果。
>
> **data\[].outputs\[].type** `string`
>
> 结果类型，通常为 `video`。
>
> **data\[].outputs\[].url** `string`
>
> 临时生成视频 URL。
>
> **data\[].outputs\[].duration** `string`
>
> 生成视频时长，单位为秒。

> [tab] 主体管理
>
> ## 可复用主体
>
> 通过 v2 资源接口创建和查询可复用主体（Element）：
>
> | 操作 | 接口 |
> | - | - |
> | 创建自定义主体 | `POST /kling/v2/general/advanced-custom-elements` |
> | 查询主体任务 | `GET /kling/v2/general/advanced-custom-elements/{task_id}` |
> | 查询预置主体（旧版） | `GET /kling/v1/general/advanced-presets-elements` |
>
> 成功查询后，从 `data.task_result.elements[].element_id` 读取主体 ID；在支持主体的视频工作流中，将该 ID 放入 `element_list`。
>
> ## 创建自定义主体
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url https://www.anyfast.ai/kling/v2/general/advanced-custom-elements \
>   --header 'Authorization: Bearer YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "element_name": "my-character",
>     "element_description": "A protagonist character",
>     "reference_type": "image_refer",
>     "element_image_list": {"frontal_image": "https://example.com/front.jpg"},
>     "external_task_id": "client-element-task"
>   }'
> ```
>
> **element\_name** `string` *required*
>
> 主体名称。
>
> **element\_description** `string` *required*
>
> 可复用主体描述。
>
> **reference\_type** `string` *required*
>
> 图片参考使用 `image_refer`。
>
> **element\_image\_list** `object` *required*
>
> 主体参考图片。
>
> **element\_image\_list.frontal\_image** `string` *required*
>
> 正面图片公开 URL。
>
> **element\_image\_list.refer\_images\[].image\_url** `string`
>
> 额外参考图片 URL。
>
> ## 创建响应
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "data": {"task_id": "TASK_ID", "task_status": "submitted"}
> }
> ```
>
> **data.task\_id** `string`
>
> 主体任务 ID。
>
> **data.task\_status** `string`
>
> 初始状态，通常为 `submitted`。
>
> ## 查询响应
>
> 使用 `GET /kling/v2/general/advanced-custom-elements/TASK_ID` 查询；成功结果中的 `element_id` 为字符串。
>
> ```bash cURL theme={null}
> curl --request GET \
>   --url 'https://www.anyfast.ai/kling/v2/general/advanced-custom-elements/TASK_ID' \
>   --header 'Authorization: Bearer YOUR_API_KEY'
> ```
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "data": {
>     "task_id": "TASK_ID",
>     "task_status": "succeed",
>     "task_result": {
>       "elements": [
>         {
>           "element_id": "ELEMENT_ID",
>           "element_name": "my-character",
>           "element_description": "A protagonist character",
>           "element_type": "image_refer"
>         }
>       ]
>     }
>   }
> }
> ```
>
> **data.task\_id** `string`
>
> 主体任务 ID。
>
> **data.task\_status** `string`
>
> 主体任务状态。
>
> **data.task\_result** `object`
>
> 已完成的主体结果。
>
> **data.task\_result.elements\[]** `object[]`
>
> 可复用主体结果列表。
>
> **data.task\_result.elements\[].element\_id** `string`
>
> 处理完成后返回的可复用主体 ID。
>
> **data.task\_result.elements\[].element\_name** `string`
>
> 主体名称。
>
> **data.task\_result.elements\[].element\_description** `string`
>
> 主体描述。
>
> **data.task\_result.elements\[].element\_type** `string`
>
> 创建主体时使用的参考类型。

> [tab] 音色管理
>
> ## 可复用音色
>
> 生产环境使用 v2 接口创建和查询可复用音色，然后将返回的 `voice_id` 放入 `voice_list`，并在提示词中使用 `<<<voice_1>>>` 或 `<<<voice_2>>>` 引用。
>
> | 操作 | 接口 |
> | - | - |
> | 创建自定义音色（当前） | `POST /kling/v2/general/custom-voices` |
> | 查询自定义音色（当前） | `GET /kling/v2/general/custom-voices/{id}` |
> | 创建自定义音色（旧版） | `POST /kling/v1/general/custom-voices` |
> | 查询自定义音色（旧版） | `GET /kling/v1/general/custom-voices/{id}` |
> | 查询预置音色（旧版） | `GET /kling/v1/general/presets-voices?pageNum=1&pageSize=30` |
>
> > 预置音色列表目前仍使用官方 v1 接口；v2 接口用于自定义音色创建和查询。
>
> Kling 2.6 最多支持两个音色；使用音色时需要启用音频开关。
>
> ## 创建自定义音色
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url https://www.anyfast.ai/kling/v2/general/custom-voices \
>   --header 'Authorization: Bearer YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{"voice_name":"Narrator","voice_url":"https://example.com/voice.mp3"}'
> ```
>
> **voice\_name** `string` *required*
>
> 自定义音色名称。
>
> **voice\_url** `string` *required*
>
> 音色样本公开 URL。
>
> ## 创建响应
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "data": {"task_id": "TASK_ID", "task_status": "submitted"}
> }
> ```
>
> **data.task\_id** `string`
>
> 自定义音色任务 ID。
>
> **data.task\_status** `string`
>
> 初始状态，通常为 `submitted`。
>
> ## 查询响应
>
> 使用 `GET /kling/v2/general/custom-voices/TASK_ID` 查询。
>
> ```bash cURL theme={null}
> curl --request GET \
>   --url 'https://www.anyfast.ai/kling/v2/general/custom-voices/TASK_ID' \
>   --header 'Authorization: Bearer YOUR_API_KEY'
> ```
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "data": {
>     "task_id": "TASK_ID",
>     "task_status": "succeed",
>     "task_result": {
>       "voices": [
>         {
>           "voice_id": "VOICE_ID",
>           "voice_name": "Narrator",
>           "trial_url": "https://example.com/trial.mp3",
>           "owned_by": "self",
>           "status": "succeed"
>         }
>       ]
>     }
>   }
> }
> ```
>
> **data.task\_id** `string`
>
> 自定义音色任务 ID。
>
> **data.task\_status** `string`
>
> 自定义音色任务状态。
>
> **data.task\_result** `object`
>
> 已完成的音色结果。
>
> **data.task\_result.voices\[]** `object[]`
>
> 可复用音色结果列表。
>
> **data.task\_result.voices\[].voice\_id** `string`
>
> 可复用音色 ID。
>
> **data.task\_result.voices\[].voice\_name** `string`
>
> 音色名称。
>
> **data.task\_result.voices\[].trial\_url** `string`
>
> 试听音频 URL。
>
> **data.task\_result.voices\[].owned\_by** `string`
>
> 音色所有者或提供方。
>
> **data.task\_result.voices\[].status** `string`
>
> 音色处理状态。
>
> 旧版接入仍可使用 `POST /kling/v1/general/custom-voices` 和 `GET /kling/v1/general/custom-voices/{id}`；预置音色仍通过上表中的 v1 接口查询。
>
> ## 查询预置音色
>
> ```bash cURL theme={null}
> curl --request GET \
>   --url 'https://www.anyfast.ai/kling/v1/general/presets-voices?pageNum=1&pageSize=30' \
>   --header 'Authorization: Bearer YOUR_API_KEY'
> ```
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "SUCCEED",
>   "request_id": "REQUEST_ID",
>   "data": [
>     {
>       "task_id": "PRESET_TASK_ID",
>       "task_status": "succeed",
>       "task_result": {
>         "voices": [
>           {
>             "voice_id": "PRESET_VOICE_ID",
>             "voice_name": "Warm narrator",
>             "trial_url": "https://example.com/preset.mp3",
>             "owned_by": "vod",
>             "status": "succeed"
>           }
>         ]
>       }
>     }
>   ]
> }
> ```
>
> **code** `integer`
>
> 响应码；`0` 表示成功。
>
> **message** `string`
>
> 响应消息。
>
> **request\_id** `string`
>
> AnyFast 请求 ID。
>
> **data** `object[]`
>
> 预置音色任务记录。
>
> **data\[].task\_id** `string`
>
> 预置音色任务 ID。
>
> **data\[].task\_status** `string`
>
> 预置音色任务状态。
>
> **data\[].task\_result** `object`
>
> 预置音色结果。
>
> **data\[].task\_result.voices\[]** `object[]`
>
> 任务返回的预置音色列表。
>
> **data\[].task\_result.voices\[].voice\_id** `string`
>
> 预置音色 ID。
>
> **data\[].task\_result.voices\[].voice\_name** `string`
>
> 预置音色名称。
>
> **data\[].task\_result.voices\[].trial\_url** `string`
>
> 试听音频 URL。
>
> **data\[].task\_result.voices\[].owned\_by** `string`
>
> 音色所有者或提供方。
>
> **data\[].task\_result.voices\[].status** `string`
>
> 音色状态。

## 扩展能力参数

**negative\_prompt** `string`

需要避免的内容，最多 2,500 个字符。

**settings.sound** `string`

支持原生音频的请求通道中的音频开关；使用音色时应启用音频。

**voice\_list\[].voice\_id** `string`

Voice Management 返回的音色 ID。最多使用两个音色，并按提示词顺序引用。

**camera\_control.type** `string`

`simple`、`down_back`、`forward_up`、`right_turn_forward` 或 `left_turn_forward`。

**camera\_control.config** `object`

`simple` 模式下在 `horizontal`、`vertical`、`pan`、`tilt`、`roll`、`zoom` 中设置一个非零值，范围为 -10 到 10。

**dynamic\_masks\[].mask** `string`

运动笔刷遮罩的 URL 或支持的原始 Base64。

**dynamic\_masks\[].trajectories** `object[]`

动态遮罩轨迹点；5 秒输出时每个遮罩支持 2–77 个点。

**element\_list\[].element\_id** `string`

Element Management 返回的可复用元素 ID。

### 输入与组合规则

图片支持 JPG、JPEG、PNG，最大 10 MB，宽高均至少 300 像素，宽高比为 1:2.5 至 2.5:1。尾帧、运动笔刷和镜头控制不能同时使用。动作控制使用一张人物图和一个参考视频；参考视频至少 3 秒，人物图朝向时最长 10 秒，视频朝向时最长 30 秒。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.