FLUX.1 Kontext [pro] can generate images directly from text input, allowing you to create entirely new visuals. This guide focuses on using the /flux-kontext-pro endpoint for its Text-to-Image capabilities.

To generate an image from text, you’ll make a request to the /flux-kontext-pro endpoint.

Examples of Image Generation

FLUX.1 Kontext [pro] not only can edit images, but it can also generate images with a prompt. Here are a few examples of what you can create:

Prompts for the images above:

Abstract cat artwork: “Abstract expressionist painting Pop Art and cubism early 20 century, straight lines and solids, cute cat face without body, warm colors, green, intricate details, hologram floating in space, a vibrant digital illustration, black background, flat color, 2D, strong lines.”

Robot and truck: “A cute round rusted robot repairing a classic pickup truck, colorful, futuristic, vibrant glow, van gogh style”

Furry elephant: “A small furry elephant pet looks out from a cat house”

Face paint portrait: “A close-up of a face adorned with intricate black and blue patterns. The left side of the face is predominantly yellow, with symbols and doodles, while the right side is dark, featuring mechanical elements. The eye on the left is a striking shade of yellow, contrasting sharply with the surrounding patterns. The face is partially covered by a hooded garment, realistic style”

Prompts for the images above:

Rainy car scene: “Close-up of a vintage car hood under heavy rain, droplets cascading down the deep cherry-red paint, windshield blurred with streaks of water, glowing headlights diffused through mist, reflections of crimson neon signage spelling “FLUX” dancing across the wet chrome grille, steam rising from the engine, ambient red light enveloping the scene, moody composition, shallow depth of field, monochromatic red palette, cinematic lighting with glossy textures.”

Burning temple warrior: “A lone warrior, clad in bloodstained samurai armor, stands motionless before a massive pagoda engulfed in flames. Embers and ash swirl around him like ghosts of fallen enemies. The once-sacred temple is collapsing, its ornate carvings crumbling into the blaze as distant screams echo through the smoke-filled air. A tattered banner flutters beside him, the last symbol of a forgotten oath. The scene is both devastating and mesmerizing, with deep reds, burning oranges, and cold blue shadows creating a stark contrast. Cinematic composition, ultra-detailed textures, dynamic lighting, atmospheric fog, embers in the wind, dark fantasy realism, intense contrast.”

Foggy gas station: “Remote gas station swallowed by crimson fog, green glow from overhead lights staining the asphalt, new tiny smart car idling with taillights cutting through the mist, vending machine humming beside cracked fuel pumps, oily puddles reflecting distorted neon, shadows stretching unnaturally long, skeletal trees barely visible in the background, wide-angle cinematic shot, deep green monochromatic palette with faint charcoal accents, backlighting and heavy atmosphere, surreal and ominous mood.”

Detective game character: “Retro game style, man in old school suit, upper body, true detective, detailed character, nigh sky, crimson moon silhouette, american muscle car parked on dark street in background, complex background in style of Bill Sienkiewicz and Dave McKean and Carne Griffiths, extremely detailed, mysterious, grim, provocative, thrilling, dynamic, action-packed, fallout style, vintage, game theme, masterpiece, high contrast, stark. vivid colors, 16-bit, pixelated, textured, distressed”

Using FLUX.1 Kontext API for Text-to-Image Generation

Create a Request

# Install `curl` and `jq`, then run:
# Ensure BFL_API_KEY is set
# export BFL_API_KEY="your_api_key_here"

request=$(curl -X POST \
  'https://api.us1.bfl.ai/flux-kontext-pro' \
  -H 'accept: application/json' \
  -H "x-key: ${BFL_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "prompt": "A small furry elephant pet looks out from a cat house",
    "width": 1024,
    "height": 1024
}')
echo "Full request response:"
echo $request
request_id=$(jq -r .id <<< $request)
echo "Request ID: ${request_id}"

A successful response will be a JSON object containing the request’s id. This ID is used to retrieve the generated image.

Poll for Result

After submitting a request, you need to poll the /v1/get_result endpoint using the request_id to check the status and retrieve the output when ready.

while true
do
  sleep 1.5
  result=$(curl -s -X 'GET' \
    "https://api.us1.bfl.ai/v1/get_result?id=${request_id}" \
    -H 'accept: application/json' \
    -H "x-key: ${BFL_API_KEY}")
  status=$(jq -r .status <<< $result)
  echo "Status: $status"
  if [ "$status" == "Ready" ]
  then
    echo "Result: $(jq -r .result.sample <<< $result)"
    break
  elif [ "$status" != "Processing" ] && [ "$status" != "Queued" ] 
  then
    echo "An error or unexpected status occurred: $result"
    break
  fi
done

A successful response will be a json object containing the result, and result['sample'] is a signed URL for retrieval.

Our signed URLs are only valid for 10 minutes. Please retrieve your result within this timeframe.

FLUX.1 Kontext Text-to-Image Parameters

FLUX.1 Kontext creates 1024x1024 images by default. Use aspect_ratio to adjust the dimensions while keeping the same total pixels.

  • Supported Range: Aspect ratios can range from 3:7 (portrait) to 7:3 (landscape).
  • Default Behavior: If aspect_ratio is not specified, the model will default to a standard aspect ratio like 1:1 (e.g. 1024x1024).
ParameterTypeDefaultDescriptionRequired
promptstringText description of the desired image.Yes
aspect_ratiostring / null"1:1"Desired aspect ratio (e.g., “16:9”). All outputs are ~1MP total. Supports ratios from 3:7 to 7:3.No
seedinteger / nullnullSeed for reproducibility. If null or omitted, a random seed is used. Accepts any integer.No
prompt_upsamplingbooleanfalseIf true, performs upsampling on the prompt. Advised for T2I only currently; may not give optimal results for edit operations yet.No
safety_toleranceinteger2Moderation level for inputs and outputs. Value ranges from 0 (most strict) to 2 (least strict for this endpoint).No
output_formatstring"jpeg"Desired format of the output image. Can be “jpeg” or “png”.No
webhook_urlstring / nullnullURL for asynchronous completion notification. Must be a valid HTTP/HTTPS URL.No
webhook_secretstring / nullnullSecret for webhook signature verification, sent in the X-Webhook-Secret header.No