This repository provides a JavaScript SDK for interacting with ComfyUI through its REST API. It allows you to control ComfyUI from external JavaScript applications, enabling you to:
- Connect to a running ComfyUI instance.
- Send prompts and trigger workflow execution.
- Monitor execution progress and retrieve results.
- Manage available workflows and nodes.
You can install the SDK using npm:
npm install comfyui-js-sdkconst Comfy = require('comfyui-js-sdk');
const comfy = new Comfy("http://localhost:8181");
comfy.queuePrompt({
// ... workflow definition and parameters ...
}).then(executionId => {
console.log("Workflow started with ID:", executionId);
// Monitor progress
setInterval(() => {
comfy.getProgress(executionId).then(progress => {
console.log("Progress:", progress);
});
}, 1000);
// Get output image when workflow is completed
comfy.getOutputImage(executionId).then(image => {
// ... do something with the image ...
});
});Creates a new ComfyUI instance.
apiUrl: The URL of the ComfyUI API.
Returns a list of available workflows.
Queues a prompt for execution.
prompt: An object describing the workflow and input parameters.
Returns the execution ID.
Retrieves the output image for a given execution ID.
Retrieves the progress of a given execution ID.
Cancels the execution of a given execution ID.
Returns a list of available nodes.
Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.
This project is licensed under the MIT License.