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

# Xem trước vùng video đã chọn của Kling

> Sử dụng endpoint Preview Selected Video Area để kết xuất bản xem trước nhanh cho các vùng đã chọn trong tác vụ chỉnh sửa video đa phương thức của Kling qua CometAPI.

Sử dụng endpoint này để xem trước vùng đã chọn trước khi bạn gửi tác vụ chỉnh sửa đa phương thức cuối cùng.

## Vì sao việc xem trước lại quan trọng

* Giúp bạn xác minh rằng các điểm chọn bao phủ đúng đối tượng hoặc khu vực dự định
* Giúp phát hiện mask không tốt trước khi bạn tốn một lệnh gọi tạo sinh
* Đây là điểm kiểm tra an toàn nhất giữa bước chỉnh sửa vùng chọn và bước tạo tác vụ cuối cùng

## Vai trò trong quy trình

<Steps>
  <Step title="Khởi tạo phiên">
    Bắt đầu với [Khởi tạo video để chỉnh sửa](./initialize-video-for-editing) và giữ lại `session_id` được trả về trên cùng một tài khoản.
  </Step>

  <Step title="Thêm các điểm chọn">
    Sử dụng [Thêm vùng chọn video](./add-video-selection) cho đến khi vùng chọn gần đúng.
  </Step>

  <Step title="Xem trước trước khi tạo">
    Gọi endpoint này, sau đó chỉ tiếp tục đến [Tạo tác vụ](./create-task) khi vùng chọn đã trông chính xác.
  </Step>
</Steps>

<Tip>
  Để xem tài liệu tham chiếu tham số đầy đủ, hãy xem [tài liệu API của Kling](https://kling.ai/document-api/apiReference/model/multiElements).
</Tip>


## OpenAPI

````yaml api/openapi/video/kling/multimodal-video-editing/post-preview-selected-video-area.openapi.json POST /kling/v1/videos/multi-elements/preview-selection
openapi: 3.1.0
info:
  title: Preview Selected Video Area API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/multi-elements/preview-selection:
    post:
      summary: Preview Selected Video Area
      operationId: preview_selected_video_area
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - session_id
              properties:
                session_id:
                  type: string
                  description: Session id returned by the video initialization endpoint.
              default:
                session_id: <session_id>
            examples:
              Default:
                summary: Default
                value:
                  session_id: <session_id>
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: integer
                    description: Response code. `0` means the request succeeded.
                  message:
                    type: string
                    description: Response message.
                  data:
                    type: object
                    description: Route-specific response payload when present.
                    additionalProperties: true
                additionalProperties: true
      x-codeSamples:
        - lang: Shell
          label: Default
          source: >
            curl
            https://api.cometapi.com/kling/v1/videos/multi-elements/preview-selection
            \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "session_id": "<session_id>"
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/multi-elements/preview-selection",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "session_id": "<session_id>"
                },
            )

            result = response.json()
            print(result.get("code"), result.get("data"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/kling/v1/videos/multi-elements/preview-selection",
            {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "session_id": "<session_id>"
              }),
            });


            const result = await response.json();

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

````