openapi: 3.1.0
info:
  title: Video Task Query
  version: '1.0'
  description: Query the status and result of an asynchronous video generation task.
servers:
- url: https://openapi.imini.ai/imini/router
components:
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        Pass `Authorization: Bearer <YOUR_API_KEY>` in the request header. Go to the [API Keys management page](https://imini.ai/api-keys) to create and manage API Keys.
security:
- ApiKeyAuth: []
paths:
  /v1/videos/tasks/{task_id}:
    get:
      summary: Get Video Task
      operationId: getVideoTask
      security:
      - ApiKeyAuth: []
      description: |
        Query the status and output of the specified asynchronous video generation task.

        A polling interval of **5 seconds** is recommended; video tasks typically complete within **1–5 minutes**.
      parameters:
      - name: task_id
        in: path
        required: true
        description: Unique task ID, returned by the video generation endpoint.
        schema:
          type: string
          example: task_2042864638838083584
      responses:
        '200':
          description: Query successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    type: string
                    description: Unique task ID
                    example: task_2042864638838083584
                  status:
                    type: string
                    description: |
                      Task status:
                      - `queued` — Submitted, waiting in queue
                      - `processing` — Model is generating
                      - `succeeded` — Generation succeeded
                      - `failed` — Generation failed, see the `error` field
                    enum:
                    - queued
                    - processing
                    - succeeded
                    - failed
                    example: succeeded
                  model:
                    type: string
                    description: The model ID used for this task
                    example: kling/kling-v3
                  created_at:
                    type: string
                    format: date-time
                    description: Task creation time (ISO 8601)
                    example: '2026-04-11T07:17:39.146Z'
                  completed_at:
                    type: string
                    format: date-time
                    nullable: true
                    description: Task completion time (ISO 8601); `null` while not yet completed
                    example: '2026-04-11T07:19:57.844Z'
                  videos:
                    nullable: true
                    type: array
                    description: Generation result list. Populated when `status` is `succeeded`, otherwise `null`.
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                          description: Platform CDN video URL
                          example: 'https://file.iminicdn.com/file/2026/04/11/2042865212863942656.mp4'
                        width:
                          type: integer
                          description: Video width (pixels)
                          example: 1284
                        height:
                          type: integer
                          description: Video height (pixels)
                          example: 716
                        duration:
                          type: integer
                          nullable: true
                          description: Video duration in seconds
                          example: 5
                        cover_url:
                          type: string
                          nullable: true
                          description: Video cover image URL, generated from the video's first frame; `null` if generation fails.
                          example: 'https://file.iminicdn.com/file/2026/04/11/2042865212863942700.jpg'
                  error:
                    nullable: true
                    description: Error information. Populated when `status` is `failed`, otherwise `null`.
                    type: object
                    properties:
                      code:
                        type: string
                        description: Error code
                        example: PROVIDER_ERROR
                      message:
                        type: string
                        description: Error details
                        example: Upstream provider returned an error
                      status:
                        type: integer
                        description: HTTP status code
                        example: 502
                  request_id:
                    type: string
                    description: Unique request ID
                    example: req_abc123
              examples:
                "Succeeded":
                  summary: Generation succeeded
                  value:
                    task_id: task_2042864638838083584
                    status: succeeded
                    model: kling/kling-v3
                    created_at: '2026-04-11T07:17:39.146Z'
                    completed_at: '2026-04-11T07:19:57.844Z'
                    videos:
                    - url: 'https://file.iminicdn.com/file/2026/04/11/2042865212863942656.mp4'
                      width: 1284
                      height: 716
                      duration: 5
                      cover_url: 'https://file.iminicdn.com/file/2026/04/11/2042865212863942700.jpg'
                    error: null
                    request_id: req_abc123
                "Processing":
                  summary: In progress
                  value:
                    task_id: task_2042864638838083584
                    status: processing
                    model: kling/kling-v3
                    created_at: '2026-04-11T07:17:39.146Z'
                    completed_at: null
                    videos: null
                    error: null
                    request_id: req_abc123
                "Failed":
                  summary: Generation failed
                  value:
                    task_id: task_2042864638838083584
                    status: failed
                    model: kling/kling-v3
                    created_at: '2026-04-11T07:17:39.146Z'
                    completed_at: '2026-04-11T07:18:05.000Z'
                    videos: []
                    error:
                      code: PROVIDER_ERROR
                      message: Upstream provider returned an error
                      status: 502
                    request_id: req_abc123
        '401':
          description: API Key is invalid or missing
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        example: UNAUTHORIZED
                      message:
                        type: string
                        example: API Key is invalid or missing
                      status:
                        type: integer
                        example: 401
                      request_id:
                        type: string
                        example: req_abc123
        '404':
          description: Task ID not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        example: TASK_NOT_FOUND
                      message:
                        type: string
                        example: The specified task ID does not exist
                      status:
                        type: integer
                        example: 404
                      request_id:
                        type: string
                        example: req_abc123
        '500':
          description: Internal platform error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        example: INTERNAL_ERROR
                      message:
                        type: string
                        example: An internal error occurred
                      status:
                        type: integer
                        example: 500
                      request_id:
                        type: string
                        example: req_abc123
