Skip to main content

What you will build

You will create a Flux image generation task with POST /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:
https://api.cometapi.com/flux/v1/flux-dev
Poll the result endpoint with the task ID:
https://api.cometapi.com/flux/v1/get_result?id=<task_id>
Authenticate with a Bearer token:
Authorization: Bearer $COMETAPI_KEY

Code examples

Use the tabs below for copyable examples in cURL, Python, and Node.js.
curl https://api.cometapi.com/flux/v1/flux-dev \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A paper boat floating on calm water at sunrise.",
    "width": 512,
    "height": 512
  }'

curl "https://api.cometapi.com/flux/v1/get_result?id=<task_id>" \
  -H "Authorization: Bearer $COMETAPI_KEY"

Flow explanation

Flux generation is asynchronous. The create endpoint returns a task id. 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

ParameterUse
model path segmentFlux model variant in the URL path, such as the reference example flux-dev.
promptRequired text prompt.
width / heightOutput dimensions in pixels. The API reference notes model-specific ranges.
seedOptional reproducibility control.
output_formatRequested output image format when supported by the selected Flux model.
webhook_urlOptional completion notification URL for supported Flux workflows.

Troubleshooting / FAQ

Keep polling with a bounded retry loop and a timeout. Store the task ID so the job can be checked later.
Download result.sample soon after the task becomes Ready, then store the image in your own storage.
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