What is FLUX.1 Fill?

FLUX.1 Fill is a specialized inpainting model tailored for two complementary applications: Selecting specific regions within an image and editing them - Transform parts of your image while preserving the surrounding context. Change objects, enhance details, or remove unwanted elements naturally. Adding new pixels at the image borders - Extend images beyond their original boundaries to increase resolution or change aspect ratios. Perfect for expanding scenes or adapting content for different formats.

Examples

Inpainting: Object Replacement

This example shows how FLUX.1 Fill can replace specific parts of an image while keeping everything else intact. On the top part of the image, we replace the jacket with a different style. On the bottom part of the image, we replace the text on the neon sign.
When using a mask, black areas will be preserved while white areas will be inpainted.

Inpainting example

The second example demonstrates shows how you can use a black and white mask to define the area to change. The original “KILL BILL” title becomes “FLUX PILL” using a mask.

Original image

Mask

Inpainted image

Using FLUX.1 Fill API

FLUX.1 Fill supports two approaches for specifying edit areas:
  • Separate Mask: Provide two files - your image plus a separate black/white mask image. Black areas preserve the original, white areas get inpainted.
  • Alpha Channel: Provide one PNG/WebP with transparency. Transparent areas get inpainted, opaque areas are preserved. No separate mask file needed.

Create a Request

curl -X POST "https://api.bfl.ai/v1/flux-pro-1.0-fill" \
  -H "x-key: $BFL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "<your prompt>",
    "image": "<base64 encoded image>",
    "mask": "<base64 encoded mask>",
    "steps": 50,
    "guidance": 30,
    "output_format": "jpeg",
    "safety_tolerance": 2
  }'

Poll for Results

After submitting a request, you need to poll using the returned polling_url to retrieve the output when ready.
while true; do
  sleep 0.5
  result=$(curl -s -X 'GET' \
    "${polling_url}" \
    -H 'accept: application/json' \
    -H "x-key: ${BFL_API_KEY}")
  
  status=$(echo $result | jq -r .status)
  echo "Status: $status"
  
  if [ "$status" == "Ready" ]; then
    echo "Result: $(echo $result | jq -r .result.sample)"
    break
  elif [ "$status" == "Error" ] || [ "$status" == "Failed" ]; then
    echo "Generation failed: $result"
    break
  fi
done
A successful response will be a json object containing the result, and result['sample'] is a signed URL for retrieval.