Complete guide to FLUX API endpoints for AI image generation. Learn text-to-image creation, API polling, regional endpoints, and code examples.
Our API endpoints enable media creation with BFL models. It follows an asynchronous design, where you first make a request for a generation and then query for the result of your request.
Routes requests across all available clusters globally
Automatic failover between clusters for enhanced uptime
Intelligent load distribution prevents bottlenecks during high traffic
Does not support finetuning and finetuned inference
Always use the polling_url returned in responses when using this endpoint
Regional Endpoints
πͺπΊ api.eu.bfl.ai - European Multi-cluster
Multi-cluster routing limited to EU regions
GDPR compliant
Does not support finetuning and finetuned inference
πΊπΈ api.us.bfl.ai - US Multi-cluster
Multi-cluster routing limited to US regions
Does not support finetuning and finetuned inference
Legacy Regional Endpoints (for finetuning and finetuned inference)
πͺπΊ api.eu1.bfl.ai - EU Single-cluster
Single cluster, no automatic failover
Required for finetuning and finetuned inference operations in EU region
πΊπΈ api.us1.bfl.ai - US Single-cluster
Single cluster, no automatic failover
Required for finetuning and finetuned inference operations in US region
For enhanced reliability and performance, we recommend using the global endpoint api.bfl.ai or regional endpoints api.eu.bfl.ai/api.us.bfl.ai for inference tasks.
To submit an image generation task with FLUX 1.1 [pro], create a request:
Copy
Ask AI
# Install curl and jq, then run:# Make sure to set your API key: export BFL_API_KEY="your_key_here"request=$(curl -X 'POST' \ 'https://api.bfl.ai/v1/flux-kontext-pro' \ -H 'accept: application/json' \ -H "x-key: ${BFL_API_KEY}" \ -H 'Content-Type: application/json' \ -d '{ "prompt": "A cat on its back legs running like a human is holding a big silver fish with its arms. The cat is running away from the shop owner and has a panicked look on his face. The scene is situated in a crowded market.", "aspect_ratio": "1:1",}')echo $requestrequest_id=$(jq -r .id <<< $request)polling_url=$(jq -r .polling_url <<< $request)echo "Request ID: ${request_id}"echo "Polling URL: ${polling_url}"
A successful response will be a json object containing the requestβs id and a polling_url that should be used to retrieve the result.
Important: When using the global endpoint (api.bfl.ai) or regional endpoints (api.eu.bfl.ai, api.us.bfl.ai), you must use the polling_url returned in the response for checking request status.
To retrieve the result, poll the endpoint using the polling_url:
Copy
Ask AI
# This assumes that the request_id and polling_url variables are set from the previous stepwhile truedo sleep 0.5 result=$(curl -s -X 'GET' \ "${polling_url}" \ -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" == "Error" ] || [ "$status" == "Failed" ] then echo "Generation failed: $result" break fidone
A successful response will be a JSON object containing the result, where result['sample'] is a signed URL for retrieval.
Our signed URLs are only valid for 10 minutes. Please retrieve your result within this timeframe.
Image Delivery: The result.sample URLs are served from delivery endpoints (delivery-eu1.bfl.ai, delivery-us1.bfl.ai) and are not meant to be served directly to users. We recommend downloading the image and re-serving it from your own infrastructure. We do not enable CORS on delivery URLs.
Rate Limits: Sending requests to our API is limited to 24 active tasks. If you exceed your limit, youβll receive a status code 429 and must wait until one of your previous tasks has finished.
Rate Limits: Additionally, due to capacity issues, for flux-kontext-max, the requests to our API is limited to 6 active tasks.
Credits: If you run out of credits (status code 402), visit https://api.bfl.ai, sign in and click βAddβ to buy additional credits. See also managing your account.