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

# Generar una imagen Flux

> Llama a POST /flux/v1/{model} para generar imágenes Flux a partir de prompts y seguir el estado mediante get_result antes de que los enlaces expiren.

## Resumen

El endpoint `/flux/v1/\{model\}` genera imágenes de alta calidad a partir de prompts de texto usando la familia de modelos Flux de Black Forest Labs. Simplemente cambia el model ID en la ruta de la URL para alternar entre distintas variantes de Flux.

<Warning>
  Debido a las diferencias significativas en las listas de parámetros entre los modelos de la serie Flux, consulta la [documentación oficial](https://docs.bfl.ai/quick_start/introduction) para obtener instrucciones de uso detalladas. La lista de parámetros proporcionada aquí es solo de referencia.

  Después de la generación, usa el endpoint [`/flux/v1/get_result`](/api/image/flux/flux-query) para consultar las imágenes generadas o supervisar el estado del proceso.

  Las URL de imágenes devueltas por el servicio de BFL expiran en aproximadamente **10 minutos**. Guarda los resultados generados lo antes posible.
</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.

````