A comfyui client, exposing all its REST endpoints.

Constructors

  • Parameters

    • endpoint: string

      The location of the endpoint.

    • opts: {
          debug?: boolean;
          secure?: boolean;
      } = ...
      • Optionaldebug?: boolean
      • Optionalsecure?: boolean

    Returns ComfyClient

Accessors

  • get uid(): `${string}-${string}-${string}-${string}-${string}`
  • Returns `${string}-${string}-${string}-${string}-${string}`

Methods

  • Remove all past requests from history.

    Returns Promise<any>

  • Remove all requests from the current queue.

    Returns Promise<any>

  • Manually closes the current connection. Usually not needed if the client is defined with the keyword using.

    Returns void

  • Remove some requests from history.

    Parameters

    • entries: string[]

      IDs of the requests to be removed

    Returns Promise<any>

  • Remove some requests from the current queue.

    Parameters

    • entries: string[]

      IDs of the requests to suspend/delete

    Returns Promise<any>

  • Returns Promise<any>

    Available embeddings from ComfyUI

    This function has been de-facto replaced by models("embeddings") on modern comfy instances

  • Returns Promise<any>

    Listing all extensions installed on a ComfyUI instance

  • It frees resources on the backend.

    Parameters

    • opts: {
          free_memory?: boolean;
          unload_models?: boolean;
      }
      • Optionalfree_memory?: boolean

        If true, memory will be freed.

      • Optionalunload_models?: boolean

        If true, models will be unloaded.

    Returns Promise<any>

  • Obtain information about the history of requests.

    Parameters

    • Optionalid: string

    Returns Promise<any>

    The current state of history.

  • Returns Promise<any>

    Information about the requests currently in execution.

  • Obtain information about the current queue of requests.

    Returns Promise<any>

    The current state of the queue.

  • It stops the execution of the current job.

    Returns Promise<any>

  • Generate a new job (automatic handling of submission, callbacks and final cleanup)

    Parameters

    • workflow: unknown

    Returns {
        get errors(): unknown[];
        get status(): ComfyJob_Status;
        get uid(): string;
        cancel(): Promise<undefined | ({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>;
        collect(outfiles: {
            from: number;
            to: string;
        }[]): Promise<Record<string, Blob[]>>;
        collect_to_files(outfiles: {
            from: number;
            to: ((x: number, filename?: string, format?: "images" | "latents") => string);
        }[]): Promise<void>;
        completion(): Promise<({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>;
        onCancelled(fn?: (() => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
        onCompleted(fn?: (() => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
        onError(fn?: ((errors: unknown) => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
        onStart(fn?: (() => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
        onUpdate(fn?: ((node: number, done: boolean) => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
        schedule(): Promise<void>;
        upload(infiles: {
            from: Blob;
            mask?: boolean;
            original?: string;
            tmp?: boolean;
            to?: string;
        }[]): Promise<({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>;
        upload_from_files(infiles: {
            from: string;
            mask?: boolean;
            original?: string;
            tmp?: boolean;
            to?: string;
        }[]): Promise<({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>;
    }

    A handle for the newly scheduled job.

    • get errors(): unknown[]
    • get status(): ComfyJob_Status
    • get uid(): string
    • cancel:function
      • Cancel this job, regardless of its current progression.

        Returns Promise<undefined | ({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>

    • collect:function
      • Collect blobs from ComfyUI after a job has finished.

        Parameters

        • outfiles: {
              from: number;
              to: string;
          }[]

          Schema for the dictionary of blobs to collect.

        Returns Promise<Record<string, Blob[]>>

    • collect_to_files:function
      • Parameters

        • outfiles: {
              from: number;
              to: ((x: number, filename?: string, format?: "images" | "latents") => string);
          }[]

        Returns Promise<void>

    • completion:function
      • Returns Promise<({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>

    • onCancelled:function
      • Parameters

        • Optionalfn: (() => void | Promise<void>)
            • (): void | Promise<void>
            • Returns void | Promise<void>

        Returns { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }

    • onCompleted:function
      • Parameters

        • Optionalfn: (() => void | Promise<void>)
            • (): void | Promise<void>
            • Returns void | Promise<void>

        Returns { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }

    • onError:function
      • Parameters

        • Optionalfn: ((errors: unknown) => void | Promise<void>)
            • (errors): void | Promise<void>
            • Parameters

              • errors: unknown

              Returns void | Promise<void>

        Returns { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }

    • onStart:function
      • Parameters

        • Optionalfn: (() => void | Promise<void>)
            • (): void | Promise<void>
            • Returns void | Promise<void>

        Returns { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }

    • onUpdate:function
      • Parameters

        • Optionalfn: ((node: number, done: boolean) => void | Promise<void>)
            • (node, done): void | Promise<void>
            • Parameters

              • node: number
              • done: boolean

              Returns void | Promise<void>

        Returns { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }

    • schedule:function
    • upload:function
      • Parameters

        • infiles: {
              from: Blob;
              mask?: boolean;
              original?: string;
              tmp?: boolean;
              to?: string;
          }[]

        Returns Promise<({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>

    • upload_from_files:function
      • Parameters

        • infiles: {
              from: string;
              mask?: boolean;
              original?: string;
              tmp?: boolean;
              to?: string;
          }[]

        Returns Promise<({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>

  • Parameters

    • type: string

    Returns Promise<any>

    Available embeddings from ComfyUI

    This function has been de-facto replaced by models("embeddings") on modern comfy instances

  • Information about the supported node types by a specific ComfyUI instance.

    Parameters

    • Optionalsubclass: string

      If not set a full list is returned, otherwise it will end up being filtered.

    Returns Promise<any>

    JSON with all the schema details.

  • Schedule a new request for execution.

    Parameters

    • workflow: {
          client_id: string;
          extra_data?: {
              extra_pnginfo: {
                  workflow: {
                      config: {};
                      extra: {};
                      groups: {}[];
                      last_link_id?: number;
                      last_node_id?: number;
                      links: [number, number, number, number, number, string][];
                      nodes: {
                          id: number;
                          inputs: {}[];
                          outputs: {
                              links: number[];
                              name: string;
                              type: string;
                          }[];
                          type: string;
                      }[];
                      version: number;
                  };
              };
          };
          prompt: {};
      }

      The JSON of the complete workflow for submission.

      • client_id: string
      • Optionalextra_data?: {
            extra_pnginfo: {
                workflow: {
                    config: {};
                    extra: {};
                    groups: {}[];
                    last_link_id?: number;
                    last_node_id?: number;
                    links: [number, number, number, number, number, string][];
                    nodes: {
                        id: number;
                        inputs: {}[];
                        outputs: {
                            links: number[];
                            name: string;
                            type: string;
                        }[];
                        type: string;
                    }[];
                    version: number;
                };
            };
        }
        • extra_pnginfo: {
              workflow: {
                  config: {};
                  extra: {};
                  groups: {}[];
                  last_link_id?: number;
                  last_node_id?: number;
                  links: [number, number, number, number, number, string][];
                  nodes: {
                      id: number;
                      inputs: {}[];
                      outputs: {
                          links: number[];
                          name: string;
                          type: string;
                      }[];
                      type: string;
                  }[];
                  version: number;
              };
          }
          • workflow: {
                config: {};
                extra: {};
                groups: {}[];
                last_link_id?: number;
                last_node_id?: number;
                links: [number, number, number, number, number, string][];
                nodes: {
                    id: number;
                    inputs: {}[];
                    outputs: {
                        links: number[];
                        name: string;
                        type: string;
                    }[];
                    type: string;
                }[];
                version: number;
            }
            • config: {}
              • extra: {}
                • groups: {}[]
                • Optionallast_link_id?: number
                • Optionallast_node_id?: number
                • links: [number, number, number, number, number, string][]
                • nodes: {
                      id: number;
                      inputs: {}[];
                      outputs: {
                          links: number[];
                          name: string;
                          type: string;
                      }[];
                      type: string;
                  }[]
                • version: number
          • prompt: {}

          Returns Promise<any>

          Endpoint response with information like the ID.

        • Generate a new job (automatic handling of submission, callbacks and final cleanup)

          Parameters

          • workflow: unknown

            The full JSON workflow to submit as part of the request.

          • infiles: {
                from: string;
                mask?: boolean;
                original?: string;
                tmp?: boolean;
                to?: string;
            }[]

            List of files to be uploaded as resources (and their naming mapping)

          • outfiles: {
                from: number;
                metadata?: boolean;
                to: ((x: number, filename?: string, format?: "images" | "latents") => string);
            }[]
          • cb: {
                onCancelled?: (() => void | Promise<void>);
                onCompleted?: (() => void | Promise<void>);
                onError?: ((errors: unknown) => void | Promise<void>);
                onStart?: (() => void | Promise<void>);
                onUpdate?: ((node: number, done: boolean) => void | Promise<void>);
            }

            All the custom callbacks defined for the lifetime of this job

            • OptionalonCancelled?: (() => void | Promise<void>)
                • (): void | Promise<void>
                • Returns void | Promise<void>

            • OptionalonCompleted?: (() => void | Promise<void>)
                • (): void | Promise<void>
                • Returns void | Promise<void>

            • OptionalonError?: ((errors: unknown) => void | Promise<void>)
                • (errors): void | Promise<void>
                • Parameters

                  • errors: unknown

                  Returns void | Promise<void>

            • OptionalonStart?: (() => void | Promise<void>)
                • (): void | Promise<void>
                • Returns void | Promise<void>

            • OptionalonUpdate?: ((node: number, done: boolean) => void | Promise<void>)
                • (node, done): void | Promise<void>
                • Parameters

                  • node: number
                  • done: boolean

                  Returns void | Promise<void>

          Returns Promise<{
              get errors(): unknown[];
              get status(): ComfyJob_Status;
              get uid(): string;
              cancel(): Promise<undefined | ({ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; })>;
              collect(outfiles: {
                  from: number;
                  to: string;
              }[]): Promise<Record<string, Blob[]>>;
              collect_to_files(outfiles: {
                  from: number;
                  to: ((x: number, filename?: string, format?: "images" | "latents") => string);
              }[]): Promise<void>;
              completion(): Promise<{ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }>;
              onCancelled(fn?: (() => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
              onCompleted(fn?: (() => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
              onError(fn?: ((errors: unknown) => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
              onStart(fn?: (() => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
              onUpdate(fn?: ((node: number, done: boolean) => void | Promise<void>)): { readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; };
              schedule(): Promise<void>;
              upload(infiles: {
                  from: Blob;
                  mask?: boolean;
                  original?: string;
                  tmp?: boolean;
                  to?: string;
              }[]): Promise<{ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }>;
              upload_from_files(infiles: {
                  from: string;
                  mask?: boolean;
                  original?: string;
                  tmp?: boolean;
                  to?: string;
              }[]): Promise<{ readonly uid: string; readonly status: ComfyJob_Status; readonly errors: unknown[]; onStart(fn?: (() => void | Promise<void>) | undefined): ...; onCompleted(fn?: (() => void | Promise<...>) | undefined): ...; ... 9 more ...; cancel(): Promise<...>; }>;
          }>

          A handle for the newly scheduled job.

        • Parameters

          • content: Blob

            A blob containing the image binary to be uploaded

          • opts: {
                overwrite?: boolean;
                subfolder?: string;
                type?: ComfyResType;
            } = {}
            • Optionaloverwrite?: boolean

              If true, it overwrites the resource (it defaults to false)

            • Optionalsubfolder?: string

              If set, it determines a subfolder where to place the image

            • Optionaltype?: ComfyResType

              It determine the resource types, like temporary, input or output

          Returns Promise<any>

        • Parameters

          • content: Blob

            A blob containing the mask binary to be uploaded

          • opts: {
                original_ref: {
                    filename: string;
                    subfolder?: string;
                    type?: ComfyResType;
                };
                overwrite?: boolean;
                subfolder?: string;
                type?: ComfyResType;
            }
            • original_ref: {
                  filename: string;
                  subfolder?: string;
                  type?: ComfyResType;
              }
              • filename: string
              • Optionalsubfolder?: string
              • Optionaltype?: ComfyResType
            • Optionaloverwrite?: boolean

              If true, it overwrites the resource (it defaults to false)

            • Optionalsubfolder?: string

              If set, it determines a subfolder where to place the image

            • Optionaltype?: ComfyResType

              It determine the resource types, like temporary, input or output

          Returns Promise<any>

        • Retrieve a file from the ComfyUI backend or it provides a preview for images.

          Parameters

          • filename: string

            The target file name

          • opts: {
                channel?: "rgba" | "rgb" | "a";
                format?: "jpg" | "png" | "webp";
                quality?: number;
                subfolder?: string;
                type?: ComfyResType;
            } = {}
            • Optionalchannel?: "rgba" | "rgb" | "a"

              For images, limit the result to some channels

            • Optionalformat?: "jpg" | "png" | "webp"

              For images, set the preview format. If left empty the full file will be requested.

            • Optionalquality?: number
            • Optionalsubfolder?: string

              Subfolder where it is located.

            • Optionaltype?: ComfyResType

              It determine the resource types, like temporary, input or output

          Returns Promise<Blob>

          The blob with the image content.

        • Parameters

          • folder: string

            Location of the file

          • filename: string

            Name of the file

          Returns Promise<any>

          The metadata associated to a given safetensors file.