Subscription Required: Running workflows via the API requires an active Comfy Cloud subscription. See pricing plans for details.
Setup
All examples use these common imports and configuration:Object Info
Retrieve available node definitions. This is useful for understanding what nodes are available and their input/output specifications.Uploading Inputs
Upload images, masks, or other files for use in workflows.Direct Upload (Multipart)
Upload Mask
The
subfolder parameter is accepted for API compatibility but ignored in cloud storage. All files are stored in a flat, content-addressed namespace.Running Workflows
Submit a workflow for execution.Concurrent submissions supported: Depending on your subscription tier, you can submit multiple workflows without waiting for previous jobs to complete. Jobs run in parallel up to your tier’s limit — additional jobs queue automatically. See Parallel Execution for details and concurrency limits.
Submit Workflow
Using Partner Nodes
If your workflow contains Partner Nodes (nodes that call external AI services like Flux Pro, Ideogram, etc.), you must include your Comfy API key in theextra_data field of the request payload.
The ComfyUI frontend automatically packages your API key into
extra_data when running workflows in the browser. This section is only relevant when calling the API directly.Generate your API key at platform.comfy.org. This is the same key used for Cloud API authentication (
X-API-Key header). See Getting an API Key for step-by-step instructions.Modify Workflow Inputs
Checking Job Status
Poll for job completion. Job Status Values: The API returns one of the following status values:| Status | Description |
|---|---|
pending | Job is queued and waiting to start |
in_progress | Job is currently executing |
completed | Job finished successfully |
failed | Job encountered an error |
cancelled | Job was cancelled by user |
WebSocket for Real-Time Progress
Connect to the WebSocket for real-time execution updates.The
clientId parameter is currently ignored—all connections for a user receive the same messages. Pass a unique clientId for forward compatibility.WebSocket Message Types
Messages are sent as JSON text frames unless otherwise noted.| Type | Description |
|---|---|
status | Queue status update with queue_remaining count |
notification | User-friendly status message (value field contains text like “Executing workflow…”) |
execution_start | Workflow execution has started |
executing | A specific node is now executing (node ID in node field) |
progress | Step progress within a node (value/max for sampling steps) |
progress_state | Extended progress state with node metadata (nested nodes object) |
executed | Node completed with outputs (images, video, etc. in output field) |
execution_cached | Nodes skipped because outputs are cached (nodes array) |
execution_success | Entire workflow completed successfully |
execution_error | Workflow failed (includes exception_type, exception_message, traceback) |
execution_interrupted | Workflow was cancelled by user |
Binary Messages (Preview Images)
During image generation, ComfyUI sends binary WebSocket frames containing preview images. These are raw binary data (not JSON):| Binary Type | Value | Description |
|---|---|---|
PREVIEW_IMAGE | 1 | In-progress preview during diffusion sampling |
TEXT | 3 | Text output from nodes (progress text) |
PREVIEW_IMAGE_WITH_METADATA | 4 | Preview image with node context metadata |
- PREVIEW_IMAGE (1)
- TEXT (3)
- PREVIEW_WITH_METADATA (4)
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 4 bytes | type | 0x00000001 |
| 4 | 4 bytes | image_type | Format code (1=JPEG, 2=PNG) |
| 8 | variable | image_data | Raw image bytes |
See the OpenAPI Specification for complete schema definitions of each JSON message type.
Downloading Outputs
Retrieve generated files after job completion.Complete End-to-End Example
Here’s a full example that ties everything together:Queue Management
Get Queue Status
Cancel a Job
Interrupt Current Execution
Error Handling
HTTP Errors
REST API endpoints return standard HTTP status codes:| Status | Description |
|---|---|
400 | Invalid request (bad workflow, missing fields) |
401 | Unauthorized (invalid or missing API key) |
402 | Insufficient credits |
429 | Subscription inactive |
500 | Internal server error |
Execution Errors
During workflow execution, errors are delivered via theexecution_error WebSocket message. The exception_type field identifies the error category:
| Exception Type | Description |
|---|---|
ValidationError | Invalid workflow or inputs |
ModelDownloadError | Required model not available or failed to download |
ImageDownloadError | Failed to download input image from URL |
OOMError | Out of GPU memory |
InsufficientFundsError | Account balance too low (for Partner Nodes) |
InactiveSubscriptionError | Subscription not active |