comfy-uiapi
Python client for ComfyUI-uiapi - programmatic control of ComfyUI workflows.
Installation
pip install comfy-uiapi
Or for development:
pip install -e /path/to/comfy-uiapi-client
Quick Start
from comfy_uiapi import ComfyClient
# Connect to ComfyUI with uiapi extension
client = ComfyClient("127.0.0.1:8188")
client.ensure_connection()
# Set workflow fields
client.set("prompt.text", "a beautiful landscape, photorealistic")
client.set("ksampler.seed", 42)
client.set("ksampler.steps", 20)
# Execute and get result
result = client.execute() # Returns numpy array (RGB)
Two Execution Modes
1. WebUI Mode (default)
Manipulates the workflow graph in the browser via uiapi:
client = ComfyClient("127.0.0.1:8188")
client.require_webui = True # default
client.set("prompt.text", "hello world")
result = client.execute()
Requires: Browser with ComfyUI WebUI open and connected.
2. Workflow API Mode
Posts JSON workflow directly to /prompt endpoint - no browser needed:
import json
# Load workflow JSON (exported from ComfyUI)
with open("workflow_api.json") as f:
workflow = json.load(f)
client = ComfyClient("127.0.0.1:8188")
client.require_webui = False
# Execute with field overrides
result = client.execute_workflow(
workflow,
fields=[
("prompt.text", "a cat in space"),
("ksampler.seed", 123),
]
)
Model Downloads
from comfy_uiapi import ComfyClient, ModelDef
client = ComfyClient("127.0.0.1:8188")
models = {
"sd_xl_base_1.0.safetensors": ModelDef(
huggingface="stabilityai/stable-diffusion-xl-base-1.0"
),
"my_lora.safetensors": ModelDef(
civitai="https://civitai.com/api/download/models/12345"
),
}
client.download_models(models)
Async API
All methods have async variants:
import asyncio
from comfy_uiapi import ComfyClient
async def main():
client = ComfyClient("127.0.0.1:8188")
await client.ensure_connection_async()
await client.set_async("prompt.text", "async generation")
result = await client.execute_async()
asyncio.run(main())
License
MIT
Metadata
Release files for comfy-uiapi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| comfy_uiapi-0.1.0.tar.gz | 37.8 kB | Without provenance | Details for comfy_uiapi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| comfy_uiapi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for comfy_uiapi-0.1.0-py3-none-any.whl |
Total release size: 49.8 kB
Release files / comfy_uiapi-0.1.0.tar.gz
| Download URL | comfy_uiapi-0.1.0.tar.gz |
|---|---|
| Size | 37.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6e6b3b3a9a2ffe05ddd0953ddf3218e4f5d4a2f208fc6bed5df8177a0786a58
|
|
BLAKE2b-256 checksum How to use checksums |
1f23bd0270597d540b55a0abd8514fd6ae95af9eea1c06f21d862deca76ffe03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / comfy_uiapi-0.1.0-py3-none-any.whl
| Download URL | comfy_uiapi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13ec7bcc1c065a276a80aca448cc0c9aea01f287459f597f5e7322f88c3d0c7a
|
|
BLAKE2b-256 checksum How to use checksums |
c225b9eccc9b2c54f69e1ce7d103cda13d52f391e09e23212ac801c688cbb590
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for comfy-uiapi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.