Skip to main content

comfy-ui-api-workflow

Build ComfyUI workflows in Python and export them in the API format that ComfyUI's POST /prompt endpoint runs.

  • 665 ComfyUI nodes as Python classes, from KSampler to Wan, LTXV, Flux, 3D and partner API nodes.
  • Checked as you build: input types, min/max ranges, combo choices, output names, socket types (no LATENT into a CLIP input) and cycles. A bad workflow fails in your code with a clear message, not in the ComfyUI queue.
  • Pipelines: reusable groups of nodes with typed parameters and named outputs, added all or nothing.
  • Round trip: load a workflow saved with ComfyUI's Export (API), change it from Python, export it again.
  • No dependencies. Python 3.10+.

Installation

pip install git+https://github.com/fabioantonioastore/comfy-ui-api-workflow

Quick start

import json

from comfy_ui_api_workflow import Workflow, nodes

workflow = Workflow()
checkpoint = workflow.add_node(
    nodes.model.loaders.CheckpointLoaderSimple, ckpt_name="sd_xl_base_1.0.safetensors"
)
prompt = workflow.add_node(
    nodes.model.conditioning.CLIPTextEncode,
    text="a lighthouse at dusk",
    clip=checkpoint.output["CLIP"],
)
negative = workflow.add_node(
    nodes.model.conditioning.CLIPTextEncode, text="blurry", clip=checkpoint.output["CLIP"]
)
latent = workflow.add_node(
    nodes.model.latent.EmptyLatentImage, width=1024, height=1024, batch_size=1
)
sampler = workflow.add_node(
    nodes.model.sampling.KSampler,
    model=checkpoint.output["MODEL"],
    positive=prompt.output["CONDITIONING"],
    negative=negative.output["CONDITIONING"],
    latent_image=latent.output["LATENT"],
    sampler_name="dpmpp_2m",
    scheduler="karras",
    steps=25,
    cfg=7.0,
)
image = workflow.add_node(
    nodes.model.latent.VAEDecode, samples=sampler.output["LATENT"], vae=checkpoint.output["VAE"]
)
workflow.add_node(nodes.image.SaveImage, images=image.output["IMAGE"], filename_prefix="lighthouse")

print(json.dumps(workflow.get_comfy_ui_workflow_format(), indent=2))

The printed JSON is what ComfyUI's /prompt endpoint takes as prompt.

Mistakes are caught right away:

from comfy_ui_api_workflow import Workflow, errors, nodes

workflow = Workflow()
latent = workflow.add_node(nodes.model.latent.EmptyLatentImage, width=512, height=512)

try:
    latent.width = 8
except errors.node.InvalidNodeParameterValue as error:
    print(error)  # width must be in closed range: [16, 16384]

Documentation

  • User guide: workflows, links, validation, changing nodes, pipelines, loading and exporting, running on ComfyUI, errors.
  • API reference: every public class, method, attribute and error.
  • Custom nodes: classes for nodes from custom node packs.
  • Node catalog: every node with its inputs and outputs.
  • examples/: runnable scripts with pipelines and nodes.

Development

hatch test             # unit tests (RunPod tests are skipped)
hatch test --cover     # with coverage
hatch test -- --runpod # also send real jobs to the RunPod endpoint in .env (paid GPU)

License

MIT

Metadata

Release files for comfy-ui-api-workflow 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for comfy-ui-api-workflow 0.0.6
File Size Uploaded Provenance Actions
comfy_ui_api_workflow-0.0.6.tar.gz 142.3 kB Without provenance Details for comfy_ui_api_workflow-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for comfy-ui-api-workflow 0.0.6
File Interpreter ABI Platform Actions
comfy_ui_api_workflow-0.0.6-py3-none-any.whl Python 3 none any Details for comfy_ui_api_workflow-0.0.6-py3-none-any.whl

Total release size: 385.2 kB

Release files / comfy_ui_api_workflow-0.0.6.tar.gz

Download URL comfy_ui_api_workflow-0.0.6.tar.gz
Size 142.3 kB
Tags Source
SHA-256 checksum
How to use checksums
076e63bc8daaf2c81afe21d8f833617871843317ab09fbcaabca665f882b5de4
BLAKE2b-256 checksum
How to use checksums
6666237ada08b4221811cbd3acce012e30b410616fd2c5c4b3d4d039388ff8c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / comfy_ui_api_workflow-0.0.6-py3-none-any.whl

Download URL comfy_ui_api_workflow-0.0.6-py3-none-any.whl
Size 242.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3b201d1d1a75fdbc8702d7a3983eb0873f433b6ac0c41c4c9e8a27f3ab031c3
BLAKE2b-256 checksum
How to use checksums
4dce3bbf653692cd27d5ba7a0b4479d59f8a261f8aae0e8f59262e5ef3222bae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for comfy-ui-api-workflow 0.0.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page