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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
comfy_uiapi-0.1.0.tar.gz
(37.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comfy_uiapi-0.1.0.tar.gz.
File metadata
- Download URL: comfy_uiapi-0.1.0.tar.gz
- Upload date:
- Size: 37.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6e6b3b3a9a2ffe05ddd0953ddf3218e4f5d4a2f208fc6bed5df8177a0786a58
|
|
| MD5 |
c0265c2f2ae52b1753ee8f2421a7e0e5
|
|
| BLAKE2b-256 |
1f23bd0270597d540b55a0abd8514fd6ae95af9eea1c06f21d862deca76ffe03
|
File details
Details for the file comfy_uiapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: comfy_uiapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13ec7bcc1c065a276a80aca448cc0c9aea01f287459f597f5e7322f88c3d0c7a
|
|
| MD5 |
4aa1f7bb7415b70bb3e58c14b3608772
|
|
| BLAKE2b-256 |
c225b9eccc9b2c54f69e1ce7d103cda13d52f391e09e23212ac801c688cbb590
|