Unlimited Open Source Models

Get Plan
Skip to main content
Workflows API

ComfyUI REST API: Run Workflows Programmatically

Every ComfyUI server has a REST API: export the workflow in API format, POST it to /prompt, and read the result from /history. ModelsLab does not host ComfyUI; if you would rather not run the server, its own node workflows run over REST at /api/v1/workflows/{id}/run.

Last updated · By ModelsLab Engineering

How to execute a ComfyUI workflow over REST

Three HTTP calls on your own ComfyUI server

ComfyUI is a server as well as an editor. The same process that serves the node UI accepts HTTP requests, so any workflow you can run by clicking Queue you can also run from code. It needs a running ComfyUI instance with the models and custom nodes the workflow uses.

  • Export the workflow in API format: in current ComfyUI choose Export (API) from the workflow menu (older versions: enable dev mode and use Save (API Format)). The file maps node ids to class_type and inputs, which is the format the server accepts.
  • Queue it: POST {"prompt": <the API-format JSON>, "client_id": "<any id>"} to http://127.0.0.1:8188/prompt. The response carries a prompt_id.
  • Change inputs in code first: edit the node values in the JSON (for example the text of a CLIPTextEncode node or the seed of a KSampler node) before you send it.
  • Wait for the run: poll GET /history/{prompt_id} until it has outputs, or listen on the /ws WebSocket for the executing message with node null.
  • Download the images: each output lists a filename, subfolder and type; GET /view with those three values returns the file.

Is there a hosted ComfyUI API on ModelsLab?

Short answer: no — here is what exists instead

ComfyUI itself has an API: the ComfyUI server you run exposes an HTTP endpoint (POST /prompt) and a WebSocket for progress, on your own machine or GPU. ModelsLab does not host that server. You cannot upload a ComfyUI workflow JSON to ModelsLab, and ComfyUI custom nodes do not run here.

What ModelsLab offers is its own visual workflow builder at /workflows. Each node is one ModelsLab model or tool, you connect outputs to inputs, and a saved workflow becomes a REST endpoint. Every field you leave unconnected becomes a named JSON parameter of that endpoint.

  • Nodes for ModelsLab models: Flux text-to-image, image-to-image, image-to-video, text-to-speech, music generation, background removal, upscaling, face swap and LLM chat
  • Run a saved workflow: POST /api/v1/workflows/{id}/run returns 202 with an execution_id
  • Poll GET /api/v1/workflows/{id}/runs/{execution_id}, or set a webhook URL on the workflow
  • Per-workflow rate limit you set between 1 and 1,000 runs per minute (default 10)
  • Same API key as every other ModelsLab endpoint, sent as `key` in the body or a `key` header

ComfyUI's own server API vs the ModelsLab Workflows API

Two different products. Pick by what you need to run.

QuestionComfyUI server API (self-hosted)ModelsLab Workflows API
Runs a ComfyUI workflow JSONYesNo — own node format
ComfyUI custom nodesAny you installNo
What a node isA ComfyUI node (sampler, loader, VAE…)A whole ModelsLab model or tool call
GPU you provideYesNone
How you pass inputsEdit node values inside the prompt JSONNamed JSON fields from unconnected node inputs
Getting the resultWebSocket or /history on your serverStatus URL poll or workflow webhook
CostYour hardware and powerEach node billed as its own API call

Checked against the ModelsLab code on 2026-09-23. ComfyUI column describes a ComfyUI server you run yourself.

Workflows API quick start

Replace WORKFLOW_ID with the id shown in the workflow's API settings. The inputs are the fields you left unconnected in the builder.

cURL — run a saved workflow

bash
1curl -X POST 'https://modelslab.com/api/v1/workflows/WORKFLOW_ID/run' \
2 -H 'Content-Type: application/json' \
3 -d '{
4 "key": "YOUR_API_KEY",
5 "prompt": "a ceramic mug on a walnut desk, soft window light"
6 }'
7
8# 202 Accepted
9# {
10# "status": "success",
11# "message": "Workflow execution started.",
12# "execution_id": 1234,
13# "workflow_id": "WORKFLOW_ID",
14# "status_url": "https://modelslab.com/api/v1/workflows/WORKFLOW_ID/runs/1234",
15# "webhook_url": null
16# }

Python — run, then poll for the output

Python
1import time
2import requests
3
4API_KEY = "YOUR_API_KEY"
5WORKFLOW_ID = "WORKFLOW_ID"
6BASE = "https://modelslab.com/api/v1/workflows/" + WORKFLOW_ID
7
8run = requests.post(
9 BASE + "/run",
10 json={"key": API_KEY, "prompt": "a ceramic mug on a walnut desk"},
11).json()
12
13while True:
14 status = requests.get(run["status_url"], headers={"key": API_KEY}).json()
15 state = status["execution"]["status"] # pending, running, completed, failed
16 if state in ("completed", "failed", "cancelled"):
17 break
18 time.sleep(5)
19
20print(status.get("output") or status.get("error"))

cURL — list the inputs a workflow accepts

bash
1curl 'https://modelslab.com/api/v1/workflows/WORKFLOW_ID' \
2 -H 'key: YOUR_API_KEY'
3
4# "parameters": [
5# {"key": "prompt", "node_name": "FLUX Text to Image",
6# "type": "string", "required": true, ...},
7# ...
8# ]

ComfyUI server API example

Runs against the ComfyUI server you start yourself (default address 127.0.0.1:8188). Adapted from the script_examples folder in the ComfyUI repository.

Python — queue an API-format workflow and save the images

Python
1import json
2import time
3import urllib.parse
4import urllib.request
5import uuid
6
7SERVER = "http://127.0.0.1:8188" # your ComfyUI server
8
9# File -> Export (API) in ComfyUI
10workflow = json.load(open("workflow_api.json"))
11workflow["6"]["inputs"]["text"] = "a ceramic mug on a walnut desk" # node 6 = CLIPTextEncode in the default workflow
12
13body = json.dumps({"prompt": workflow, "client_id": str(uuid.uuid4())}).encode()
14queued = json.loads(urllib.request.urlopen(
15 urllib.request.Request(SERVER + "/prompt", data=body)).read())
16prompt_id = queued["prompt_id"]
17
18while True:
19 history = json.loads(urllib.request.urlopen(f"{SERVER}/history/{prompt_id}").read())
20 if prompt_id in history:
21 break
22 time.sleep(1)
23
24for node_output in history[prompt_id]["outputs"].values():
25 for image in node_output.get("images", []):
26 query = urllib.parse.urlencode(
27 {"filename": image["filename"], "subfolder": image["subfolder"], "type": image["type"]})
28 with open(image["filename"], "wb") as f:
29 f.write(urllib.request.urlopen(f"{SERVER}/view?{query}").read())

From a node graph to an endpoint

Four steps, no GPU or server to manage.

STEP 01
STEP 01

Step 1: Build the graph

Open /workflows/builder and drop in ModelsLab nodes, or describe the pipeline and let the AI builder draft it. Connect one node’s output to the next node’s input.

STEP 02
STEP 02

Step 2: Turn on API access

In the workflow’s API settings, enable the API and set a rate limit. Inputs you left unconnected become the endpoint’s parameters. Add a webhook URL if you want a callback.

STEP 03
STEP 03

Step 3: POST the inputs

Send the parameters and your key to /api/v1/workflows/{id}/run. The call returns 202 with an execution_id and a status_url straight away.

STEP 04
STEP 04

Step 4: Collect the output

Poll the status_url until the execution is completed or failed, or wait for the webhook. The response carries the last node’s output URLs.

What a run costs

A workflow has no price of its own. Each node calls the matching ModelsLab endpoint with your key, so a three-node run costs the same as the three API calls made one by one. Self-hosted open-source models come out of your plan (Basic $21/month, Standard $47/month, or unlimited on the $149/month Open Source Unlimited plan); third-party models such as Imagen or Runway are paid from the usage included in Basic or Standard, then from wallet balance, and from wallet balance on Open Source Unlimited. An active plan is required to call the Workflows API.

When to stay on ComfyUI

If your pipeline depends on ComfyUI custom nodes, a specific sampler graph or a checkpoint you load by file, keep running ComfyUI on your own GPU — the Workflows API cannot reproduce it. If your pipeline is a chain of model calls (generate, animate, voice, upscale), the Workflows API replaces the server and the GPU with one HTTP call.

Get Expert Support in Seconds

We're Here to Help.

Want to know more? You can email us anytime at support@modelslab.com

View Docs

Not on ModelsLab. ModelsLab does not host ComfyUI, so it cannot run a ComfyUI workflow JSON; ComfyUI's own server exposes POST /prompt on the machine you run it on. The ModelsLab alternative is its own node-based workflow builder, whose saved workflows run over REST at /api/v1/workflows/{id}/run.

Build it at /workflows/builder and enable API access in its API settings. Then POST the inputs plus your key to https://modelslab.com/api/v1/workflows/{id}/run. The call returns 202 with an execution_id and a status_url; poll GET /api/v1/workflows/{id}/runs/{execution_id} until the status is completed or failed.

No. Nodes in the ModelsLab builder are ModelsLab models and tools, for example Flux text-to-image, image-to-video, text-to-speech, music generation, background removal, upscaling and face swap. ComfyUI custom nodes such as Impact Pack or AnimateDiff do not run here; if you need them, keep a self-hosted ComfyUI server.

Each node is billed as its own API call, so a run costs the same as calling those endpoints one by one. Self-hosted open-source models come out of your plan: Basic $21/month, Standard $47/month, or unlimited on the $149/month Open Source Unlimited plan. Third-party models in a workflow are paid from the usage included in Basic or Standard, then from wallet balance, and from wallet balance on Open Source Unlimited.

Every node input you leave unconnected in the builder becomes a named JSON field of the endpoint, such as prompt or init_image. When two nodes share a field name, the second one gets a prefix. GET /api/v1/workflows/{id} lists the exact parameter keys, types and defaults.

No. Each node runs on ModelsLab's hosted endpoints. Runs are asynchronous: an image node takes seconds and a video node can take minutes, so poll the status_url or set a webhook on the workflow instead of holding a request open.

A workflow is private unless you publish it, and only its owner can call a private workflow through the API. Run status and outputs are returned only to the account that started the run.

Yes, if it includes a video node such as image-to-video. The status response returns the last node's output URLs, so a workflow that ends on a video node returns a video URL. AnimateDiff is a ComfyUI custom node and is not available.

Yes. Build the pipeline once, enable the API, and have your backend POST user inputs to /api/v1/workflows/{id}/run. Set a per-workflow rate limit between 1 and 1,000 runs per minute (the default is 10) in the workflow's API settings.

Send your ModelsLab API key as "key" in the JSON body or as a key request header, the same key as every other ModelsLab endpoint. The Workflows API does not read an Authorization header, and calling it requires an active plan.

Your Data is Secure: GDPR Compliant AI Services

ModelsLab GDPR Compliance Certification Badge

GDPR Compliant