How to hit the Black Forest Labs (FLUX) API

Black Forest Labs makes the FLUX image models. Its API at https://api.bfl.ai/v1 is asynchronous: submit a prompt, then poll the returned polling_url until the status is Ready.

Authentication

Create a key at dashboard.bfl.ai and send it as the x-key header. In the examples it's written {{BFL_API_KEY}}. Result image URLs expire after 10 minutes.

Full reference: https://docs.bfl.ai/

Generate an image

Returns id and polling_url.

curl -X POST https://api.bfl.ai/v1/flux-2-pro-preview \
  -H "x-key: {{BFL_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a taco food truck at golden hour, photo", "width": 1024, "height": 768}'
Run in PostTaco

Poll for the result

Poll the polling_url from the generate call — its host and id go here. Results can be served from a regional host, so use the one you were given.

curl "https://{{POLLING_HOST}}/v1/get_result?id={{REQUEST_ID}}" \
  -H "x-key: {{BFL_API_KEY}}"
Run in PostTaco