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

# Kling 비디오 확장

> POST /kling/v1/videos/video-extend를 사용해 task_id와 video_id로 Kling 생성 비디오를 확장하세요. 상위 계정에서 하위 작업으로 실행됩니다.

이 엔드포인트를 사용해 기존 Kling 비디오를 후속 작업으로 확장할 수 있습니다.

## 호출 전 확인 사항

* 완료된 Kling 비디오 결과에서 시작하세요
* 상위 task 결과의 `video_id`를 전달하세요
* `video_id`와 함께 상위 `task_id`를 전달하세요
* 확장과 호환되는 소스 비디오를 사용하세요. 지원되지 않는 소스 비디오는 확장 작업을 생성하는 대신 HTTP 400을 반환합니다
* 확장 호환성을 위해 완료된 5초 Kling v1 또는 v1-6 text-to-video 또는 image-to-video 상위 작업을 시작점으로 사용하는 것이 더 안전합니다
* 연속 생성을 제어해야 할 때만 `prompt`, `negative_prompt`, 또는 `cfg_scale`를 추가하세요
* 상위 작업과 동일한 계정 컨텍스트에서 확장을 실행하세요
* 상위 작업 리소스가 만료되기 전에 즉시 확장을 트리거하세요

## 작업 흐름

<Steps>
  <Step title="상위 비디오 작업 완료">
    원본 Kling 비디오를 생성하고 결과를 사용할 수 있을 때까지 기다리세요.
  </Step>

  <Step title="확장 요청 제출">
    상위 `task_id`, `video_id`, 그리고 선택적 prompt를 전송한 다음, 반환된 task id를 저장하세요.
  </Step>

  <Step title="확장 작업 폴링">
    확장된 비디오가 최종 상태에 도달할 때까지 [Kling 작업 조회](./individual-queries)를 계속 진행하세요.
  </Step>
</Steps>

<Tip>
  전체 파라미터 참조는 [Kling 공식 문서](https://kling.ai/document-api/apiReference/model/videoDuration)를 확인하세요.
</Tip>


## OpenAPI

````yaml api/openapi/video/kling/post-video-extension.openapi.json POST /kling/v1/videos/video-extend
openapi: 3.1.0
info:
  title: Video Extension API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/video-extend:
    post:
      summary: Video Extension
      description: Only videos from supported generation types can be extended.
      operationId: video_extension
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - video_id
                - task_id
              properties:
                task_id:
                  type: string
                  description: >-
                    Parent Kling task id for the extension-compatible video
                    being extended.
                video_id:
                  type: string
                  description: >-
                    Video id from a parent task result. The source video must be
                    extension-compatible; unsupported videos return HTTP 400.
                prompt:
                  type: string
                  description: >-
                    Text prompt describing the desired motion for the extended
                    segment. Maximum 500 characters.
                callback_url:
                  type: string
                  description: >-
                    Webhook URL to receive task status updates when the task
                    completes.
                negative_prompt:
                  type: string
                  description: Elements to avoid in the extension.
                cfg_scale:
                  type: number
                  description: 'Prompt adherence strength for the extension. Range: 0-1.'
              default:
                task_id: <parent_task_id>
                video_id: <video_id>
                prompt: Continue with the same calm morning atmosphere
                cfg_scale: 0.5
            examples:
              Default:
                summary: >-
                  Video extension request with an extension-compatible parent
                  task
                value:
                  task_id: <parent_task_id>
                  video_id: <video_id>
                  prompt: Continue with the same calm morning atmosphere
                  cfg_scale: 0.5
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                  - request_id
                  - data
                properties:
                  code:
                    type: integer
                    description: Error code; specifically define the error code
                  message:
                    type: string
                    description: error message
                  request_id:
                    type: string
                    description: >-
                      Request ID, system-generated, for tracking requests,
                      troubleshooting issues
                  data:
                    type: object
                    required:
                      - task_id
                      - task_status
                      - task_status_msg
                      - task_info
                      - task_result
                      - created_at
                      - updated_at
                    properties:
                      task_id:
                        type: string
                        description: Task ID, system generated
                      task_status:
                        type: string
                        description: >-
                          Task status, enumerated values: submitted, processing,
                          succeed, failed.
                      task_status_msg:
                        type: string
                      task_info:
                        type: object
                        required:
                          - parent_video
                        properties:
                          parent_video:
                            type: object
                            required:
                              - id
                              - url
                              - duration
                            properties:
                              id:
                                type: string
                              url:
                                type: string
                              duration:
                                type: string
                      task_result:
                        type: object
                        required:
                          - videos
                        properties:
                          videos:
                            type: array
                            items:
                              type: object
                              properties:
                                id:
                                  type: string
                                url:
                                  type: string
                                duration:
                                  type: string
                      created_at:
                        type: integer
                        description: Task creation time, Unix timestamp, in ms.
                      updated_at:
                        type: integer
                        description: Task update time, Unix timestamp, in ms.
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/kling/v1/videos/video-extend \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "task_id": "<parent_task_id>",
                  "video_id": "<video_id>",
                  "prompt": "Continue with the same calm morning atmosphere",
                  "cfg_scale": 0.5
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/video-extend",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "task_id": "<parent_task_id>",
                  "video_id": "<video_id>",
                  "prompt": "Continue with the same calm morning atmosphere",
                  "cfg_scale": 0.5
                },
            )

            result = response.json()
            print(result.get("code"), result.get("data", {}).get("task_id"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/kling/v1/videos/video-extend", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "task_id": "<parent_task_id>",
                "video_id": "<video_id>",
                "prompt": "Continue with the same calm morning atmosphere",
                "cfg_scale": 0.5
              }),
            });


            const result = await response.json();

            console.log(result.code, result.data?.task_id);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````