ComfyUI accepts an API-format graph at POST /prompt. A successful queue response gives you a prompt_id for checking the later result.
Save the API graph and submit one job
Run a small image workflow successfully in the canvas and include a Save Image node. Export its API JSON as workflow-api.json. Its top-level keys identify nodes with a class_type and inputs. If you saved a canvas JSON, export the API format and check the node mapping before posting.
import json
from pathlib import Path
from urllib.request import Request, urlopen
graph = json.loads(Path("workflow-api.json").read_text(encoding="utf-8"))
assert graph and all("class_type" in node for node in graph.values())
request = Request("http://127.0.0.1:8188/prompt",
data=json.dumps({"prompt": graph}).encode(),
headers={"Content-Type": "application/json"})
with urlopen(request, timeout=30) as response:
queued = json.load(response)
print(queued["prompt_id"])
Find the job’s saved output
Take the returned ID and query GET /history/<prompt_id>. While the job runs, check again after an interval. When it finishes, look in that job’s outputs for the image filename and subfolder from the Save Image node. Use the same ID throughout to avoid reading a previous job’s output.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| Server up | The canvas loads at 127.0.0.1:8188 | Start ComfyUI before calling the API |
| POST accepted | The response contains a prompt_id | Check the JSON shape: the workflow goes in prompt |
| Job finishes | The history for the prompt_id shows a finished job | Poll again: generation takes time |
| Image saved | The output image is in the output folder | Read the output path from the history entry |
Expected result. We checked the ComfyUI README, which says ComfyUI integrates into pipelines through its API endpoints and that workflows save as JSON. We did not call the ComfyUI API on this machine.
Limits
This guide covers submitting one workflow only. Polling history, fetching the image bytes and wiring the API into an app are separate steps, and the local API has no authentication by default. We did not test any API call ourselves.
