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

# Query a video task

> Returns the task status. When `status` is `completed` the response carries `video_url` (valid for 7 days; download it promptly); when it is `failed` it carries `error`, and failed tasks are not charged. Poll every 10–15 seconds.



## OpenAPI

````yaml /openapi/en/kling-4-0.json get /v1/videos/{task_id}
openapi: 3.1.0
info:
  description: >-
    Kling 4.0: 3–30 second videos with synchronised audio in one generation;
    text-to-video, image-to-video and first/last frame, up to 4K.
  title: Kling 4.0
  version: v1
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: Kling 4.0
paths:
  /v1/videos/{task_id}:
    get:
      tags:
        - Kling 4.0
      summary: Query a video task
      description: >-
        Returns the task status. When `status` is `completed` the response
        carries `video_url` (valid for 7 days; download it promptly); when it is
        `failed` it carries `error`, and failed tasks are not charged. Poll
        every 10–15 seconds.
      operationId: videoQueryTask
      parameters:
        - description: The `task_id` returned when the task was created.
          example: job_02b88886c4fda5be35baff61
          in: path
          name: task_id
          required: true
          schema:
            examples:
              - job_02b88886c4fda5be35baff61
            type: string
      responses:
        '200':
          content:
            application/json:
              examples:
                In progress:
                  summary: In progress
                  value:
                    task_id: job_02b88886c4fda5be35baff61
                    status: in_progress
                    model: kling-4.0
                    created_at: 1794846663
                    request_id: req_6a9a539502118ba1c33f1bfc
                Completed:
                  summary: Completed
                  value:
                    task_id: job_02b88886c4fda5be35baff61
                    status: completed
                    model: kling-4.0
                    created_at: 1794846663
                    completed_at: 1794847019
                    request_id: req_6a9a539502118ba1c33f1bfc
                    video_url: >-
                      https://cdn.example.com/videos/02b88886c4fda5be35baff61.mp4
                Failed:
                  summary: Failed
                  value:
                    task_id: job_02b88886c4fda5be35baff61
                    status: failed
                    model: kling-4.0
                    created_at: 1794846663
                    completed_at: 1794847019
                    request_id: req_6a9a539502118ba1c33f1bfc
                    error:
                      type: api_error
                      message: >-
                        InvalidParameterValue: Please input the ImageURL that
                        can be retrieved from the external network.
              schema:
                $ref: '#/components/schemas/VideoTaskResponse'
          description: Task details.
          headers:
            X-Request-Id:
              description: ID of this request; include it when reporting issues.
              schema:
                type: string
        '401':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: unauthorized
                      http_status: 401
                      message: Invalid API key.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: authentication_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: Missing or invalid API Key.
        '404':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: not_found
                      http_status: 404
                      message: The requested task was not found.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: invalid_request_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: The task does not exist or its result has expired.
        '429':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: rate_limit_exceeded
                      http_status: 429
                      message: Rate limit exceeded. Please try again later.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: rate_limit_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: Too many requests; retry later.
        '500':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: api_error
                      http_status: 500
                      message: Unable to query the task. Please try again later.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: api_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: Server error; retry later.
components:
  schemas:
    VideoTaskResponse:
      additionalProperties: false
      description: Task details.
      properties:
        task_id:
          description: Task ID.
          type: string
        status:
          description: |-
            Task status.

            **Allowed values:**
            - `queued`: Waiting in the queue.
            - `in_progress`: Being generated.
            - `completed`: Finished; download the video from `video_url`.
            - `failed`: Failed; see `error` for the reason. Not charged.
          enum:
            - queued
            - in_progress
            - completed
            - failed
          type: string
        model:
          description: Model name.
          type: string
        created_at:
          description: Task creation time, Unix timestamp in seconds.
          format: int64
          type: integer
        completed_at:
          description: >-
            Time the task finished (completed or failed), Unix timestamp in
            seconds; absent while the task is running.
          format: int64
          type: integer
        request_id:
          description: >-
            ID of the request that created the task; include it when reporting
            issues.
          type: string
        video_url:
          description: >-
            Download URL of the generated video; only present when `status` is
            `completed`. The link is valid for 7 days, so download and store the
            video promptly.
          type: string
        error:
          $ref: '#/components/schemas/VideoTaskError'
          description: Failure details; only present when `status` is `failed`.
      required:
        - task_id
        - status
        - model
        - created_at
        - request_id
      type: object
    VideoAPIErrorResponse:
      additionalProperties: false
      description: Error response.
      properties:
        error:
          $ref: '#/components/schemas/VideoAPIError'
          description: Error details.
      required:
        - error
      type: object
    VideoTaskError:
      additionalProperties: false
      description: Why the task failed.
      properties:
        type:
          description: |-
            Error type.

            **Allowed values:**
            - `api_error`: Video generation failed.
          enum:
            - api_error
          type: string
        message:
          description: Human-readable failure reason.
          type: string
      required:
        - type
        - message
      type: object
    VideoAPIError:
      additionalProperties: false
      description: Error details.
      properties:
        code:
          description: Error code.
          type: string
        http_status:
          description: HTTP status code.
          format: int64
          type: integer
        message:
          description: Human-readable error message.
          type: string
        request_id:
          description: Request ID; include it when reporting issues.
          type: string
        type:
          description: |-
            Error type.

            **Allowed values:**
            - `invalid_request_error`: Invalid request.
            - `authentication_error`: Authentication failed.
            - `insufficient_balance_error`: Insufficient balance.
            - `permission_error`: Permission denied.
            - `rate_limit_error`: Rate limited.
            - `api_error`: Server error.
          enum:
            - invalid_request_error
            - authentication_error
            - insufficient_balance_error
            - permission_error
            - rate_limit_error
            - api_error
          type: string
      required:
        - code
        - http_status
        - message
        - request_id
        - type
      type: object
  securitySchemes:
    bearerAuth:
      description: >-
        API Key created in the DreamTo console, sent as `Authorization: Bearer
        <API Key>`.
      scheme: bearer
      type: http

````

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