Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
comfy-api-simplified
Advanced tools
This is a small python wrapper over the ComfyUI API. It allows you to edit API-format ComfyUI workflows and queue them programmaticaly to the already running ComfyUI.
I use it to iterate over multiple prompts and key parameters of workflow and get hundreds of images overnight to cherrypick from.
Only Basic auth and no auth (for local server) are supported.
pip3 install comfy_api_simplified
You would like to have your node titles unique. Usually both positive and negative prompts have title "CLIP Text Encode (Prompt)", you would like to at least give them different names in case you would like to change it's parameters from python.
In ComfyUI settings, check "Enable Dev mode Options":
from comfy_api_simplified import ComfyApiWrapper, ComfyWorkflowWrapper
# create api wrapper using your ComfyUI url (add user and password params if needed)
api = ComfyApiWrapper("http://127.0.0.1:8188/")
# create workflow wrapper using your downloaded in api format workflow
wf = ComfyWorkflowWrapper("workflow_api.json")
# change anything you like in your workflow
# the syntax is "Node Title", then "Input param name", then value
wf.set_node_param("Empty Latent Image", "batch_size", 2)
wf.set_node_param("negative", "text", "embedding:EasyNegative")
# queue your workflow for completion
results = api.queue_and_wait_images(wf, "Save Image")
for filename, image_data in results.items():
with open(f"{filename}", "wb+") as f:
f.write(image_data)
More examples:
Queue prompt and get result images example.
Queue many prompts and do not wait for completion example.
Send input image and then call i2i workflow example.
There are some other approaches to use Python with ComfyUI out there.
If you are looking to conver your workflows to backend server code, check out ComfyUI-to-Python-Extension
If you are looking to use running ComfyUI as backend, but declare workflow in Python imperatively, check out ComfyScript.
If you try to run queue_and_wait_images in async method, it may give you an error since there is already async code inside. As a workaround, you can use
import nest_asyncio
nest_asyncio.apply()
for now.
FAQs
A simple way to schedule ComfyUI prompts with different parameters
We found that comfy-api-simplified demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.