Before you begin
To call Comfy Cloud from your code, make sure you have these:- A paid Comfy Cloud subscription
- A Workflow that runs in the Comfy Cloud editor: test it in the editor before you run it from code. If it needs Custom Nodes or models the standard build doesn’t have, create a custom Build first.
- Python 3.10 or later, or Node 22 or later: the SDK you install needs one of them.
Run a Workflow on the standard build
The standard build runs any Workflow that uses only the Custom Nodes Comfy Cloud supports. To run one from your code, you create an API key, install the SDK, and export the Workflow in API format.1
Create an API key
Your application sends the key with each request, so create a key for your application on the Developer Platform.
- Sign in at platform.comfy.org, and then click API Keys.
- Click New API key, enter a name, and then click Generate key.
- Copy the key and store it somewhere safe. The Developer Platform shows it once.
comfyui-. See Getting an API Key for how to manage keys.2
Install the SDK
3
Export the Workflow in API format
The SDK sends the API format of a Workflow, not the file the editor saves.
- In the Comfy Cloud editor, open the Workflow, select File > Export (API), and save the file as
workflow_api.json.
4
Run the Workflow
The SDK sends requests to Comfy Cloud unless you set another base URL, so pass only your API key:
- Replace
"9"with the ID of the output Node in yourworkflow_api.json. run()waits until the job finishes, and then the code writes the outputs to disk.
Run a Workflow on a custom Build
Deploying a custom Build gives you a deployment with its own URL. Your code from the previous section runs on the deployment once you change the base URL.1
Create and deploy a Build
Follow Custom Builds to create a Build from your Workflow and deploy it.
2
Copy the deployment URL
- On the Developer Platform, open the deployment’s page.
- Wait until the deployment’s status reads Ready.
- In Run via API, copy the Deployment URL.
https://dep-<id>.run.comfy.app.3
Set the base URL
Set
COMFY_BASE_URL to the deployment URL:4
Run the Workflow
Run the code from Run a Workflow on the standard build with your API key. The SDK now sends the job to your deployment.
Next steps
Once your Workflow runs from code, use these pages to handle inputs and progress, manage deployments, and check your limits.Comfy SDKs
Upload inputs, watch job progress, and retry submissions safely.
Manage Deployments
Release Build versions, scale workers, and call your deployment.
Usage and Limits
Check how Comfy Credits and concurrent jobs work on Comfy Cloud.
Running Workflows
Run the same SDK code against self-hosted ComfyUI.