Skip to main content
Comfy Router lets you call partner models through 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 runs byteplus/dreamina-seedance-2-5-260628, a video model. These examples use Comfy as the default provider. To use an alternate provider, add model_provider to the SDK call or ?model_provider=<provider> to the URL. The provider coverage matrix lists the available model and provider combinations. Start with byteplus/dreamina-seedance-2-5-260628 below, or choose another model first.
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.Router charges credits per request. If your workspace has no credit balance, the first live call returns 402 with error_type: insufficient_credits. This check runs before body validation, so an unfunded workspace can return 402 even for an invalid request. Add credits at workspace billing before debugging the request body.
2

Save a key for this request

Generate this value once for this request. 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 generation.
3

Run the model

Choose your language and run the example. Generation can take a few minutes.
All four examples take the key from COMFY_API_KEY: the Python and TypeScript clients read it from the environment themselves, and the Swift example reads it and passes it to ComfyCloudClient(apiKey:).
4

Read the result

Router returns the model’s native result. Inspect the response body and read the fields your application needs.

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 (the SDK versions step 3 installs have it), or send the same body to POST /v2/models/{provider}/{model}/requests over HTTP. Send an Idempotency-Key with it as you did in step 2: a submit retried after a dropped connection then returns the original request instead of queueing and billing a second one. The SDKs mint one per submit call. 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 scoped to the workspace behind your key, which a key created in your Comfy workspace carries.