Skip to main content
If you already run ComfyUI, Runchat can drive it. Two Code nodes send a workflow to ComfyUI’s HTTP API and bring the images back onto the canvas. Your checkpoints, LoRAs and custom nodes do the generating on your own hardware, and the results can feed any other node in your Runchat workflow. You’ll need: a running ComfyUI server, on your own machine or a cloud GPU (Vast.ai, RunPod, or any VM)

Open the example workflow

Make a copy of this workflow in your account to follow along.

How it works

Code nodes run on Runchat’s servers, not in your browser. So Runchat has to reach ComfyUI over the public internet. localhost:8188 on your PC is not reachable from there. The example workflow has three inputs and two code nodes: Images come back as data URLs, which Runchat uploads automatically. They render on the node and can connect to any image input downstream.

1. Give ComfyUI a public hostname

Pick the option that matches where ComfyUI runs.
The easiest and safest option is a Cloudflare quick tunnel. You don’t need an account or router changes, and you don’t have to open a port.
  1. Install cloudflared (downloads)
  2. With ComfyUI running, start a tunnel to it:
  1. Copy the https://….trycloudflare.com URL it prints. That’s your server URL.
The URL changes each time you start the tunnel and stops working when you close it.
Bare IP addresses are blocked. Code nodes can’t fetch() a URL like http://203.0.113.7:8188. Wrap the IP in a free wildcard DNS name instead: replace the dots with dashes and add .sslip.io, e.g. http://203-0-113-7.sslip.io:8188. Custom ports work.
Paste the URL into the ComfyUI server URL input node.

2. Export your workflow in API format

ComfyUI has two JSON formats. Runchat needs the API one.
  1. In ComfyUI, open the workflow you want to run and check that it works there
  2. Choose Workflow → Export (API) to save the .json file
  3. Paste its contents into the Workflow (API format) input node
Then mark the values Runchat should fill in:
  • Replace the positive prompt text with $prompt. It can sit inside a longer string, e.g. "$prompt, golden hour, 35mm"
  • Replace the seed value with "$seed" (as a string, including the quotes) to get a new random seed on every run
The example’s default workflow is a basic Stable Diffusion 1.5 text-to-image graph. It expects the v1-5-pruned-emaonly-fp16.safetensors checkpoint. Change ckpt_name to a model you have installed.

3. Run it

Select Get images and click Run. Runchat runs Queue prompt first, then waits for the result. Get images waits up to about 50 seconds, because code nodes time out after 60. If your workflow takes longer, the node stops with Still generating. ComfyUI keeps working, so run Get images on its own again to collect the images. That doesn’t queue a new job.
The GPU time is yours, so ComfyUI runs cost no model credits. Each fetch() a code node makes costs 1 credit: one to queue, one per status check (the node backs off from 2 to 8 seconds between checks), and one per image downloaded. A typical 20-second generation uses about 5 credits plus the node run cost.
Prompts, LLM nodes, lists and loops all work as usual. Connect a list of prompts to Prompt and the workflow runs once per item. Or have an Agent node write variations first.

Adding authentication

ComfyUI has no login, so anyone who has your URL can queue jobs and see your outputs. A quick-tunnel URL is hard to guess and only lives while the tunnel runs. That’s fine for a working session, but don’t post it anywhere. For a server that stays up, put ComfyUI behind a proxy that checks a token. Your provider may already do this, or you can set up Cloudflare Access, Caddy or nginx. Then store the token as a credential, with its allowed origin set to your server URL, and send it from both code nodes:
Add the same Authorization header to the /history and /view requests in Get images. Or select the code nodes and ask the agent to do it.

Troubleshooting

Going further

Select either code node and ask the agent to extend it. For example:
  • Image-to-image: upload an input image to ComfyUI’s /upload/image endpoint and set its filename on a LoadImage node
  • More parameters: add inputs for steps, CFG or resolution and substitute them the same way as $prompt
  • Publish as a tool: publish the workflow so the agent can call your ComfyUI setup directly from chat

Next steps