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

# Get a task

> Returns one of your tasks. A task that belongs to another account is a 404.



## OpenAPI

````yaml /openapi.json get /v1/tasks/{task_id}
openapi: 3.1.0
info:
  title: one-api.ai
  version: 1.0.0
  description: Image and video generation tasks.
servers:
  - url: https://one-api.ai
security:
  - bearerAuth: []
tags:
  - name: Generate
    description: Start an image or video task.
  - name: Tasks
    description: Read task status and results.
paths:
  /v1/tasks/{task_id}:
    get:
      tags:
        - Tasks
      summary: Get a task
      description: >-
        Returns one of your tasks. A task that belongs to another account is a
        404.
      operationId: getTask
      parameters:
        - name: task_id
          in: path
          required: true
          description: The id returned when the task was created.
          schema:
            type: string
            pattern: ^task_[0-9a-f]{32}$
        - name: wait
          in: query
          required: false
          description: >-
            Hold the call open until the task finishes, for at most this many
            seconds. `Prefer: wait=<seconds>` does the same.
          schema:
            type: integer
            minimum: 0
            maximum: 60
            default: 0
      responses:
        '200':
          description: The task.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskResponse'
        '401':
          description: The API key is missing, wrong or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No task with this id belongs to your account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many requests.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TaskResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          examples:
            - 200
        data:
          $ref: '#/components/schemas/Task'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - bad_request
                - unauthorized
                - insufficient_credits
                - not_found
                - method_not_allowed
                - rate_limited
                - bad_gateway
            message:
              type: string
    Task:
      type: object
      required:
        - id
        - status
        - type
        - model
        - cost
        - credits_cost
        - created
      properties:
        id:
          type: string
          examples:
            - task_0a17552fb8dbea3a74bc42048e5212e1
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
        type:
          type: string
          enum:
            - image
            - video
        model:
          type: string
        cost:
          type: number
          description: Price in US dollars. 0 for a failed task.
        credits_cost:
          type: number
          description: Price in credits. One credit is $0.001.
        created:
          type: integer
          description: Unix time in seconds.
        completed:
          type: integer
          description: Unix time in seconds. Present once the task has ended.
        actual_time:
          type: integer
          description: Seconds from creation to the end.
        result:
          type: object
          description: Present when the task completed.
          properties:
            images:
              type: array
              items:
                $ref: '#/components/schemas/Output'
            videos:
              type: array
              items:
                $ref: '#/components/schemas/Output'
        error:
          type: object
          description: Present when the task failed.
          properties:
            code:
              type: string
              enum:
                - generation_failed
                - timed_out
            message:
              type: string
    Output:
      type: object
      properties:
        url:
          type: array
          items:
            type: string
            format: uri
          description: Temporary signed links to the file. Download promptly.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your one-api.ai API key.

````

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