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

# Retrieve a Kling 4.0 task

> Query the status and output of an existing task using its public Kling 4.0 ID.

Use the GENGEN API key that owns the task and preserve the complete `kling40:` ID returned by creation.

Poll until `succeeded` or `failed`. A successful result contains `outputs.videos`; save the video to your own storage because download links expire. Query the task again to obtain a refreshed link. Success is returned after output storage and billing settlement; repeated queries do not charge for generation again.

Do not submit a replacement task after a timeout or uncertain creation response. If no task ID was returned, contact support before retrying.

## Usage

On success, `usage.hasVideoInput` indicates whether video input affected the charge. Without video input, `billableSeconds` equals `outputDurationSeconds`. With video input, it equals `outputDurationSeconds + max(inputVideoDurationSeconds, outputDurationSeconds)`. For example, 8 seconds of input and 5 seconds of output give 13 billable seconds.

`usage.resolution` is the pricing tier string. Multiply `billableSeconds` by the per-second rate for `usage.priceRowId` in the [price catalog](https://docs.gengen.farm/api-reference/model-prices).


## OpenAPI

````yaml openapi/kling-40-video.yaml GET /contents/generations/tasks/{id}
openapi: 3.1.0
info:
  title: Kling 4.0 Video API
  version: 1.0.0
  description: >-
    Supports text-to-video, image keyframes and Omni references/editing.
    Authenticate with a GENGEN API key.
servers:
  - url: https://gengen.farm/api/gengen/v1
security:
  - bearerAuth: []
paths:
  /contents/generations/tasks/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          pattern: ^kling40:[0-9a-f-]{36}$
        description: Complete task ID returned by creation; use the owning GENGEN API key.
    get:
      summary: Retrieve a Kling 4.0 task
      description: >-
        Read an existing task without creating a generation. Poll until
        succeeded or failed. Repeated polling does not repeat the generation
        charge. Query again to renew an expired output URL.
      operationId: retrieveKling40VideoTask
      responses:
        '200':
          description: >-
            Task status. Save the complete public ID. Success is delivered after
            output storage and settlement.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
              examples:
                processing:
                  summary: In progress
                  value:
                    id: kling40:01234567-89ab-cdef-0123-456789abcdef
                    model: kling-4.0
                    status: processing
                    outputs:
                      videos: []
                      images: []
                succeeded:
                  summary: Completed video (placeholder URL)
                  value:
                    id: kling40:01234567-89ab-cdef-0123-456789abcdef
                    model: kling-4.0
                    status: succeeded
                    outputs:
                      videos:
                        - https://example.com/generated-video.mp4
                      images: []
                    usage:
                      priceRowId: kling-40-720p-video-input
                      resolution: 720p
                      hasVideoInput: true
                      inputVideoDurationSeconds: 8
                      outputDurationSeconds: 5
                      billableSeconds: 13
                failed:
                  summary: Failed task
                  value:
                    id: kling40:01234567-89ab-cdef-0123-456789abcdef
                    model: kling-4.0
                    status: failed
                    failureReason: Video generation failed.
                    outputs:
                      videos: []
                      images: []
        '400':
          description: Invalid request or incompatible media/mode.
        '401':
          description: Invalid GENGEN API key.
        '402':
          description: Insufficient balance.
        '404':
          description: Task not found or not owned by this API key.
        '429':
          description: Rate limited.
        '502':
          description: >-
            Provider response, output or usage needs reconciliation. Query an
            existing task rather than submitting again.
        '503':
          description: Service temporarily unavailable.
components:
  schemas:
    Task:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: ^kling40:[0-9a-f-]{36}$
        model:
          type: string
          enum:
            - kling-4.0
          description: Always `kling-4.0`.
        status:
          type: string
          enum:
            - pending
            - processing
            - succeeded
            - failed
          description: >
            - `pending`: Task accepted and awaiting processing.

            - `processing`: Generation, output storage or billing settlement is
            in progress.

            - `succeeded`: Output is stored and billing is settled; read
            `outputs.videos`.

            - `failed`: Task failed; see `failureReason`.
        outputs:
          type: object
          additionalProperties: false
          properties:
            videos:
              type: array
              items:
                type: string
                format: uri
              description: >-
                One video URL on success; empty while pending/processing or
                failed. Links expire: copy outputs to your storage or retrieve
                the task again.
            images:
              type: array
              items:
                type: string
          required:
            - videos
            - images
        usage:
          type: object
          description: >-
            Successful task detail. With video input, billable seconds equal
            output seconds plus the greater of input and output seconds.
            Otherwise only output seconds are charged.
          required:
            - priceRowId
            - resolution
            - billableSeconds
            - outputDurationSeconds
            - inputVideoDurationSeconds
            - hasVideoInput
          properties:
            priceRowId:
              type: string
              description: Stable customer price row in GET /api/public/pricing.
            resolution:
              type: string
              description: Resolution tier used for pricing, such as 720p.
            billableSeconds:
              type: number
              description: Seconds to multiply by the selected per-second rate.
            outputDurationSeconds:
              type: number
              description: Output video duration in seconds.
            inputVideoDurationSeconds:
              type: number
              description: Input video seconds used for billing.
            hasVideoInput:
              type: boolean
              description: Whether the video input rate applies.
        createdAt:
          type: string
          format: date-time
        failureReason:
          type: string
          description: Present when the task fails.
      required:
        - id
        - model
        - status
        - outputs
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: GENGEN API key

````

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