https://api.comfy.org with one Comfy API key. Send the model’s input to POST /v2/models/{provider}/{model} and wait for the finished result. This example generates an image with bfl/flux-2-pro.
1
Create an API key
Create a key in your Comfy workspace. In a Bash-compatible terminal, set:Keep API keys on your server or in your local environment. These examples are for a terminal or server, not browser JavaScript.
2
Save a key for this request
Generate this value once for this image. If you retry the same request, reuse it.If
uuidgen is unavailable, use another UUID generator. Use a new key when you start a new image.3
Generate an image
Choose your language and run the example. Image generation can take a few minutes.Both SDKs read
COMFY_API_KEY from the environment.4
Read and save the result
For this model, the image URL is at Open the returned URL or download it:Download promptly. Router can rehost BFL assets on Comfy storage, but URLs expire and a replay does not renew them. A failed rehost can leave a shorter-lived provider URL. See result assets.
result.sample in the response body. An abbreviated response looks like this; the URL below is illustrative:Queue instead of waiting
run holds the connection until the image is ready. To get a request_id back at once and collect the result later, from this process or another one, call submit instead (comfy-sdk and @comfyorg/sdk 0.3.0 or later), or send the same body to POST /v2/models/{provider}/{model}/requests over HTTP. Every model page has a Queue and collect later tab beside the synchronous snippet, and Queued delivery walks through status, cancellation and collection. Queued delivery is rolling out per workspace.