Skip to main content
Experimental API: This API is experimental and subject to change. Endpoints, request/response formats, and behavior may be modified without notice. Some endpoints are maintained for compatibility with local ComfyUI but may have different semantics (e.g., ignored fields).
This page provides complete examples for common Comfy Cloud API operations.
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 the extra_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).

Modify Workflow Inputs


Jobs API

The Jobs API provides efficient endpoints for listing and retrieving job details. Use these endpoints instead of the legacy /history and /queue endpoints for better performance and richer filtering options.

List Jobs

Retrieve a paginated list of jobs with optional filtering by status, workflow ID, or output type.

Get Job Details

Retrieve complete details for a specific job including the workflow and full outputs.
Legacy Endpoints: The /api/history, /api/history_v2, and /api/queue endpoints are maintained for compatibility with local ComfyUI but the Jobs API is recommended for new integrations.

Checking Job Status

Poll for job completion. Job Status Values: The API returns one of the following status values:
StatusDescription
pendingJob is queued and waiting to start
in_progressJob is currently executing
completedJob finished successfully
failedJob encountered an error
cancelledJob 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.
TypeDescription
statusQueue status update with queue_remaining count
notificationUser-friendly status message (value field contains text like “Executing workflow…”)
execution_startWorkflow execution has started
executingA specific node is now executing (node ID in node field)
progressStep progress within a node (value/max for sampling steps)
progress_stateExtended progress state with node metadata (nested nodes object)
executedNode completed with outputs (images, video, etc. in output field)
execution_cachedNodes skipped because outputs are cached (nodes array)
execution_successEntire workflow completed successfully
execution_errorWorkflow failed (includes exception_type, exception_message, traceback)
execution_interruptedWorkflow 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 TypeValueDescription
PREVIEW_IMAGE1In-progress preview during diffusion sampling
TEXT3Text output from nodes (progress text)
PREVIEW_IMAGE_WITH_METADATA4Preview image with node context metadata
Binary frame formats (all integers are big-endian):
OffsetSizeFieldDescription
04 bytestype0x00000001
44 bytesimage_typeFormat code (1=JPEG, 2=PNG)
8variableimage_dataRaw 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:
StatusDescription
400Invalid request (bad workflow, missing fields)
401Unauthorized (invalid or missing API key)
402Insufficient credits
429Subscription inactive
500Internal server error

Execution Errors

During workflow execution, errors are delivered via the execution_error WebSocket message. The exception_type field identifies the error category:
Exception TypeDescription
ValidationErrorInvalid workflow or inputs
ModelDownloadErrorRequired model not available or failed to download
ImageDownloadErrorFailed to download input image from URL
OOMErrorOut of GPU memory
InsufficientFundsErrorAccount balance too low (for Partner Nodes)
InactiveSubscriptionErrorSubscription not active