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

> Kling 2.6 文生视频、图生视频、动作控制和音色管理旧版 API。

<Tabs>
  <Tab title="文生视频">
    ## 创建任务

    `POST /kling/v1/videos/text2video`

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.ai/kling/v1/videos/text2video \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "model_name": "kling-2.6",
          "prompt": "一只柯基在海边日落时奔跑，浪花拍打沙滩",
          "negative_prompt": "模糊，抖动",
          "duration": "5",
          "mode": "pro",
          "sound": "on",
          "aspect_ratio": "16:9",
          "watermark_info": {"enabled": false}
        }'
      ```

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

    ## 请求头

    <ParamField header="Authorization" type="string" required>Bearer 身份验证，格式为 `Bearer YOUR_API_KEY`。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>固定为 `application/json`。</ParamField>

    ## 请求体

    <ParamField body="model_name" type="string" required>固定为 `kling-2.6`。</ParamField>
    <ParamField body="prompt" type="string" required>正向提示词，最长 2500 字符。</ParamField>
    <ParamField body="negative_prompt" type="string">不希望出现在视频中的内容，最长 2500 字符。</ParamField>
    <ParamField body="voice_list" type="object[]">音色引用列表，最多 2 个；每项填写音色管理接口返回的 `voice_id`。</ParamField>
    <ParamField body="sound" type="string" default="off">是否生成同步音频，可选 `on` 或 `off`。使用 `voice_list` 时必须为 `on`。</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="aspect_ratio" type="string" default="16:9">可选 `16:9`、`9:16` 或 `1:1`。</ParamField>
    <ParamField body="camera_control" type="object">预设或自定义运镜控制。</ParamField>
    <ParamField body="watermark_info" type="object">通过 `enabled` 控制是否同时生成含平台水印的结果。</ParamField>

    ### 指定音色

    `voice_list` 最多包含 2 个音色。按列表顺序在提示词中写入 `<<<voice_1>>>`、`<<<voice_2>>>`，并将 `sound` 设为 `on`。

    ```json theme={null}
    {
      "model_name": "kling-2.6",
      "prompt": "<<<voice_1>>>说：'欢迎来到今天的节目'",
      "voice_list": [{"voice_id": "voice-id"}],
      "duration": "5",
      "mode": "pro",
      "sound": "on",
      "aspect_ratio": "16:9"
    }
    ```

    ### 运镜控制

    `camera_control.type` 支持 `simple`、`down_back`、`forward_up`、`right_turn_forward` 和 `left_turn_forward`。`simple` 模式的 `config` 可设置 `horizontal`、`vertical`、`pan`、`tilt`、`roll` 或 `zoom`，范围均为 -10 到 10，且只能有一项非 0。

    ## 查询任务（单个）

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

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

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

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

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

  <Tab title="图生视频">
    ## 创建任务

    `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.6",
          "image": "https://example.com/first-frame.png",
          "image_tail": "https://example.com/end-frame.png",
          "prompt": "镜头缓慢拉远，人物微笑",
          "duration": "5",
          "mode": "pro",
          "sound": "off"
        }'
      ```

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

    ## 请求头

    <ParamField header="Authorization" type="string" required>Bearer 身份验证，格式为 `Bearer YOUR_API_KEY`。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>固定为 `application/json`。</ParamField>

    ## 请求体

    <ParamField body="model_name" type="string" required>固定为 `kling-2.6`。</ParamField>
    <ParamField body="image" type="string">首帧图片 URL 或原始 Base64；与 `image_tail` 至少填写一个。</ParamField>
    <ParamField body="image_tail" type="string">尾帧图片；不能与 `dynamic_masks`、`static_mask` 或 `camera_control` 同时使用。</ParamField>
    <ParamField body="prompt" type="string">正向提示词，最长 2500 字符。</ParamField>
    <ParamField body="negative_prompt" type="string">负向提示词，最长 2500 字符。</ParamField>
    <ParamField body="voice_list" type="object[]">最多 2 个音色，每项包含 `voice_id`。</ParamField>
    <ParamField body="sound" type="string" default="off">可选 `on` 或 `off`；引用音色时必须为 `on`。</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="static_mask" type="string">静态区域蒙版，URL 或原始 Base64。</ParamField>
    <ParamField body="dynamic_masks" type="object[]">动态运动笔刷，最多 6 组。</ParamField>
    <ParamField body="camera_control" type="object">预设或自定义运镜控制。</ParamField>
    <ParamField body="watermark_info" type="object">通过 `enabled` 控制是否同时生成含水印结果。</ParamField>

    ### 图片要求

    * 支持公开 URL 或原始 Base64；Base64 不要添加 `data:image/...;base64,` 前缀。
    * 支持 JPG、JPEG、PNG；文件不超过 10 MB，宽高均不小于 300 px，宽高比为 1:2.5 到 2.5:1。
    * `image` 与 `image_tail` 至少填写一个。
    * `image_tail`、运动笔刷和 `camera_control` 三类控制不能同时使用。

    ### 运动笔刷

    <ParamField body="dynamic_masks[].mask" type="string" required>动态区域蒙版，尺寸与输入图片一致。</ParamField>
    <ParamField body="dynamic_masks[].trajectories" type="object[]" required>轨迹坐标列表；5 秒视频可填写 2–77 个坐标点。</ParamField>
    <ParamField body="dynamic_masks[].trajectories[].x" type="integer" required>横坐标，原点位于图片左下角。</ParamField>
    <ParamField body="dynamic_masks[].trajectories[].y" type="integer" required>纵坐标，原点位于图片左下角。</ParamField>

    ### 指定音色示例

    ```json theme={null}
    {
      "model_name": "kling-2.6",
      "image": "https://example.com/person.png",
      "prompt": "<<<voice_1>>>让图中人物说：'欢迎大家'",
      "voice_list": [{"voice_id": "voice-id"}],
      "duration": "5",
      "mode": "pro",
      "sound": "on"
    }
    ```

    ## 查询任务（单个）

    `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>

    成功时，`data.task_result.videos` 返回 `id`、`url`、`watermark_url` 和 `duration`；`data.final_unit_deduction` 与 `data.final_balance_deduction` 描述最终扣减信息。

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

  <Tab title="动作控制">
    ## 创建任务

    `POST /kling/v1/videos/motion-control`

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.ai/kling/v1/videos/motion-control \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "model_name": "kling-2.6",
          "image_url": "https://example.com/character.png",
          "video_url": "https://example.com/motion.mp4",
          "prompt": "保持人物外观，准确复现参考动作",
          "character_orientation": "video",
          "keep_original_sound": "yes",
          "mode": "pro"
        }'
      ```

      ```json 200 theme={null}
      {"code":0,"message":"SUCCEED","request_id":"request-id","data":{"task_id":"task-id","task_status":"submitted"}}
      ```
    </div>

    ## 请求头

    <ParamField header="Authorization" type="string" required>Bearer 身份验证，格式为 `Bearer YOUR_API_KEY`。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>固定为 `application/json`。</ParamField>

    ## 请求体

    <ParamField body="model_name" type="string" required>固定为 `kling-2.6`。</ParamField>
    <ParamField body="prompt" type="string">补充画面内容或运镜说明，最长 2500 字符。</ParamField>
    <ParamField body="image_url" type="string" required>角色参考图片 URL 或原始 Base64。</ParamField>
    <ParamField body="video_url" type="string" required>动作参考视频的公开 URL。</ParamField>
    <ParamField body="element_list" type="object[]">可选主体引用，最多 1 个；使用时 `character_orientation` 必须为 `video`。</ParamField>
    <ParamField body="element_list[].element_id" type="string" required>旧版主体管理接口返回的主体 ID。</ParamField>
    <ParamField body="keep_original_sound" type="string" default="yes">是否保留动作参考视频原声，可选 `yes` 或 `no`。</ParamField>
    <ParamField body="character_orientation" type="string" required>角色朝向参考，可选 `image` 或 `video`。</ParamField>
    <ParamField body="mode" type="string" default="std">可选 `std` 或 `pro`。</ParamField>
    <ParamField body="watermark_info" type="object">通过 `enabled` 控制是否同时生成含水印结果。</ParamField>

    ### 素材要求

    * 图片支持 JPG、JPEG、PNG，不超过 10 MB；宽高为 300–65536 px，宽高比为 1:2.5 到 2.5:1。人物应清晰露出头部、上半身或全身，避免遮挡和极端朝向。
    * 视频支持 MP4、MOV，不超过 100 MB；宽高为 340–3850 px，时长至少 3 秒。
    * `character_orientation: "image"` 时视频最长 10 秒；设为 `video` 时最长 30 秒。
    * 参考视频应为连续单镜头，人物保持在画面内，避免切镜、剧烈运镜和过快动作，建议只包含一个人物。

    <Warning>
      当动作难度较高或速度过快时，模型可能只提取有效的连续动作并生成短于上传视频的结果。只要提取到至少 3 秒连续有效动作，任务仍可能生成并产生费用，相关消耗不退还。建议适当降低动作难度与速度。
    </Warning>

    ## 查询任务（单个）

    `GET /kling/v1/videos/motion-control/{task_id}`

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

    <ParamField path="task_id" type="string" required>动作控制任务 ID。</ParamField>

    成功结果位于 `data.task_result.videos`；任务状态为 `submitted`、`processing`、`succeed` 或 `failed`。

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

  <Tab title="音色管理">
    ## 接口列表

    | 操作        | 方法与路径                                      |
    | --------- | ------------------------------------------ |
    | 创建自定义音色   | `POST /kling/v1/general/custom-voices`     |
    | 查询单个自定义音色 | `GET /kling/v1/general/custom-voices/{id}` |
    | 查询自定义音色列表 | `GET /kling/v1/general/custom-voices`      |
    | 查询预置音色列表  | `GET /kling/v1/general/presets-voices`     |
    | 删除自定义音色   | `POST /kling/v1/general/delete-voices`     |

    ## 创建自定义音色

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.ai/kling/v1/general/custom-voices \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "voice_name": "旁白",
          "voice_url": "https://example.com/voice.mp3"
        }'
      ```

      ```json 200 theme={null}
      {"code":0,"message":"SUCCEED","request_id":"request-id","data":{"task_id":"voice-task-id","task_status":"submitted"}}
      ```
    </div>

    <ParamField body="voice_name" type="string" required>自定义音色名称，最长 20 字符。</ParamField>
    <ParamField body="voice_url" type="string">公开可访问的 MP3、WAV、MP4 或 MOV 地址；与 `video_id` 至少填写一个。</ParamField>
    <ParamField body="video_id" type="string">符合条件的历史生成视频 ID；与 `voice_url` 至少填写一个。</ParamField>

    音色素材应只包含一个清晰人声，时长 5–30 秒。创建任务状态可能为 `submitted`、`processing`、`succeed` 或 `failed`；成功后可取得 `voice_id` 和 `trial_url`。

    ## 查询单个自定义音色

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

    成功结果包含 `voice_id`、`voice_name`、`trial_url` 和 `owned_by`。

    ## 查询音色列表

    ```bash cURL theme={null}
    curl --request GET \
      --url 'https://www.anyfast.ai/kling/v1/general/custom-voices?pageNum=1&pageSize=30' \
      --header 'Authorization: Bearer YOUR_API_KEY'
    ```

    ```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'
    ```

    <ParamField query="pageNum" type="integer" default={1}>页码，范围 1–1000。</ParamField>
    <ParamField query="pageSize" type="integer" default={30}>每页数量，范围 1–1000。</ParamField>

    预置音色的 `owned_by` 为 `kling`，可以直接用于生成，但不能删除。

    ## 删除自定义音色

    ```bash cURL theme={null}
    curl --request POST \
      --url https://www.anyfast.ai/kling/v1/general/delete-voices \
      --header 'Authorization: Bearer YOUR_API_KEY' \
      --header 'Content-Type: application/json' \
      --data '{"voice_id":"VOICE_ID"}'
    ```

    <ParamField body="voice_id" type="string" required>需要删除的自定义音色 ID。</ParamField>
  </Tab>
</Tabs>

<Note>
  本页使用可灵旧版请求结构。AnyFast 在旧版接口路径前增加 `/kling` 路由前缀；页面不包含新版模型独立端点，也不列出当前未开放的任务列表查询。
</Note>

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