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

# Get Flux image result

> Check Flux image generation task status and fetch results by task ID with CometAPI via GET /flux/v1/get_result, compatible with Replicate tasks.

## Overview

Query the status and result of an image generation task by task ID.

<Tip>
  **Cross-API Compatibility:** This endpoint is also compatible with tasks created via `/replicate/v1/models/\{model\}/predictions` and `/flux/v1/\{model\}`.
</Tip>


## OpenAPI

````yaml api/openapi/image/flux/get-flux-query.openapi.json GET /flux/v1/get_result
openapi: 3.1.0
info:
  title: flux query API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /flux/v1/get_result:
    get:
      summary: flux query
      description: >-
        Poll a Flux generation task. Poll promptly after submission: finished
        results expire on the provider side, and expired or unknown tasks return
        `status: "Task not found"`.
      operationId: flux_query
      parameters:
        - name: id
          in: query
          required: true
          description: Task id returned by the Flux generate endpoint.
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  result:
                    type: object
                    properties:
                      seed:
                        type: integer
                      prompt:
                        type: string
                      sample:
                        type: string
                        description: >-
                          Time-limited URL of the generated image. Download it
                          promptly; the link expires.
                      duration:
                        type: number
                      end_time:
                        type: number
                      start_time:
                        type: number
                    description: >-
                      Generation result when the task is `Ready`. `sample`
                      carries a time-limited image URL; download it promptly.
                  status:
                    type: string
                    description: >-
                      Task state, such as `Pending`, `Ready`, or `Task not
                      found` for expired or unknown tasks.
              example:
                id: <task_id>
                result:
                  seed: 4041919005
                  prompt: A red kite in a blue sky.
                  sample: https://delivery.eu2.bfl.ai/durable/.../sample.jpeg
                  duration: 7.2
                  start_time: 1781078400.1
                  end_time: 1781078407.3
                status: Ready
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            TASK_ID="<task_id>"

            curl "https://api.cometapi.com/flux/v1/get_result?id=$TASK_ID" \
              -H "Authorization: Bearer $COMETAPI_KEY"
        - lang: Python
          label: Default
          source: |
            import os
            import time
            import requests

            task_id = "<task_id>"
            headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}

            while True:
                task = requests.get(
                    "https://api.cometapi.com/flux/v1/get_result",
                    params={"id": task_id},
                    headers=headers,
                ).json()
                print(task["status"])
                if task["status"] not in ("Pending", "Request Accepted"):
                    break
                time.sleep(3)

            if task["status"] == "Ready":
                print(task["result"]["sample"])  # download promptly; the link expires
        - lang: JavaScript
          label: Default
          source: >
            const taskId = "<task_id>";

            const headers = { Authorization: `Bearer
            ${process.env.COMETAPI_KEY}` };


            let task;

            while (true) {
                task = await (await fetch(
                    `https://api.cometapi.com/flux/v1/get_result?id=${taskId}`, { headers }
                )).json();
                console.log(task.status);
                if (task.status !== "Pending" && task.status !== "Request Accepted") break;
                await new Promise((resolve) => setTimeout(resolve, 3000));
            }


            if (task.status === "Ready") {
                console.log(task.result.sample); // download promptly; the link expires
            }
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````