Skip to main content

What you will build

You will submit a 1280x768 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
  • curl and jq, Python 3.10+ with requests, or Node.js 18+
  • Access to flux-2-pro on your CometAPI account

Endpoints and authentication

Submit the task:
Poll with the top-level id returned by the create response:
Authenticate both CometAPI requests with:

Code examples

How the flow works

The create endpoint returns a top-level task id; 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

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.
Download result.sample promptly after the task becomes Ready, then place the image in storage that your application controls.
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

Last modified on July 31, 2026