ComfyUI Node

Api Generate

Run a full workflow on a remote ComfyUI and get the image back, no screen required

By alchemine·Created about a year ago·Updated 3 days ago· 2
Api Generate
  • image
  • output
workflow
positive_prompt
positive_prompt_id
negative_prompt_id
output_id
seed-1
seed_id
api_url
image_node_id
timeout_sec300
negative_prompt
overrides

ApiGenerate is the "just do it" remote-execution node: hand it an API-format workflow JSON, point it at a reachable ComfyUI, and it submits, waits, and hands you back the decoded image as a tensor. It's the whole "render on my RunPod, keep my nice local graph" fantasy in one node, and it's the synchronous version - you queue, it blocks until the remote finishes, and the frames land in your downstream nodes.

If that blocking behavior sounds wrong for your use case, that's exactly what Api Submit + Api Collect are for. This node is for when you want one clean pipeline step: fire, wait, get tensor.

How it works

The mechanics are the interesting part. You give it the API-format workflow (the flat {node_id: {class_type, inputs}} JSON from "Save (API Format)"), and it does surgical injection before submitting:

  • positive_prompt is written into the node you name in positive_prompt_id.
  • negative_prompt, if non-empty, goes into negative_prompt_id.
  • seed, if not -1, replaces the seed/noise_seed at seed_id.
  • An optional image input is encoded to PNG, uploaded to the remote's /upload/image, and bound to the LoadImage node you name in image_node_id.
  • overrides - a JSON string of {node_id: <full node dict>} - replaces entire node entries wholesale, applied last so it wins over every other injection.

Then it submits to the remote /prompt endpoint and polls /history until timeout_sec elapses. When done, it pulls the output of output_id (typically a SaveImage node), fetches the files, and decodes them into a tensor. Animated outputs come back as a batch of frames.

One nice detail: the whole submit/poll runs off the event loop in a worker thread, so ComfyUI marks the node pending and runs other ready nodes in the meantime instead of freezing the whole graph.

Inputs that matter

For a beginner, three of the ten required inputs do most of the work:

  • workflow - the API-format JSON string. Feed it from Load Workflow, or a file path.
  • api_url - the remote base URL, e.g. https://xxxx-8188.proxy.runpod.net or http://127.0.0.1:8188.
  • positive_prompt and positive_prompt_id - the text and the node id it goes into. You find node ids by hovering in the UI or checking the JSON.

output_id is the one people forget; leave it empty and nothing gets fetched back.

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 via ComfyUI Manager (search "ComfyUI-Alchemine-Pack"). Only dependency is python-dotenv, no model downloads - the models live on the remote, which is the whole trick.

Common issues

The number-one failure is feeding a UI-format workflow. The remote will reject it with a parse error because the structure is completely different. Always save API format.

Number two: the api_url scheme matters. A bare xxxx-8188.proxy.runpod.net without https:// gets rejected by the validator - include the protocol. And if your pod has an API key set, this pack's API nodes don't currently take one as an input, so a key-protected pod will just fail auth.

Number three: timeout_sec defaults to 300. A heavy SDXL workflow with hires fix can outrun that on a slow pod. Bump it.

CategoryAlcheminePack/API

Inputs (13)

NameTypeDefaultDescription
workflowSTRING
positive_promptSTRING
positive_prompt_idSTRING
negative_prompt_idSTRING
output_idSTRING
seedINT-1-1–2147483647
seed_idSTRING
api_urlSTRING
image_node_idSTRING
timeout_secINT3001–36000
negative_promptoptSTRING
imageoptIMAGE
overridesoptSTRING

Outputs (1)

NameTypeDescription
output*