Skip to content

Custom Workflow Chaining in ComfyUI

We don’t always create things out of necessity, even if it’s a big motivation many times, some time we create things just to see if we can. If it’s possible. This is one of those times.

But the result turned out to be surprisingly useful: a method to ‘infinite chain’ ComfyUI workflows, effectively bypassing the VRAM limits that usually crash complex pipelines like Text-to-Image-to-Video.

The Idea

The concept is simple: instead of trying to run a marathon with a heavy backpack, we treat the process like a relay race.

In a standard ComfyUI workflow, every node—from the text encoder to the final video upscaler—is loaded into the execution graph at once. This means your VRAM is being held hostage by models that might only be used for a fraction of the time.

My idea was to break this chain. I wanted to create a node that acts as a baton pass. It allows Workflow A (e.g., Flux Image Generation) to finish its job, save the result, and then completely shut down. Once it’s clear, it triggers the ComfyUI API to launch Workflow B (e.g., WAN Video Generation) into a completely fresh, empty memory environment.

The Solution: Talking to the Server, Not the UI

To make this happen, I had to step outside the standard node logic. Usually, nodes just pass data (images, latents) to each other. But for this to work, I needed a node that could talk directly to the ComfyUI Server itself.

I built a custom node called Chain Workflow (API).

Instead of processing images, this node simply waits. It waits for the first workflow to finish saving its output, and then it sends a command to the local API saying: “Hey, I’m done. Clear the queue and load this next JSON file.”

It sounds simple, but there was one major hurdle: File Formats.

I discovered that the ComfyUI server is picky. It doesn’t understand the standard workflow files (the ones with all the nice UI positions and node colors). It only speaks “API JSON.” This meant that the second workflow couldn’t just be saved normally—it had to be exported using the “Export (API Format)” option.

Once I figured that out, the pieces clicked into place. We can now chain an infinite number of workflows together, limited only by disk space, not VRAM.

Independent research like this is self-funded. If this guide saved you hours of troubleshooting, consider fueling the lab.

Support the Project

How to Set It Up

Getting this running is straightforward, but you have to follow the rules strictly for the API to accept the hand-off.

Prepare Your “Second” Workflow (The Destination)

This is the workflow you want to run second (e.g., your WAN Video Generator).

  • Set it up and test it to make sure it works, including prompts and settings.
  • In the menu, click the “Export (API Format)” button. Do not use the standard Save button.
  • Save this .json file somewhere easy to access (e.g., C:\AI\workflows\chain_wan.json).
chain api

Prepare Your “First” Workflow (The Trigger)

  • At the end of your first workflow (e.g., Flux), add the Chain Workflow node.
  • Connect your Save Image node to the trigger_image input. This ensures the first job is totally finished writing to disk before the switch happens.
  • Paste the full path to your API-formatted JSON file into the text box.

The “Dead Drop” (Passing the Image)

  • Have Workflow A save the image to a specific folder.
  • Have Workflow B load the image from that same folder using “Load Batch From Dir (Creepybits)”.
  • Pro Tip: Make sure your image loader in Workflow B is set to “Force Rescan” or “No Cache.” Otherwise, ComfyUI might try to be helpful and serve you an old cached image from a previous run!
creepybits

The node is available in the Creepybits Nodepack at Github: ComfyUI Creepy Nodes

If you liked this guide and want to got more of these, as well as other useful tips directly in your inbox, you should sign up for my newsletter.

Published inAIAI ImagesAI VideoComfyUIEnglishTech