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

# Querying Async Task Results

> Query asynchronous task results by task ID, including task status and final result data when processing is complete.

export const FileStoragePolicy = ({uploadedFiles, responseType}) => {
  const responseFileData = {
    URL: {
      stored: "Yes",
      retention: "24 Hours",
      deletion: "Automatic"
    },
    BASE64: {
      stored: "No",
      retention: "N/A",
      deletion: "Immediate"
    }
  };
  if (!uploadedFiles && !responseType) return null;
  return <div>
      <table>
        <thead>
          <tr>
            <th>Data Type</th>
            <th>Stored</th>
            <th>Retention</th>
            <th>Training</th>
            <th>Deletion</th>
          </tr>
        </thead>
        <tbody>
          {uploadedFiles && <tr>
              <td>Uploaded Files</td>
              <td>No</td>
              <td>N/A</td>
              <td>No</td>
              <td>Immediate</td>
            </tr>}
          {responseType && responseFileData?.[responseType] && <tr>
              <td>Response Files ({responseType})</td>
              <td>{responseFileData[responseType]['stored']}</td>
              <td>{responseFileData[responseType]['retention']}</td>
              <td>No</td>
              <td>{responseFileData[responseType]['deletion']}</td>
            </tr>}
        </tbody>
      </table>

      <Tip>
        For more information, see the{" "}<a href="/docs/file-storage-policy">File Storage Policy</a> and{" "}<a href="https://www.ailabtools.com/privacy-policy" target="_blank">Privacy Policy</a>.
      </Tip>
    </div>;
};

<Tip>
  Use this endpoint to query asynchronous task status and retrieve final results with the returned `task_id`.

  Async task results remain available for 24 hours. Query every 5 seconds.
</Tip>

## File Storage Policy

<FileStoragePolicy responseType="URL" />


## OpenAPI

````yaml GET /api/common/query-async-task-result
openapi: 3.0.0
info:
  title: AILabAPI
  description: >-
    [<b>AILabTools</b>](https://www.ailabtools.com) is an advanced tool that
    offers a vast array of simple and flexible API endpoints to suit your
    specific needs. With just one [<b>API
    KEY</b>](https://www.ailabtools.com/doc/get-api-key), you can easily call
    any of the endpoints and integrate them quickly into your application or
    workflow, allowing for smooth and efficient operations.


    [<b>AILabTools</b>](https://www.ailabtools.com) is continuously evolving,
    and you can anticipate even more API endpoints being added in the future,
    further enhancing its capabilities and usefulness for your artificial
    intelligence and machine learning requirements.
  version: 1.0.0
servers:
  - url: https://www.ailabapi.com
    description: Production server
security:
  - apiKeyAuth: []
tags:
  - name: AI IMAGE
  - name: AI IMAGE > Image Enhancement
  - name: AI IMAGE > Image Effects
  - name: AI IMAGE > Image Editing
  - name: AI IMAGE > Image Scoring
  - name: AI BACKGROUND REMOVAL
  - name: AI BACKGROUND REMOVAL > Portrait
  - name: AI BACKGROUND REMOVAL > General
  - name: AI PORTRAIT
  - name: AI PORTRAIT > Portrait Effects
  - name: AI PORTRAIT > Portrait Enhance
  - name: AI PORTRAIT > Portrait Editing
  - name: AI PORTRAIT > Portrait Analysis
  - name: AI COMMON
paths:
  /api/common/query-async-task-result:
    get:
      tags:
        - AI COMMON
      summary: Querying Async Task Results
      description: >-
        Query asynchronous task results by task ID, including task status and
        final result data when processing is complete.
      parameters:
        - name: task_id
          in: query
          schema:
            type: string
          description: The task_id returned by the asynchronous API.
      responses:
        '200':
          headers:
            Content-Type:
              schema:
                type: string
                example: application/json
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PublicResponseFields'
                  - type: object
                    required:
                      - task_status
                    properties:
                      task_status:
                        type: integer
                        enum:
                          - 0
                          - 1
                          - 2
                        description: |-
                          Task status. 
                          - `0`: queued. 
                          - `1`: processing. 
                          - `2`: completed.
                      data:
                        type: object
                        description: >-
                          Result payload. Available when `task_status` is `2`.
                          Structure depends on the async API.
              example:
                request_id: ''
                log_id: ''
                error_detail:
                  code: ''
                  code_message: ''
                  message: ''
                task_status: 0
          description: Success
components:
  schemas:
    PublicResponseFields:
      type: object
      required:
        - request_id
        - log_id
        - error_detail
      properties:
        request_id:
          type: string
          description: Request ID for debugging.
        log_id:
          type: string
          description: Log ID for debugging.
        error_detail:
          $ref: '#/components/schemas/ErrorDetail'
    ErrorDetail:
      type: object
      required:
        - code
        - code_message
        - message
      properties:
        code:
          type: string
          description: >-
            Error Code. See [Error
            Codes](/docs/response-description#error-codes).
        code_message:
          type: string
          description: Error summary.
        message:
          type: string
          description: Detailed error message.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: ailabapi-api-key
      description: API Key for authentication

````