What you will build
You will create a Flux image generation task withPOST /flux/v1/flux-dev, poll GET /flux/v1/get_result, and download the generated image URL when the task is ready.
Prerequisites
- A CometAPI API key stored in
COMETAPI_KEY - Python 3.10+ with
requests, or Node.js 18+ - A Flux model path from the Flux API reference or Models
API key, base URL, authentication
Flux generation uses a model name in the URL path:Code examples
Use the tabs below for copyable examples in cURL, Python, and Node.js.Flow explanation
Flux generation is asynchronous. The create endpoint returns a taskid. Poll /flux/v1/get_result?id=<task_id> until status is Ready, then download result.sample.
Flux result URLs are time-limited. Copy completed images into your own storage when your application needs durable access.
Common parameters
| Parameter | Use |
|---|---|
model path segment | Flux model variant in the URL path, such as the reference example flux-dev. |
prompt | Required text prompt. |
width / height | Output dimensions in pixels. The API reference notes model-specific ranges. |
seed | Optional reproducibility control. |
output_format | Requested output image format when supported by the selected Flux model. |
webhook_url | Optional completion notification URL for supported Flux workflows. |
Troubleshooting / FAQ
The task stays pending
The task stays pending
Keep polling with a bounded retry loop and a timeout. Store the task ID so the job can be checked later.
The image URL expired
The image URL expired
Download
result.sample soon after the task becomes Ready, then store the image in your own storage.A Flux parameter fails
A Flux parameter fails
Flux parameter support varies by model variant. Start with
prompt, width, and height, then check the Flux API reference before adding optional fields.Next steps
- Read the Flux generate image API reference.
- Poll results with Get Flux image result.
- Find Flux models in Models.
- Estimate cost with Estimate request cost before calling a model.