Flux
Generate a FLUX image
Submit FLUX.2 text-to-image and reference-image tasks through CometAPI’s native BFL-compatible endpoint.
POST
/
flux
/
v1
/
{model}
curl https://api.cometapi.com/flux/v1/flux-2-pro \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.",
"seed": 424242,
"width": 1280,
"height": 768,
"output_format": "png"
}'{
"id": "<task_id>",
"status": "Pending",
"result": {},
"polling_url": "https://api.cometapi.com/flux/v1/get_result?id=<task_id>"
}Overview
POST /flux/v1/\{model\} generates an image with a native BFL-format request. Requests are asynchronous by default. Store the top-level response id, then poll GET /flux/v1/get_result with that task ID.
To wait for the image in the same request, send "async": false in the JSON body. A successful synchronous response contains status: "Ready" and the image URL in result.sample.
The API playground includes text-to-image request examples for FLUX.2 Pro, Flex, and Max. Check the Models page or /v1/models for model IDs and account availability.
Request fields
Start withprompt, width, height, and output_format. You can also send seed; the completed result can report the seed used, but that field alone does not establish repeatable output.
The optional async field controls how the request returns. Use the JSON boolean false for synchronous generation. Use true or omit the field for asynchronous generation. Do not send a string such as "false".
For reference-image editing, send a public HTTPS image URL in input_image. This field is supported for the three FLUX.2 models above. FLUX.2 Pro also accepts a second public HTTPS URL in input_image_2; include input_image whenever you send input_image_2.
Generate synchronously
Select Synchronous text to image (FLUX.2 Pro) in the request examples to send"async": false. Keep the connection open while the image is generated. The example uses a 300-second client timeout; this is a client setting, not a completion deadline.
When the response has status: "Ready", read result.sample directly. No result polling is needed. If the request fails, handle the HTTP error before reading the result.
Do not combine async: false with webhook_url or webhook_secret. Synchronous requests return the result directly and reject these webhook fields.
Submit asynchronously and poll
Whenasync is true or omitted, the create response returns a task ID while generation continues. Use its top-level id with the CometAPI result endpoint; clients should not depend on a response-supplied polling_url.
Poll until the result endpoint returns status: "Ready". Treat Error, Failed, Failure, Task not found, Request Moderated, and Content Moderated as failures. For other states, continue polling within your application’s retry and timeout limits.
When a task is ready,
result.sample is a temporary image URL. Download or transfer it promptly; do not rely on a fixed lifetime.Path Parameters
Body
application/json
Controls whether generation returns asynchronously. Set false to wait for the finished image and read result.sample from the successful response. Set true or omit this field to receive a task ID for polling. Use a JSON boolean, not a string. Do not combine false with webhook_url or webhook_secret.
Response
200 - application/json
With async: false, successful generation returns status: "Ready" and the image URL in result.sample. With async: true or no async field, save the top-level id and poll the CometAPI result endpoint.
Last modified on September 21, 2026
⌘I
curl https://api.cometapi.com/flux/v1/flux-2-pro \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.",
"seed": 424242,
"width": 1280,
"height": 768,
"output_format": "png"
}'{
"id": "<task_id>",
"status": "Pending",
"result": {},
"polling_url": "https://api.cometapi.com/flux/v1/get_result?id=<task_id>"
}