Skip to content

API documentationΒ #2110

Open
Open

Description

@kanbekotori

Where can I get the documentation for the comfyui api, like what are the urls and descriptions of the parameters and such.

Activity

  1. DuckyBlender commented on Mar 16, 2024

    @DuckyBlender

    Is there going to be more documented API? Two file examples isn't an API documentation

  2. johnbenac commented on Mar 20, 2024

    @johnbenac

    Yes, I want to build a GUI using Vue, that grabs images created in input or output folders, and then lets the users call the API by filling out JSON templates that use the assets already in the comfyUI library.

    Say, for example, you want to upscale an image, and you may want to use different models to do the upscale. The GUI would show you all the models that you can use, polled from the models folder, and it will also give you a gallery of images presented on the client on the client machine (What is the API endpoint that will enable this? Is there an API endpoint for this? Can I add one?) and then when the user selects an image on their client machine, it sends the path of that image where it lives on the server in the API call to the server.

    What are the API endpoints that will enable this?

    I know that there are api endpoint that give you the models. Even just a simple readme that points to the the file where the API endpoints are defined.

  3. johnbenac commented on Mar 21, 2024

    @johnbenac
  4. DuckyBlender commented on Apr 30, 2024

    @DuckyBlender

    This file seems somewhat self explanatory:

    [ComfyUI/web/scripts /api.js](https://github.com/comfyanonymous/ComfyUI/blob/master/web/scripts/api.js)

    LLAMA 3 generated documentation based on this file:

    Endpoints

    GET Endpoints

    /prompt

    • Returns the current status of the prompt queue
    • Response: JSON object with status information

    /extensions

    • Returns a list of extension URLs to import
    • Response: JSON array of script URLs

    /embeddings

    • Returns a list of embedding names
    • Response: JSON array of embedding names

    /object_info

    • Returns node object definitions for the graph
    • Response: JSON object with node definitions

    /queue

    • Returns the current state of the queue
    • Response: JSON object with running and pending items

    /history

    • Returns the prompt execution history
    • Response: JSON object with history items

    /system_stats

    • Returns system and device stats
    • Response: JSON object with system stats

    /settings

    • Returns all setting values for the current user
    • Response: JSON object with setting values

    /settings/:id

    • Returns a specific setting value for the current user
    • Response: JSON value of the setting

    /userdata/:file

    • Returns a user data file for the current user
    • Response: File contents

    POST Endpoints

    /prompt

    • Queues a new prompt
    • Request Body: JSON object with prompt data
    • Response: JSON object with queue status

    /interrupt

    • Interrupts the execution of the running prompt
    • Response: JSON object with interrupt status

    /users

    • Creates a new user
    • Request Body: JSON object with username
    • Response: JSON object with user data

    /settings

    • Stores a dictionary of settings for the current user
    • Request Body: JSON object with setting values
    • Response: JSON object with setting values

    /settings/:id

    • Stores a specific setting value for the current user
    • Request Body: JSON value of the setting
    • Response: JSON object with setting value

    /userdata/:file

    • Stores a user data file for the current user
    • Request Body: File contents
    • Response: JSON object with file upload status

    DELETE Endpoints

    /queue/:id

    • Deletes an item from the queue
    • Response: JSON object with delete status

    /history/:id

    • Deletes an item from the history
    • Response: JSON object with delete status

    Note that this documentation only covers the endpoints and methods defined in the provided JavaScript file. There may be additional endpoints or methods not included in this documentation.

  5. JulianKingman commented on Jun 19, 2024

    @JulianKingman

    Would a PR with API documentation be welcome/accepted?

  6. Spritan commented on Aug 25, 2024

    @Spritan

    is there any /health endpint to acertain if my comfyui instance is running

  7. ltdrdata commented on Aug 25, 2024

    @ltdrdata
    Member

    is there any /health endpint to acertain if my comfyui instance is running

    You can utilize /system_stats.

  8. TimRutjens04 commented on Nov 28, 2024

    @TimRutjens04

    I've found the API code, not much of an addition to the response of @DuckyBlender but it's something I guess, its over here: https://github.com/comfyanonymous/ComfyUI/blob/master/server.py

    All code for the endpoints are found here, hope it might help give a little more understanding on how to use them

  9. lim3light commented on Feb 13, 2025

    @lim3light

    Is there proper documentation with all recorded endpoints and info about them? I want to use img2img, but not sure what's the right endpoint to upload the images.

  10. christian-byrne commented on Feb 13, 2025

    @christian-byrne
    Contributor

    Is there proper documentation with all recorded endpoints and info about them? I want to use img2img, but not sure what's the right endpoint to upload the images.

    https://docs.comfy.org/essentials/comms_routes

    https://docs.comfy.org/essentials/comfyui-server/comms_messages#built-in-message-types

  11. dattazigzag commented on Apr 6, 2025

    @dattazigzag

    I have summarized my learnings here in COMFYUI_API.md πŸ₯³

    The above repo also has a simple combined python script to test the major API endpoints (the ones that are not implemented in the python script are marked accordingly in the API doc).

    The diff between this script and the other example scripts is that mine has a good verbose of execution states and flow steps (based on websocket info).

    This helped me to put everything together and thus I'm sharing it with the world hoping this would help others too.
    One key think I found missing was the API interaction sequence diagram.
    So, I created that too and added that in my API doc.
    The mermaid diagram is there but you can also check it out here (for any corrections)

  12. saurabhthesuperhero commented on Apr 8, 2025

    @saurabhthesuperhero

    @dattazigzag can you help me,,

    What i am doing is , parsing the JSON of orignal workflow, with object_info and trying to use connecitons nodes and build the workflow which can be send to prompt endpoint,
    But this code of making prompt is not that great some how its as below ::
    Problem is for now its working for Loras simple thats it, but cant work for any other lie if i have ipadapter or in middle i muted the workflow etc.
    Do you know how comfyUI does that ? or how I can do it ?? its in kotlin code.

    private fun analyzeWorkflowForAPIPrompt(uiWorkflow: UiWorkflow): Pair<Set<String>, Map<String, Map<Int, Pair<String, Int>>>> {
        // Set of nodes that will be excluded from the API prompt (only bypassed/muted nodes)
        val excludedNodes = mutableSetOf<String>()
    
        // Identify nodes to exclude based solely on mode
        for (node in uiWorkflow.nodes) {
            // Exclude nodes that are bypassed/muted (mode = 4)
            if (node.mode == 4) {
                excludedNodes.add(node.id)
                Log.d(TAG, "Excluding bypassed/muted node ${node.id} (type=${node.type}, mode=${node.mode}) from API prompt")
            }
        }
    
        // Connection remapping: for each node that gets input from an excluded node,
        // remap to get input from the excluded node's input or a suitable alternative.
        val connectionRemapping = mutableMapOf<String, MutableMap<Int, Pair<String, Int>>>()
    
        // Build maps for easier analysis
        val linkMap = mutableMapOf<Int, UiLink>() // linkId -> UiLink
        val nodeInputs = mutableMapOf<String, MutableMap<Int, Int>>() // nodeId -> (slotIndex -> linkId)
        val nodeOutputs = mutableMapOf<String, MutableMap<Int, MutableList<Int>>>() // nodeId -> (slotIndex -> list of linkIds)
    
        // Populate linkMap
        uiWorkflow.links.forEach { link ->
            linkMap[link.id] = link
        }
    
        // Populate nodeInputs
        uiWorkflow.nodes.forEach { node ->
            nodeInputs[node.id] = mutableMapOf()
            node.inputs.forEachIndexed { index, input ->
                if (input.link != null && !input.link.isJsonNull && input.link.isJsonPrimitive && input.link.asJsonPrimitive.isNumber) {
                    nodeInputs[node.id]!![index] = input.link.asInt
                }
            }
        }
    
        // Populate nodeOutputs
        uiWorkflow.nodes.forEach { node ->
            nodeOutputs[node.id] = mutableMapOf()
            node.outputs.forEachIndexed { index, output ->
                if (output.links != null && output.links.isNotEmpty()) {
                    nodeOutputs[node.id]!![index] = output.links.toMutableList()
                }
            }
        }
    
        // Process excluded nodes to remap their connections
        for (excludedNodeId in excludedNodes) {
            // For each output slot of the excluded node, process its links
            val excludedNodeOutputMap = nodeOutputs[excludedNodeId] ?: continue
            for ((outputSlot, links) in excludedNodeOutputMap) {
                for (linkId in links) {
                    val link = linkMap[linkId] ?: continue
                    val targetNodeId = link.target_id
                    val targetSlot = link.target_slot
    
                    // Skip if target node is also excluded
                    if (targetNodeId in excludedNodes) continue
    
                    // Get the target node and its input for the target slot
                    val targetNode = getNodeById(uiWorkflow, targetNodeId) ?: continue
                    if (targetSlot >= targetNode.inputs.size) continue
                    val targetInput = targetNode.inputs[targetSlot]
                    val expectedType = if (!targetInput.type.isJsonNull && targetInput.type.isJsonPrimitive) {
                        targetInput.type.asString
                    } else {
                        ""
                    }
    
                    // Special case for muted nodes: skip the connection if no valid input found
                    if (targetNode.mode == 4) {
                        // Skip this connection as the target node is muted and the input is required
                        continue
                    }
    
                    if (targetNode.type == "SaveImage") {
                        // Special case: For SaveImage nodes, connect to VAEDecode output if possible
                        val vaeDecodeNode = uiWorkflow.nodes.find { it.type == "VAEDecode" && it.id !in excludedNodes }
                        if (vaeDecodeNode != null) {
                            Log.d(TAG, "Remapping SaveImage input: node ${targetNodeId} slot $targetSlot to VAEDecode ${vaeDecodeNode.id} slot 0")
                            connectionRemapping.getOrPut(targetNodeId) { mutableMapOf() }[targetSlot] = Pair(vaeDecodeNode.id, 0)
                        }
                    } else {
                        // Try to find the appropriate input remap based on type matching
                        var chosenMapping: Pair<String, Int>? = null
                        var fallbackMapping: Pair<String, Int>? = null
    
                        // Get all candidate inputs from the excluded node
                        val excludedInputs = nodeInputs[excludedNodeId] ?: continue
                        for ((inputSlot, candidateLinkId) in excludedInputs) {
                            val candidateLink = linkMap[candidateLinkId] ?: continue
                            val candidateSourceNodeId = candidateLink.origin_id
                            val candidateSourceSlot = candidateLink.origin_slot
    
                            // Skip if candidate source is also excluded
                            if (candidateSourceNodeId in excludedNodes) continue
    
                            // Save the first found mapping as a fallback
                            if (fallbackMapping == null) {
                                fallbackMapping = Pair(candidateSourceNodeId, candidateSourceSlot)
                            }
    
                            // Try to obtain candidate type from the excluded node’s input at the candidate slot
                            if (inputSlot < targetNode.inputs.size) {
                                val candidateInput = targetNode.inputs[inputSlot]
                                val candidateType = if (!candidateInput.type.isJsonNull && candidateInput.type.isJsonPrimitive) {
                                    candidateInput.type.asString
                                } else {
                                    ""
                                }
                                if (candidateType == expectedType) {
                                    chosenMapping = Pair(candidateSourceNodeId, candidateSourceSlot)
                                    break
                                }
                            }
                        }
    
                        // Apply the chosen mapping or fallback
                        val mappingToApply = chosenMapping ?: fallbackMapping
                        if (mappingToApply != null) {
                            connectionRemapping.getOrPut(targetNodeId) { mutableMapOf() }[targetSlot] = mappingToApply
                            Log.d(TAG, "Remapped: target node $targetNodeId slot $targetSlot now uses source ${mappingToApply.first} slot ${mappingToApply.second}")
                        } else {
                            Log.d(TAG, "Could not find a suitable input remap for node $targetNodeId slot $targetSlot")
                        }
                    }
                }
            }
        }
    
        // Return the set of nodes to exclude and the connection remapping
        return Pair(excludedNodes, connectionRemapping)
    }
    
  13. dattazigzag commented on Apr 8, 2025

    @dattazigzag

    What i am doing is , parsing the JSON of orignal workflow, with object_info and trying to use connections nodes and build the workflow which can be send to prompt endpoint,

    To understand correctly, you are just trying to parse out prompt values from the json. from CLIP Text Encode Node?
    workflow json (full workflow export) or workflow api json (linked)?

  14. saurabhthesuperhero commented on Apr 9, 2025

    @saurabhthesuperhero

    @dattazigzag
    So i am first converting to Object_info

    and finding, input output of node and their connections and linearly, sending this data into prompt.
    but this part of connections etc not quite well.

  15. dattazigzag commented on Apr 9, 2025

    @dattazigzag

    @dattazigzag So i am first converting to Object_info

    and finding, input output of node and their connections and linearly, sending this data into prompt. but this part of connections etc not quite well.

    • Maybe create a separate issue.
    • I'm not clear about your ask on what you are trying to do: why do you want to know, in your words, "... input output of node and their connections " to pass it to prompt? you want to check what nodes are connected to each other, from the json Object? If so, why ?
    • If you want to update a prompt (text node), you can simply modify the parameters in the object and pass the object as BODY to the/prompt endpoint.

    Say, the exported workflow (api) json, has a text node:

    "3": {
        "inputs": {
          "text": " ...",
          "clip": [
            "1",
            1
          ]
        },
        "class_type": "CLIPTextEncode",
        "_meta": {
          "title": "<what ever name you gave to the node>"
        }
      }

    The "3" is not fixed and could be any number based on your workflow ... and you can use the 'title' string as a unique identifier instead of the Node ID. Based on that you can update the 'text' and make a POST with the updated json object as the request's BODY .

    Are you looking a generic universal parsing function for any kind of workflow api Json object to parse specific node values?
    I'm not sure what you are trying to do. May be take some time to explain better the context and your requirements.

  16. saurabhthesuperhero commented on Apr 9, 2025

    @saurabhthesuperhero

    @dattazigzag Sorry for insufficient , requirements.

    • first my update a prompt (text node), etc task is wroking for eg for simple workflow which contains : checkpoint, lora and and output image , ksampler i am able to parse it even with changes

    What i want and what i am facing issue with ?
    So i have tons of workflows saved which uses various nodes, for eg some are using face id node, some use reactor face swap, now i am using f5tts node, and many time workflows nodes are muted,by passed (as i am checking it by 4,2 etc)
    My logic of parsing to api json flow is not correct

    Or in one line
    Yes i need unversal function which can parse any workflow json with any nodes or connecitons muted bypassed, any type of complexity into Prompt json !!
    They way comfy is doing itself. thank you

    hope my requirement is clear

  17. AbrahamN commented on Aug 14, 2025

    @AbrahamN

    An updated reference of the API in the new ComfyUI's electron app (inspired by @DuckyBlender Llama3, this is done by Gemini's long context)

    HTTP API endpoints available in the ComfyUI server, based on server.py.

    Note: All endpoints are also available with an /api prefix. For example, /prompt can also be accessed at /api/prompt.


    WebSocket

    GET /ws

    Establishes a WebSocket connection for real-time communication between the frontend and backend.

    • Query Parameters:

      • clientId (optional): A unique identifier for the client. If provided, the server will try to reuse an existing session.
    • Communication:

      • The server sends status updates, execution progress, preview images, and feature flags.
      • The client can send feature flags upon connection.
    • JavaScript Client Example:

      const server_address = "127.0.0.1:8188";
      const client_id = "your_client_id_here"; // Or generate a UUID
      
      const ws = new WebSocket(`ws://${server_address}/ws?clientId=${client_id}`);
      
      ws.onopen = () => {
          console.log("WebSocket connection established.");
          // You can send feature flags or other initial messages here if needed.
          // ws.send(JSON.stringify({ type: "feature_flags", data: { your_flag: true } }));
      };
      
      ws.onmessage = (event) => {
          if (typeof event.data === "string") {
              const data = JSON.parse(event.data);
              console.log("Received JSON message:", data);
              // Handle different message types
              if (data.type === 'status') {
                  console.log("Queue status:", data.data.status.exec_info.queue_remaining);
              } else if (data.type === 'executing') {
                  console.log("Currently executing node:", data.data.node);
              }
          } else {
              // Handle binary data (like preview images)
              console.log("Received binary message of size:", event.data.size);
          }
      };
      
      ws.onerror = (error) => {
          console.error("WebSocket error:", error);
      };
      
      ws.onclose = () => {
          console.log("WebSocket connection closed.");
      };
    • Python Client Example:

      import websocket
      import json
      import uuid
      
      server_address = "127.0.0.1:8188"
      client_id = str(uuid.uuid4())
      
      def on_message(ws, message):
          # The server sends both text and binary messages
          if isinstance(message, str):
              data = json.loads(message)
              # Handle different message types
              if data['type'] == 'status':
                  print(f"Queue remaining: {data['data']['status']['exec_info']['queue_remaining']}")
              elif data['type'] == 'executing':
                  node_id = data['data']['node']
                  if node_id is None:
                      print("Execution finished")
                  else:
                      print(f"Executing node: {node_id}")
              else:
                  print("Received other message type:", data['type'])
          else:
              # Handle binary preview images
              print("Received a binary message (preview image)")
      
      
      def on_error(ws, error):
          print(f"WebSocket Error: {error}")
      
      def on_close(ws, close_status_code, close_msg):
          print("### WebSocket closed ###")
      
      def on_open(ws):
          print("WebSocket connection opened")
      
      if __name__ == "__main__":
          ws_url = f"ws://{server_address}/ws?clientId={client_id}"
          ws = websocket.WebSocketApp(ws_url,
                                    on_open=on_open,
                                    on_message=on_message,
                                    on_error=on_error,
                                    on_close=on_close)
      
          ws.run_forever()

    File & Asset Endpoints

    GET /

    Serves the main index.html file for the ComfyUI frontend.

    • Response:
      • Content-Type: text/html
      • The main HTML page.

    GET /embeddings

    Retrieves a list of available embedding names.

    • Example Response:
      [
        "embedding1",
        "embedding2"
      ]

    GET /models

    Retrieves a list of available model types (the names of the model folders).

    • Example Response:
      [
        "checkpoints",
        "loras",
        "vae",
        "controlnet"
      ]

    GET /models/{folder}

    Retrieves a list of available models within a specific folder.

    • Path Parameters:
      • folder: The name of the model folder (e.g., checkpoints).
    • Example Response (/models/checkpoints):
      [
        "v1-5-pruned-emaonly.ckpt",
        "sd_xl_base_1.0.safetensors"
      ]

    GET /extensions

    Retrieves a list of custom frontend extensions.

    • Example Response:
      [
        "/extensions/core/previews.js",
        "/extensions/my_nodes/stuff.js"
      ]

    POST /upload/image

    Uploads an image to a specified directory.

    • Request Body: multipart/form-data
      • image: The image file to upload.
      • overwrite (optional): If set to true or 1, overwrites an existing file with the same name.
      • subfolder (optional): The subfolder within the type directory to save the image.
      • type (optional): The directory type. Can be input, output, or temp. Defaults to input.
    • Example Response:
      {
        "name": "example.png",
        "subfolder": "optional_subfolder",
        "type": "input"
      }
    • JavaScript Upload Example:
      <input type="file" id="fileInput" />
      <button onclick="uploadImage()">Upload Image</button>
      
      <script>
      async function uploadImage() {
          const fileInput = document.getElementById('fileInput');
          const file = fileInput.files[0];
          if (!file) {
              alert("Please select a file first.");
              return;
          }
      
          const formData = new FormData();
          formData.append("image", file);
          formData.append("overwrite", "true"); // or "false"
          formData.append("subfolder", "my_images");
          formData.append("type", "input");
      
          try {
              const response = await fetch("http://127.0.0.1:8188/upload/image", {
                  method: 'POST',
                  body: formData,
              });
              const data = await response.json();
              console.log("Upload successful:", data);
          } catch (error) {
              console.error("Error uploading file:", error);
          }
      }
      </script>
    • Python Upload Example:
      import requests
      
      server_address = "127.0.0.1:8188"
      file_path = "path/to/your/image.png"
      url = f"http://{server_address}/upload/image"
      
      with open(file_path, "rb") as f:
          files = {
              'image': (file_path, f, 'image/png')
          }
          data = {
              'overwrite': 'true',
              'subfolder': 'my_images',
              'type': 'input'
          }
          response = requests.post(url, files=files, data=data)
      
      if response.status_code == 200:
          print("Image uploaded successfully:", response.json())
      else:
          print("Error uploading image:", response.status_code, response.text)

    POST /upload/mask

    Uploads a mask and applies it as the alpha channel to an existing image.

    • Request Body: multipart/form-data
      • image: The mask image file.
      • original_ref: A JSON string referencing the original image to apply the mask to.
      • Other parameters are the same as /upload/image.
    • Example Response:
      {
        "name": "masked_image.png",
        "subfolder": "",
        "type": "output"
      }
    • JavaScript Upload Example:
      <label>Mask File:</label>
      <input type="file" id="maskFileInput" />
      <button onclick="uploadMask()">Upload Mask</button>
      
      <script>
      async function uploadMask() {
          const fileInput = document.getElementById('maskFileInput');
          const file = fileInput.files[0];
          if (!file) {
              alert("Please select a mask file first.");
              return;
          }
      
          const original_ref = JSON.stringify({
              filename: "original_image.png",
              type: "output",
              subfolder: "my_images"
          });
      
          const formData = new FormData();
          formData.append("image", file);
          formData.append("original_ref", original_ref);
      
          try {
              const response = await fetch("http://127.0.0.1:8188/upload/mask", {
                  method: 'POST',
                  body: formData,
              });
              const data = await response.json();
              console.log("Mask upload successful:", data);
          } catch (error) {
              console.error("Error uploading mask:", error);
          }
      }
      </script>
    • Python Upload Example:
      import requests
      import json
      
      server_address = "127.0.0.1:8188"
      mask_path = "path/to/your/mask.png"
      url = f"http://{server_address}/upload/mask"
      
      original_ref = {
          "filename": "original_image.png",
          "type": "output",
          "subfolder": "my_images"
      }
      
      with open(mask_path, "rb") as f:
          files = {
              'image': (mask_path, f, 'image/png')
          }
          data = {
              'original_ref': json.dumps(original_ref)
          }
          response = requests.post(url, files=files, data=data)
      
      if response.status_code == 200:
          print("Mask uploaded successfully:", response.json())
      else:
          print("Error uploading mask:", response.status_code, response.text)

    GET /view

    Retrieves and displays an image or file from the output, input, or temp directories.

    • Example URL: /view?filename=example.png&subfolder=foo&type=output
    • Response:
      • The raw file data with the appropriate Content-Type.

    GET /view_metadata/{folder_name}

    Retrieves metadata from a .safetensors model file.

    • Example URL: /view_metadata/checkpoints?filename=model.safetensors
    • Example Response:
      {
        "ss_sd_model_name": "v1-5-pruned-emaonly",
        "ss_resolution": "512,512",
        "ss_clip_skip": "2"
      }

    System & Queue Endpoints

    GET /system_stats

    Retrieves statistics about the server's system and GPU devices.

    • Example Response:
      {
        "system": {
          "os": "posix",
          "ram_total": 67325669376,
          "ram_free": 58778599424,
          "comfyui_version": "1.2.3",
          "python_version": "3.10.9"
        },
        "devices": [
          {
            "name": "NVIDIA GeForce RTX 4090",
            "type": "cuda",
            "index": 0,
            "vram_total": 25757220864,
            "vram_free": 23358472192,
            "torch_vram_total": 25757220864,
            "torch_vram_free": 23358472192
          }
        ]
      }

    GET /features

    Retrieves a list of server-side feature flags.

    • Example Response:
      {
          "custom_nodes_from_web": true
      }

    POST /prompt

    Submits a workflow (prompt) to the queue for execution.

    • Example Request Body:
      {
        "prompt": {
          "3": {
            "class_type": "KSampler",
            "inputs": {
              "model": ["4", 0],
              "positive": ["6", 0],
              "negative": ["7", 0],
              "latent_image": ["5", 0],
              "seed": 8566257,
              "steps": 20,
              "cfg": 8,
              "sampler_name": "euler",
              "scheduler": "normal",
              "denoise": 1
            }
          },
          "4": {
            "class_type": "CheckpointLoaderSimple",
            "inputs": { "ckpt_name": "v1-5-pruned-emaonly.ckpt" }
          },
          "5": {
            "class_type": "EmptyLatentImage",
            "inputs": { "width": 512, "height": 512, "batch_size": 1 }
          },
          "6": {
            "class_type": "CLIPTextEncode",
            "inputs": { "clip": ["4", 1], "text": "masterpiece, best quality, a friendly robot" }
          },
          "7": {
            "class_type": "CLIPTextEncode",
            "inputs": { "clip": ["4", 1], "text": "bad anatomy, worst quality" }
          },
          "8": {
            "class_type": "VAEDecode",
            "inputs": { "samples": ["3", 0], "vae": ["4", 2] }
          },
          "9": {
            "class_type": "SaveImage",
            "inputs": { "filename_prefix": "ComfyUI", "images": ["8", 0] }
          }
        },
        "client_id": "your_client_id_here"
      }
    • Example Response:
      {
        "prompt_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
        "number": 42,
        "node_errors": {}
      }

    GET /prompt

    Retrieves the current status of the execution queue.

    • Example Response:
      {
        "exec_info": {
          "queue_remaining": 1
        }
      }

    GET /queue

    Retrieves the running and pending items in the prompt queue.

    • Example Response:
      {
        "queue_running": [
          [ 1, "a1b2c3d4...", {}, { "client_id": "..." } ]
        ],
        "queue_pending": [
          [ 2, "b2c3d4e5...", {}, { "client_id": "..." } ]
        ]
      }

    POST /queue

    Modifies the prompt queue.

    • Example Request Body (to delete items):
      {
        "delete": ["a1b2c3d4...", "b2c3d4e5..."]
      }
    • Response:
      • 200 OK

    POST /interrupt

    Interrupts the currently executing task.

    • Response:
      • 200 OK

    POST /free

    Frees up system and/or VRAM.

    • Example Request Body:
      {
          "unload_models": true,
          "free_memory": true
      }
    • Response:
      • 200 OK

    History Endpoints

    GET /history

    Retrieves the execution history.

    • Example Response:
      {
        "a1b2c3d4-e5f6-7890-1234-567890abcdef": {
          "prompt": [ 1, "a1b2...", {}, {} ],
          "outputs": {
            "9": {
              "images": [
                {
                  "filename": "ComfyUI_00001_.png",
                  "subfolder": "",
                  "type": "output"
                }
              ]
            }
          }
        }
      }

    GET /history/{prompt_id}

    Retrieves a specific entry from the execution history.

    • Example Response:
      {
        "prompt": [ 1, "a1b2...", {}, {} ],
        "outputs": {
          "9": {
            "images": [
              {
                "filename": "ComfyUI_00001_.png",
                "subfolder": "",
                "type": "output"
              }
            ]
          }
        }
      }

    POST /history

    Modifies the execution history.

    • Example Request Body (to clear history):
      {
        "clear": true
      }
    • Response:
      • 200 OK

    Node & Object Info Endpoints

    GET /object_info

    Retrieves detailed information about all available node classes.

    • Example Response (truncated):
      {
        "CheckpointLoaderSimple": {
          "input": {
            "required": {
              "ckpt_name": [ [ "model1.safetensors", "model2.ckpt" ], {} ]
            }
          },
          "output": [ "MODEL", "CLIP", "VAE" ],
          "output_is_list": [ false, false, false ],
          "output_name": [ "MODEL", "CLIP", "VAE" ],
          "name": "CheckpointLoaderSimple",
          "display_name": "Load Checkpoint",
          "description": "",
          "category": "loaders",
          "output_node": false
        }
      }

    GET /object_info/{node_class}

    Retrieves detailed information for a single node class.

    • Example Response (/object_info/KSampler):
      {
        "KSampler": {
          "input": {
            "required": {
              "model": [ "MODEL", {} ],
              "seed": [ "INT", { "default": 0, "min": 0, "max": 18446744073709551615 } ],
              "steps": [ "INT", { "default": 20, "min": 1, "max": 10000 } ],
              "cfg": [ "FLOAT", { "default": 8, "min": 0, "max": 100 } ],
              "sampler_name": [ [ "euler", "dpm_fast" ], {} ],
              "scheduler": [ [ "normal", "karras" ], {} ],
              "positive": [ "CONDITIONING", {} ],
              "negative": [ "CONDITIONING", {} ],
              "latent_image": [ "LATENT", {} ],
              "denoise": [ "FLOAT", { "default": 1, "min": 0, "max": 1 } ]
            }
          },
          "output": [ "LATENT" ],
          "output_is_list": [ false ],
          "output_name": [ "LATENT" ],
          "name": "KSampler",
          "display_name": "KSampler",
          "description": "",
          "category": "sampling",
          "output_node": false
        }
      }
  18. NorthernNoober commented on Jan 16, 2026

    @NorthernNoober

    Has anybody had an issue with Python script using a workflow's API.json resulting in the workflow running and generating the proper output, but ended with the workflow hanging up and not seemingly ending? By which I mean the green bar across the top of ComfyUI remains and a "(0%) ??? (100%)" is seen in the far left of the green bar? That's what I'm getting for some reason. While my API call from python works and produces the correct output, I have to re-start comfyui after running the script if I want to run another workflow again (whether manually or through the python script).

  19. dattazigzag commented on Jan 17, 2026

    @dattazigzag

    Has anybody had an issue with Python script using a workflow's API.json resulting in the workflow running and generating the proper output, but ended with the workflow hanging up and not seemingly ending? By which I mean the green bar across the top of ComfyUI remains and a "(0%) ??? (100%)" is seen in the far left of the green bar? That's what I'm getting for some reason. While my API call from python works and produces the correct output, I have to re-start comfyui after running the script if I want to run another workflow again (whether manually or through the python script).

    So,

    So what does the log of ComfyUI says?
    Do you mean the Comfy Server Hangs (gets blocked) and can't execute any other workflow or workflow call (via API)
    May be add eject models and clear cache nodes in your workflow and to be triple sure also call, via api to clear cache

  20. NorthernNoober commented on Jan 17, 2026

    @NorthernNoober

    Thanks for the response. The issue was I had one terminal running comfy with its venv, then I had another terminal where I created a venv for my python API script and activated that venv, and then ran the python script from there.

    The solution was to activate the venv for comfy in the second terminal and run the python API script.

  21. dattazigzag commented on Jan 19, 2026

    @dattazigzag

    Thanks for the response. The issue was I had one terminal running comfy with its venv, then I had another terminal where I created a venv for my python API script and activated that venv, and then ran the python script from there.

    The solution was to activate the venv for comfy in the second terminal and run the python API script.

    Okay, So, both are running now? The comfy server as well as your python script (that uses comfy API and talks to the comfy server) ?

  22. NorthernNoober commented on Jan 19, 2026

    @NorthernNoober

    Yes, both are running and both are using the comfy venv, and now the comfy API completes without hanging up the workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions