> ## 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.

# Generate a Flux image

> Call POST /flux/v1/{model} to generate Flux images from prompts and track status via get_result before links expire.

## Overview

The `/flux/v1/\{model\}` endpoint generates high-quality images from text prompts using Black Forest Labs' Flux model family. Simply swap the model ID in the URL path to switch between different Flux variants.

<Tip>
  For a copyable create-and-poll flow, start with the [Flux API quickstart](/quickstarts/image/flux-api).
</Tip>

<Warning>
  Due to significant differences in parameter lists across Flux series models, please refer to the [official documentation](https://docs.bfl.ai/quick_start/introduction) for detailed usage instructions. The parameter list provided here is for reference only.

  After generation, use the [`/flux/v1/get_result`](/api/image/flux/flux-query) endpoint to query generated images or monitor process status.

  Image URLs returned by BFL's service expire in approximately **10 minutes**. Save the generated results promptly.
</Warning>


## OpenAPI

````yaml api/openapi/image/flux/post-flux-generate-image.openapi.json POST /flux/v1/{model}
openapi: 3.1.0
info:
  title: flux generate image API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /flux/v1/{model}:
    post:
      summary: flux generate image
      operationId: flux_generate_image
      parameters:
        - name: model
          in: path
          required: true
          description: >-
            Flux model variant to use, e.g. `flux-pro-1.1`, `flux-pro`,
            `flux-dev`, `flux-pro-1.1-ultra`.
          schema:
            type: string
        - name: Content-Type
          in: header
          required: false
          description: Must be `application/json`.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - prompt
              properties:
                prompt:
                  type: string
                  description: Text prompt describing the image to generate.
                  default: A paper boat floating on calm water at sunrise
                image_prompt:
                  type: string
                  description: >-
                    URL of a reference image to guide the generation style or
                    content.
                width:
                  type: integer
                  description: >-
                    Output image width in pixels. Must be a multiple of 32.
                    Range varies by model.
                height:
                  type: integer
                  description: >-
                    Output image height in pixels. Must be a multiple of 32.
                    Range varies by model.
                steps:
                  type: integer
                  description: >-
                    Number of diffusion steps. Higher values improve quality but
                    increase latency.
                prompt_upsampling:
                  type: boolean
                  description: >-
                    When `true`, automatically enhances the prompt for more
                    detailed results.
                seed:
                  type: integer
                  description: >-
                    Random seed for reproducible outputs. Omit for random
                    generation.
                guidance:
                  type: number
                  description: >-
                    Guidance scale controlling how closely the output follows
                    the prompt. Higher values increase prompt adherence.
                safety_tolerance:
                  type: integer
                  description: >-
                    Safety filter tolerance level. Higher values are more
                    permissive. Range: 0–6.
                interval:
                  type: integer
                  description: >-
                    Diversity interval. Higher values produce more varied
                    outputs at the cost of prompt adherence.
                output_format:
                  type: string
                  description: 'Output image format. Supported values: `jpeg`, `png`.'
                webhook_url:
                  type: string
                  description: URL to receive a POST notification when the task completes.
                webhook_secret:
                  type: string
                  description: >-
                    Secret string included in webhook payloads for request
                    verification.
              default:
                prompt: A paper boat floating on calm water at sunrise
            examples:
              Default:
                summary: Text to image (flux-dev shown; set the model in the URL path)
                value:
                  prompt: A paper boat floating on calm water at sunrise.
                  width: 512
                  height: 512
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Task id. Pass it to `GET /flux/v1/get_result?id=...`.
                  polling_url:
                    type: string
              example:
                id: <task_id>
                polling_url: https://api.eu2.bfl.ai/v1/get_result?id=<task_id>
                cost: null
                input_mp: null
                output_mp: null
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/flux/v1/flux-dev \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "prompt": "A paper boat floating on calm water at sunrise.",
                "width": 512,
                "height": 512
              }'
        - lang: Python
          label: Default
          source: >
            import os

            import requests


            response = requests.post(
                "https://api.cometapi.com/flux/v1/flux-dev",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                    "prompt": "A paper boat floating on calm water at sunrise.",
                    "width": 512,
                    "height": 512,
                },
            )


            task = response.json()

            print(task["id"])  # poll /flux/v1/get_result?id=... promptly;
            finished results expire
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/flux/v1/flux-dev", {
                method: "POST",
                headers: {
                    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    prompt: "A paper boat floating on calm water at sunrise.",
                    width: 512,
                    height: 512,
                }),
            });


            const task = await response.json();

            console.log(task.id); // poll /flux/v1/get_result?id=... promptly;
            finished results expire
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````