Optional protocols: string | string[]Readonly CLOSED: 3Readonly CLOSING: 2Readonly CONNECTING: 0Readonly OPEN: 1Private _cached_Private _pluginsProtected _polling_Protected _polling_Optional clientOptional init: RequestInitOptional init: RequestInitOptional socketProtected socket_Static DEFAULT_Static DEFAULT_Static DEFAULT_Static IS_Asynchronously enqueues a prompt with optional workflow and random seed.
The prompt to enqueue.
Optional options: { The options for enqueueing the prompt.
Optional workflow?: Record<string, unknown>The workflow for the prompt.
A promise that resolves with the enqueued prompt response.
If there is an error in the response.
Adds an event listener for the specified event type.
The type of event to listen for.
The callback function to be executed when the event is triggered.
Rest ...args: ArgumentMap<ComfyUIClientEvents>[Extract<T, keyof ComfyUIClientEvents>]Optional options: any(Optional) Additional options for the event listener.
A function that removes the event listener when called.
Protected addConnects to the WebSocket server by creating a new socket connection.
The options for connecting to the server.
Optional polling?: { The options for polling.
Optional interval?: numberOptional timeout_The timeout for the connection in milliseconds.
Optional websocket?: { The options for the WebSocket connection.
Enqueues a prompt and waits for the corresponding prompt websocket.
The prompt to enqueue.
Optional options: EnqueueOptions<T>The options for enqueueing the prompt.
A promise that resolves with the prompt result.
Optional options: EnqueueOptionsAsynchronously enqueues a prompt and waits for the corresponding prompt websocket.
This function does not use WebSocket, but uses polling to get the result So if your workflow contains custom ws events, this function will not be able to get these events
The prompt to enqueue.
Optional options: EnqueueOptions<T>The options for enqueueing the prompt.
A promise that resolves with the prompt result.
Optional options: EnqueueOptionsFetches API data based on the provided route and options.
NOTE: CORS policy: Request header field comfy-user is not allowed by Access-Control-Allow-Headers in preflight response. Please use empty string in browser.
The route for the API request.
Optional options: RequestInit(Optional) Additional options for the request.
A promise that resolves to the API response.
Gets the prompt execution history
Prompt history including node outputs
Loads a list of items (queue or history)
The type of items to load, queue or history
The items of the specified type grouped by their status
Loads node object definitions for the graph
The object info for the graph
Retrieves the outputs of a prompt with the given ID from the history.
The ID of the prompt to retrieve the outputs for.
A promise that resolves to the outputs of the prompt.
If the prompt with the given ID is not found in the history or if it failed with a non-"success" status.
Retrieves the result of a prompt with the given ID, resolved using the provided resolver.
The ID of the prompt to retrieve the result for.
The resolver to use when resolving the prompt result.
A promise that resolves to the result of the prompt.
Retrieves the status of a prompt based on the provided prompt ID.
The ID of the prompt to check status for.
Object containing the running, pending, and done status of the prompt.
Gets system & device stats
System stats such as python version, OS, per device info
Adds an event listener for the specified event type.
The type of event to listen for.
The callback function to be executed when the event is triggered.
Rest ...args: ArgumentMap<ComfyUIClientEvents>[Extract<T, keyof ComfyUIClientEvents>]Optional options: any(Optional) Additional options for the event listener.
A function that removes the event listener when called.
Listens for progress updates for a specific task.
The progress callback function.
The ID of the task to listen for progress updates.
A function that can be used to remove the progress listener.
Adds an event listener for the specified event type.
The type of event to listen for.
The callback function to be executed when the event is triggered.
Rest ...args: ArgumentMap<ComfyUIClientEvents>[Extract<T, keyof ComfyUIClientEvents>]Optional options: any(Optional) Additional options for the event listener.
A function that removes the event listener when called.
Private postThe index at which to queue the prompt, passing -1 will insert the prompt at the front of the queue
The prompt to queue
This png info to be added to resulting image
The response from the server
Protected removeAsynchronously runs a prompt with the provided options.
This function does not use WebSocket, but uses polling to get the result So if your workflow contains custom ws events, this function will not be able to get these events
The prompt to run.
Optional options: { The options for running the prompt.
Optional polling_The number of milliseconds to polling query prompt result.
Optional workflow?: Record<string, unknown>The workflow for the prompt, It will be added to the png info of the generated image.
A promise that resolves with the prompt result.
Use enqueue_polling instead
Use a plugin by calling its install method on this instance.
The plugin to install.
Generates a URL for viewing a specific file with the given filename, subfolder, and type.
The name of the file to view.
The subfolder where the file is located.
The type of the file.
The URL for viewing the file.
Asynchronously waits for the prompt with the provided ID to be done, using a WebSocket connection to receive updates.
The ID of the prompt to wait for.
A function to resolve the output of the prompt.
A promise that resolves with the output of the prompt.
Static load
The Client class provides a high-level interface for interacting with the ComfyUI API.
Example