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

# Generate an image with FLUX 3.1

> Generate or edit images with FLUX 3.1 and retrieve the asynchronous result.

```bash Text to image theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "Ultra-wide cinematic shot of a fog-drenched coastal highway at dawn, cliffs on one side, turquoise sea on the other, a single vintage car with headlights on, soft golden rim light",
  "aspect_ratio": "21:9",
  "resolution": "2k"
}'
```

```bash Edit an image theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "Make it a winter night: snow on the roof, the dock and the trees, the lake is frozen, warm yellow light glowing in the cabin windows.",
  "images": [
    "https://cdn.sanity.io/images/2gpum2i6/production/ae68491f9136ce25fc5c8d91830a778d73340c10-1800x1350.webp"
  ],
  "aspect_ratio": "match_first_image"
}'
```

```bash Multi reference theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "Turn Image 1 in the Style of Image 2",
  "images": [
    "https://cdn.sanity.io/images/2gpum2i6/production/ababcf5c9cf86074d71c92d6362ff63545d90661-1800x1201.webp",
    "https://cdn.sanity.io/images/2gpum2i6/production/dc642f5b01040c4afc46c1b4f8c4945152932683-1350x1800.webp"
  ]
}'
```

```bash Exact size theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "Panoramic banner of a quiet alpine lake at sunrise, mirror-still water reflecting snow-capped peaks, a red wooden boathouse on the left shore, thin mist over the water",
  "width": 2560,
  "height": 1080,
  "output_format": "jpeg"
}'
```

```bash Layout with boxes theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "Minimalist graphic illustration featuring a black silhouette of a person <silhouette_1> centered against a solid, vibrant chartreuse background <background_1>. The figure is captured in a dynamic, mid-stride running pose, facing toward the left side of the frame, mimicking a screen-printed or risograph aesthetic.",
  "aspect_ratio": "1:1",
  "bounding_boxes": [
    {
      "id": "background_1",
      "bbox": [0, 0, 1, 1],
      "desc": "A flat field of neon yellow-green with a subtle, tactile paper texture and fine, organic grain."
    },
    {
      "id": "silhouette_1",
      "bbox": [0.15, 0.15, 0.85, 0.85],
      "desc": "A black silhouette of a person in motion, made of a dense, stippled texture like ink on paper. The trailing edges dissolve into a spray of coarse, square pixels and scattered dots."
    }
  ]
}'
```

```bash Move with boxes theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "In <ref_image_0>, move the miniature grey amigurumi knight figure <knight_1> upwards and to the left along the yarn cliff. Leave the polished steel tapestry needle <needle_1> in its original position in the air. Keep the rest of the image unchanged.",
  "images": [
    "https://cdn.sanity.io/images/2gpum2i6/production/aa7b28af831835fcef86e770262c8c30fa308c2c-1360x768.webp"
  ],
  "bounding_boxes": [
    {
      "id": "knight_1",
      "from": "ref_image_0",
      "src_bbox": [0.5, 0.15, 0.85, 0.35],
      "tgt_bbox": [0.194, 0.055, 0.544, 0.255],
      "desc": "A miniature amigurumi knight crocheted from thick grey woolen yarn, with a rounded helmet and tiny stubby arms reaching upwards."
    },
    {
      "id": "needle_1",
      "from": "ref_image_0",
      "src_bbox": [0.42, 0.25, 0.55, 0.45],
      "tgt_bbox": [0.42, 0.25, 0.55, 0.45],
      "desc": "An oversized polished steel tapestry needle with a blunt tip and an elongated eye."
    }
  ]
}'
```

```bash Painted mask theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "Inside the painted mask on the red-brick wall, paint a bold modern geometric street mural in vibrant cobalt blue, warm ochre yellow, terracotta, and cream abstract curved shapes with matte brick-textured paint following the real mortar grooves. No text.",
  "images": [
    "https://cdn.sanity.io/images/2gpum2i6/production/0aad450d25e80dad6b378c112a0d03d1c9871b9e-1732x1154.webp"
  ],
  "mask": "https://cdn.sanity.io/images/2gpum2i6/production/687f38e5809923bb5e69e80948030d3e9785c7fb-1732x1154.png",
  "aspect_ratio": "match_first_image",
  "resolution": "match_first_image"
}'
```

```bash Grounding theme={null}
curl --request POST \
  --url https://api.bfl.ai/v1/flux-3.1-image \
  --header "x-key: $BFL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "The Elbphilharmonie in Hamburg at blue hour, seen from a harbour ferry, lights reflecting in the Elbe",
  "aspect_ratio": "16:9",
  "grounding": "force"
}'
```


## OpenAPI

````yaml https://api.bfl.ai/openapi.json POST /v1/flux-3.1-image
openapi: 3.1.0
info:
  title: BFL API
  description: Authorize with an API key from your user profile.
  version: 0.0.1
servers:
  - url: https://api.bfl.ai
    description: BFL API
security: []
tags:
  - name: Models
    description: >-
      Generation task endpoints. These endpoints allow you to submit generation
      tasks.
  - name: Utility
    description: >-
      These utility endpoints allow you to check the results of submitted tasks
      and to manage your finetunes.
paths:
  /v1/flux-3.1-image:
    post:
      tags:
        - Models
      summary: Generate or edit an image with FLUX 3.1.
      description: 'Submits a FLUX 3.1 image task: a prompt, optionally with images.'
      operationId: flux31_image_v1_flux_3_1_image_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Flux31ImageInputs'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/AsyncResponse'
                  - $ref: '#/components/schemas/AsyncWebhookResponse'
                title: Response Flux31 Image V1 Flux 3 1 Image Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    Flux31ImageInputs:
      properties:
        user:
          anyOf:
            - type: string
              maxLength: 256
              minLength: 1
              pattern: ^[^\x00]*$
            - type: 'null'
          title: User
          description: Opaque identifier for the end user supplied by the calling platform.
        prompt:
          type: string
          title: Prompt
          description: Free-form prompt describing the image.
        images:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Images
          description: >-
            Input image(s), up to 10 (9 with `mask`): URL or base64, 20 MB each
            at most.
        mask:
          anyOf:
            - type: string
            - type: 'null'
          title: Mask
          description: >-
            Mask for a local edit. Image 1 (the first of `images`) is the target
            image of the local edit: white may change, black is kept. URL or
            base64, at image 1's aspect ratio. With `mask`, `images` takes at
            most 9 images: the mask counts as image 10. A black-and-white mask
            can also be sent as one of `images`.
        aspect_ratio:
          type: string
          enum:
            - '21:9'
            - '2:1'
            - '16:9'
            - '3:2'
            - '7:5'
            - '4:3'
            - '5:4'
            - '1:1'
            - '4:5'
            - '3:4'
            - '5:7'
            - '2:3'
            - '9:16'
            - '1:2'
            - '9:21'
            - match_first_image
            - auto
          title: Aspect Ratio
          description: >-
            Output aspect ratio. `auto`: chosen from the prompt.
            `match_first_image`: the first image's. Ignored when `width` and
            `height` are set.
          default: auto
        resolution:
          type: string
          enum:
            - 1MP
            - 2MP
            - 4MP
            - 8MP
            - 12MP
            - 16MP
            - 1k
            - 2k
            - 4k
            - hd
            - fhd
            - qhd
            - uhd
            - match_first_image
            - auto
          title: Resolution
          description: >-
            Output size. `1MP` to `16MP`: megapixels. `1k` / `2k` / `4k`: the
            pixels of a 1024 / 2048 / 4096 square. `hd` / `fhd` / `qhd` / `uhd`:
            1280x720 / 1920x1080 / 2560x1440 / 3840x2160, which also sets the
            aspect ratio. `match_first_image`: the first image's pixel count.
            `auto`: chosen from the prompt. Ignored when `width` and `height`
            are set.
          default: auto
        width:
          anyOf:
            - type: integer
            - type: 'null'
          title: Width
          description: >-
            Output width in pixels; set together with `height`. width x height:
            250000 to 16822272 pixels, aspect ratio within 8:1.
        height:
          anyOf:
            - type: integer
            - type: 'null'
          title: Height
          description: Output height in pixels; set together with `width`.
        safety_tolerance:
          type: integer
          maximum: 7
          minimum: 0
          title: Safety Tolerance
          description: >-
            Harm moderation tolerance from 0 to 7, with 0 the strictest. The
            route and organization determine the approved maximum and
            per-category ceilings. Unapproved levels return 422 with approved
            levels.
          default: 2
        grounding:
          type: string
          enum:
            - auto
            - force
            - 'off'
          title: Grounding
          description: >-
            Web lookups for reference images and facts. `auto`: the model
            decides per request. `force`: always look things up. `off`: never
            look anything up.
          default: 'off'
        bounding_boxes:
          anyOf:
            - items:
                $ref: '#/components/schemas/Flux31BoundingBox'
              type: array
            - type: 'null'
          title: Bounding Boxes
          description: Where objects go in the output, at most 32 boxes.
        version:
          type: string
          const: latest
          title: Version
          description: Version of the endpoint's behavior.
          default: latest
        mode:
          type: string
          enum:
            - fast
            - quality
          title: Mode
          description: Speed and quality trade-off.
          default: quality
        output_format:
          type: string
          enum:
            - jpeg
            - png
          title: Output Format
          description: Output image format.
          default: jpeg
        webhook_url:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Webhook Url
          description: URL to receive webhook notifications
        webhook_secret:
          anyOf:
            - type: string
            - type: 'null'
          title: Webhook Secret
          description: Optional secret for webhook signature verification
      additionalProperties: false
      type: object
      required:
        - prompt
      title: Flux31ImageInputs
      description: 'FLUX 3.1 Image: text-to-image, or editing with up to 10 images.'
    AsyncResponse:
      properties:
        id:
          type: string
          title: Id
        polling_url:
          type: string
          title: Polling Url
        cost:
          anyOf:
            - type: number
            - type: 'null'
          title: Cost
          description: Cost in credits for this request
        input_mp:
          anyOf:
            - type: number
            - type: 'null'
          title: Input Mp
          description: Input megapixels (2 decimal places)
        output_mp:
          anyOf:
            - type: number
            - type: 'null'
          title: Output Mp
          description: Output megapixels (2 decimal places)
      type: object
      required:
        - id
        - polling_url
      title: AsyncResponse
    AsyncWebhookResponse:
      properties:
        id:
          type: string
          title: Id
        status:
          type: string
          title: Status
        webhook_url:
          type: string
          title: Webhook Url
        cost:
          anyOf:
            - type: number
            - type: 'null'
          title: Cost
          description: Cost in credits for this request
        input_mp:
          anyOf:
            - type: number
            - type: 'null'
          title: Input Mp
          description: Input megapixels (2 decimal places)
        output_mp:
          anyOf:
            - type: number
            - type: 'null'
          title: Output Mp
          description: Output megapixels (2 decimal places)
      type: object
      required:
        - id
        - status
        - webhook_url
      title: AsyncWebhookResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Flux31BoundingBox:
      properties:
        id:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Id
          description: 'Name of the object. Default: `obj_N`, N = its position.'
        desc:
          anyOf:
            - type: string
              maxLength: 1000
            - type: 'null'
          title: Desc
          description: Description of the object.
        bbox:
          anyOf:
            - items:
                type: number
              type: array
            - type: 'null'
          title: Bbox
          description: >-
            Box in the output: [y_min, x_min, y_max, x_max], 0-1 from the
            top-left corner.
        from:
          anyOf:
            - type: string
            - type: 'null'
          title: From
          description: >-
            Edits: `ref_image_N` for an object from input image N, or `target`
            for a new object. Used with `src_bbox` / `tgt_bbox` instead of
            `bbox`.
        src_bbox:
          anyOf:
            - items:
                type: number
              type: array
            - type: 'null'
          title: Src Bbox
          description: 'Edits: box of the object in its input image, same format as `bbox`.'
        tgt_bbox:
          anyOf:
            - items:
                type: number
              type: array
            - type: 'null'
          title: Tgt Bbox
          description: 'Edits: box of the object in the output, same format as `bbox`.'
      additionalProperties: false
      type: object
      title: Flux31BoundingBox
      description: Where one object goes in the output.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-key

````

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