Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ComfyUI — Modly extension

Run any ComfyUI workflow from inside a Modly workflow. This extension adds a ComfyUI Generate node: feed it a positive and a negative prompt, point it at a workflow you exported from ComfyUI, and it returns the generated image to the next node in your Modly graph.

It talks to a ComfyUI server you already run locally — nothing is bundled, nothing is downloaded. The processor is pure Python standard library, so there is no setup.py and no virtual environment to build.


The node

┌─ ComfyUI Generate ──────────────┐
│ ○ positive          image ● ──→ │
│ ○ negative                      │
├─────────────────────────────────┤
│ Server URL   http://127.0.0.1…  │
│ Workflows    <folder> 📁        │
│ Workflow     ▼ my_workflow.json │
│ Seed         -1                 │
└─────────────────────────────────┘
Port Type Description
positive (input) text Prompt injected into the workflow's positive text encoder
negative (input) text Prompt injected into the workflow's negative text encoder
image (output) image The generated image, passed downstream
Parameter Description
Server URL Where ComfyUI is listening. http://127.0.0.1:8188 by default (ComfyUI Desktop often uses port 8000).
Workflows Folder A folder of ComfyUI workflows exported in API format.
Workflow Dropdown of the .json files in that folder — pick the one to run.
Seed -1 (default) randomizes the seed on every run. Set a fixed value (≥ 0) for reproducible results.

Both prompt inputs are optional. If a prompt input is left unconnected, the text already saved in the workflow is used as-is.


Requirements

  • Modly with extension support.
  • A running ComfyUI server, reachable from the machine Modly runs on.
  • Any Python 3.8+ available to Modly (only the standard library is used).

Installation

From GitHub (recommended)

In Modly → ExtensionsInstall from GitHub, paste this repository's URL.

Manual

Copy this folder into Modly's extensions directory, then restart Modly (extensions are loaded at startup). The node appears under Extensions in the Workflows node palette.


Getting started (step by step)

1. Find your ComfyUI port

The node needs the URL where ComfyUI is listening. The port is not always 8188.

  • Look at the ComfyUI console when it starts — it prints a line like: Starting serverTo see the GUI go to: http://127.0.0.1:8188 The number at the end (8188, 8000, …) is your port.
  • Or look at your browser's address bar when ComfyUI is open: http://127.0.0.1:XXXX.
  • Rule of thumb: the classic/portable ComfyUI uses 8188; ComfyUI Desktop usually uses 8000.

So your Server URL is http://127.0.0.1:<that number> (e.g. http://127.0.0.1:8000).

Quick check: open http://127.0.0.1:<port> in a browser — if the ComfyUI interface loads, that's the right port.

2. Export your workflow in API format

This is the single most common source of errors. ComfyUI's /prompt API only accepts the API format, not the visual graph you see on screen.

  1. In ComfyUI, open Settings (⚙️) and enable Dev mode (a.k.a. "Enable dev mode options"). This adds the API export button.
  2. Open or build the workflow you want to run.
  3. Workflow → Export (API) (older builds: the "Save (API Format)" button).
  4. Save the .json into a dedicated folder — that folder is your Workflows Folder.

If you feed a normal (UI-format) export, the node fails with: This is a UI-format export. In ComfyUI use Workflow > Export (API) instead.

A ready example is in examples/txt2img_api.json — a minimal SD1.5 text-to-image graph. Change ckpt_name to a checkpoint you actually have installed in ComfyUI.

3. Configure the node in Modly

  1. Add the ComfyUI Generate node (Workflows palette → Extensions).
  2. Server URL → the URL from step 1.
  3. Workflows Folder → click 📁 and pick the folder from step 2.
  4. Workflow → choose your .json in the dropdown.
  5. Wire a Text node into positive (and optionally another into negative), then run.

How it works

On each run the processor:

  1. Reads the selected workflow JSON (rejecting UI-format files early).
  2. Finds every CLIPTextEncode node and traces which sampler slot consumes it, to know whether it is the positive or negative encoder — then writes your prompts in.
  3. Sets every seed / noise_seed — randomized by default, or to the fixed Seed value when you set one (≥ 0). With a fixed seed, identical inputs are served from ComfyUI's cache and emit no image, so the node reports it.
  4. POST /prompt → polls GET /history/{id} → downloads the first image via GET /view and saves it into Modly's workspace, returning its path to the next node.

Tips

  • Batch generation: put your prompts in two folders (positif/, negatif/) and drive the two inputs with two For Each Text nodes running in lockstep — one image per pair.
  • Isolated subjects: a plain white background positive plus a background, scenery, landscape negative gives clean subjects — ideal to feed a 3D mesh generator downstream.
  • Wrong port: if you get "server not reachable", check the Server URL. ComfyUI Desktop frequently listens on 8000, not 8188.

Troubleshooting

Message Cause / fix
server not reachable at … ComfyUI isn't running, or the Server URL/port is wrong.
This is a UI-format export… Re-export via Workflow → Export (API).
rejected the workflow … A node/model referenced by the workflow isn't installed in ComfyUI.
produced no outputs … The workflow has no Save Image node.

License

MIT © 2026 Lorchie

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages