ComfyUI Local API Workflow: Submit, Track Progress and Retrieve Images

Start with a workflow that already runs locally, capture its real request, submit through /prompt, observe /ws, inspect /history/{prompt_id}, and retrieve images through /view.

·

AI-generated illustration: ComfyUI Local API Workflow: Submit, Track Progress and Retrieve Images
AI-generated illustration: ComfyUI Local API Workflow: Submit, Track Progress and Retrieve Images · Original file

Your workflow produces an image in the ComfyUI interface, but your application gets only a task ID. What does that ID establish? When should you fetch the image? And why might an image that displays correctly fail as input to another workflow?

A ComfyUI API workflow becomes easier to integrate when you separate submission acceptance, workflow execution, and readable output files. They are different outcomes.

This guide covers a ComfyUI Server you run locally. It uses the supplied official documentation snapshot retrieved on December 2, 2026, not a pinned release. Commands are illustrative and require verification against your installation; they are not reported test results. Cloud deployment, authentication, and any Partner Nodes authorization or billing are outside this guide’s verified scope. Do not transfer the local address and request assumptions to those environments.

Get the submission body from a successful local run

The official interface overview describes the visual interface as a way to drive the ComfyUI Server. For programmatic integration, the best starting point is the workflow you already have working—not an unrelated, larger graph.

For a controlled example, duplicate your existing workflow and keep only the path needed to save one image. Set the batch count to one, fix the seed in your existing sampling node, and make sure the output path includes an image-saving node. Run it in the interface first. Record your Server commit or installed release, frontend version, actual model files, and custom-node versions. None of these are supplied as tested settings here.

Open your browser’s Network panel and run the workflow again. Find the POST to /prompt and save its actual JSON request body as submit.json. If you use an API-format export, compare it with the prompt content in that request. A normal workflow file containing canvas layout is not automatically the complete submission body.

Capturing the request preserves the node classes, connections, and inputs accepted by your installation without inventing model filenames or node IDs. If the request includes a client identifier, keep its use consistent with the connection behavior of your local frontend.

A submission response is not a generated image

Assuming your server actually listens on 127.0.0.1:8188, inspect submit.json before running:

BASE=http://127.0.0.1:8188
curl --fail-with-body -sS \
  -H 'Content-Type: application/json' \
  --data-binary @submit.json \
  "$BASE/prompt"

This creates a new execution request; it is not a lookup. It consumes local resources and may invoke separately billed nodes if your workflow contains them. Execute only after checking the graph.

The official routes documentation says POST /prompt validates the prompt and adds it to the execution queue. Success returns prompt_id and number; validation failure returns error and node_errors. Inspect both the HTTP response and JSON body, then persist the returned task identifier. Do not mark the job as having an image merely because submission finished, and do not interpret number as a completion percentage.

Watch execution over WebSocket; find results in history

The documented /ws endpoint provides real-time communication. Listed message types include status, execution_start, execution_cached, executing, progress, and executed. These can describe queue changes, node activity, cached work, and progress in long-running operations. They do not define a universal whole-workflow percentage.

Before implementing your own client, inspect the local frontend’s WebSocket handshake and messages. Verify the client identifier, task-correlation fields, error events, and completion behavior for your installation. Connect before submitting a new job to reduce the chance of missing early messages. Do not attribute an unrelated job’s event to yours, or treat one node’s executed event as proof that all images have been saved.

Once you have a prompt_id, query its history independently:

PROMPT_ID='replace-with-returned-prompt-id'
curl --fail-with-body -sS \
  "$BASE/history/$PROMPT_ID" > history.json

The documentation establishes GET /history/{prompt_id} as the route for a specific prompt’s history, but the supplied material does not establish a complete, fixed response schema. Inspect your actual execution status, errors, and per-node outputs before writing the parser. An absent record or missing image field alone proves neither success nor failure. Correlate it with that job’s messages, queue state, and server logs. If polling, use an interval and a total deadline rather than a tight loop.

This gives the two channels distinct jobs: WebSocket provides timely observation; history lets you retrieve records again. After a disconnect, follow the saved prompt_id before deciding to submit another execution.

Retrieve the file using its full location metadata

When you find an image output, retain its filename, subfolder, and storage type. Do not assume every image lives in the same directory or persist only a bare filename.

This request illustrates query encoding. Replace every placeholder with the actual output metadata; do not arbitrarily set TYPE to output or temp.

FILENAME='replace-with-returned-filename'
SUBFOLDER='replace-with-returned-subfolder-or-empty'
TYPE='replace-with-returned-type'
curl --fail-with-body -sS --get "$BASE/view" \
  --data-urlencode "filename=$FILENAME" \
  --data-urlencode "subfolder=$SUBFOLDER" \
  --data-urlencode "type=$TYPE" \
  -o result.image

The official documentation identifies /view as an image-viewing route and points to the installed server.py for its options. These three parameters also appear in the user example in GitHub issue #4122. After downloading, verify that the response is an image, decode it, and check its dimensions. A successful request or a filename extension is not enough.

The issue exposes another boundary: being readable through /view does not establish that another workflow’s input node can load the same image by bare filename. The reporter encountered a distinction between temp images and the input directory, then used a custom node. That is an individual report from 2024, not a built-in capability guaranteed across installations. For a second workflow, verify the current input node’s path and upload conventions separately.

Troubleshoot the layer that actually failed

ObservationEvidence to inspect firstNext action
The UI also fails with missing models or nodesActual model files, node classes, installation logsRepair the local workflow rather than repeatedly posting it
/prompt returns validation errorserror, node_errors, submitted bodyCheck the affected inputs and whether canvas JSON was submitted by mistake
A task ID exists, but execution failsCorrelated events, history, server logsSeparate runtime errors from submission validation and retain the error context
Execution appears finished, but no image is foundOutput nodes and actual history outputs; preview-only or non-image resultsAvoid hard-coded node IDs and confirm an image-saving output path
File metadata exists, but /view failsFilename, subfolder, type, and target serverPreserve and encode the metadata; confirm the file still exists on the same instance

For the separate problem of uncertain submissions and duplicate work, see AI image API rate limits and safe retries. That article discusses general scheduling design, not a ComfyUI route contract.

If you also need to evaluate another image service for programmatic integration, see InkRoom’s image API introduction and integration entry, then check its current interface, authorization, and account requirements. This entry does not establish that InkRoom imports or executes ComfyUI workflows or supports the local routes described above.

Related articles and cases