What you will build
You will submit a1280x768 PNG task to FLUX.2 Pro, store the returned task id, poll GET /flux/v1/get_result, and download result.sample when the task becomes Ready.
Prerequisites
- A CometAPI API key stored in
COMETAPI_KEY curlandjq, Python 3.10+ withrequests, or Node.js 18+- Access to
flux-2-proon your CometAPI account
Endpoints and authentication
Submit the task:id returned by the create response:
Code examples
How the flow works
The create endpoint returns a top-level taskid; it can also return status: "processing". Poll the CometAPI result endpoint with that id. Ready is the successful terminal state. Treat known error and moderation states as failures, and keep polling other states only until your client timeout.
Use result.sample only to download the finished image. It is a temporary URL and should not be used as durable application storage.
Common parameters
Troubleshooting
The task stays in a processing state
The task stays in a processing state
Continue polling within a bounded retry loop. If the client timeout is reached, keep the task ID for later inspection and report the request as timed out rather than successful.
The image URL no longer works
The image URL no longer works
Download
result.sample promptly after the task becomes Ready, then place the image in storage that your application controls.A request field has no effect
A request field has no effect
Start with the fields in the API reference. Treat additional model-specific controls as unverified until you confirm that the selected CometAPI route preserves and applies them.
Next steps
- Read the Generate a FLUX image API reference.
- Poll results with Get a FLUX image result.
- Find available FLUX models in Models.