ComfyUI Node

Api Collect

The half of fire-and-forget remote rendering nobody ships you

By alchemine·Created about a year ago·Updated 3 days ago· 2
Api Collect
    • output
    • label
    wait_sec0
    poll_interval2.00

    ApiCollect is the "pick up the result" half of the Alchemine pack's remote-rendering pair. Api Submit fires a workflow at a remote ComfyUI and forgets about it; ApiCollect waits, then grabs the finished image frames and hands them back to your local graph. They're meant to live together, and once you see the pattern - submit, then collect in a loop - you'll wonder why every remote API node doesn't work this way.

    The whole point is that a RunPod or cloud instance is slow, and your local ComfyUI shouldn't sit idle holding a socket open while it cooks. Submit returns in milliseconds. ApiCollect is the thing that eventually turns that job into a tensor you can actually post-process.

    How it works

    When Api Submit records a job, it writes a small lock file (jobs.lock, in the pack directory) containing the job id, the remote URL, and the output node id you care about. ApiCollect reads that lock, polls the remote's /history endpoint for the recorded prompt id, and:

    • completed → fetches the output images, decodes them into a tensor, clears the lock (freeing the slot for the next submit), returns frames.
    • errored → drops the job, clears the lock, and skips downstream this run.
    • still running → waits up to wait_sec, then skips downstream.
    • no job → skips downstream.

    "Skips downstream" means it returns an ExecutionBlocker, so everything downstream of it just doesn't run that pass. That's the mechanism you exploit by looping the graph - run it again in a moment and the job is done, so the blocker disappears and the pipeline continues.

    The inputs that matter

    Two inputs, both simple:

    • wait_sec (default 0) - how long to poll before giving up on this run. 0 means "collect if it's already done, otherwise block and bail". Set it to a few hundred if you want one queue to block until the render finishes.
    • poll_interval (default 2.0) - seconds between /history polls while waiting. Leave it alone unless the remote is straining.

    The outputs are output (the IMAGE tensor - animated outputs expand to frames) and label, the label string you attached at submit time so you can tell which job you just collected.

    Install

    Part of ComfyUI-Alchemine-Pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alchemine/comfyui-alchemine-pack
    pip install -r requirements.txt
    

    Or install via ComfyUI Manager (search "ComfyUI-Alchemine-Pack"). Only dependency is python-dotenv; no model downloads.

    Common issues

    The big one people hit: only one API job can be in flight at a time. Submit returns an empty job_id if a job is already recorded, and that's not a bug - it's the queue discipline. If your Submit output is empty, check that you collected (or the lock expired) before queuing again.

    Second: ApiCollect needs the remote to still be reachable. If your RunPod pod went to sleep between submit and collect, the poll fails, the job gets dropped, and you've lost the render. Keep the pod alive for the duration of the job, or don't blame the node.

    Last, remember wait_sec=0 means it will not wait - if you queue once and expect the result, you'll get a blocker and think it's broken. Run it in a loop (the pack docs suggest /loop) or give it a real wait_sec.

    CategoryAlcheminePack/API

    Inputs (2)

    NameTypeDefaultDescription
    wait_secINT00–36000
    poll_intervalFLOAT2.000.5–60

    Outputs (2)

    NameTypeDescription
    outputIMAGE
    labelSTRING