Nodes/comfyui_bmad_nodes/CreateRequestMetadata
ComfyUI Node Runs on cloud

CreateRequestMetadata

A JSON breadcrumb so scripts know what your render did

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
CreateRequestMetadata
      request_idinsert_id

      Most ComfyUI workflows end with an image. API-driven workflows end with a contract: some external script fires a render, waits, and needs to know what happened. CreateRequestMetadata is the starting point of this pack's barebones API machinery - a node that writes a small JSON status file into ComfyUI's output folder, keyed by a request_id, so an outside process can check whether the request started, finished, or failed, and find the files that were produced.

      Let me be upfront about scope, because the author is: the README explicitly says they won't document the API nodes and that there are "better, more comprehensive and already documented solutions" for API requests. This node is the pack's own lightweight approach, not a replacement for a proper queueing system.

      How it works

      CreateRequestMetadata is an output node (it has no outputs). It takes a single input, request_id (a STRING, default "insert_id"), and when the workflow runs it:

      1. Validates the request_id - leaving it as "insert_id" raises an error on purpose, telling you to set it.
      2. Enforces that only one instance of the node exists in the workflow (a second one trips an assertion).
      3. Writes {request_id}.json into ComfyUI's output directory, with a starting payload of {"state": "started", "outputs": []}.

      Then the other API nodes in this pack extend that file as the workflow proceeds: SetRequestStateToComplete flips state to "complete" (and clears the request id), a companion error-handling path sets state to "failed", and the pack's save nodes register produced files under outputs. Your external script reads the JSON file to learn the request's lifecycle.

      How you'd use it

      This only makes sense in an automated setup - a script that POSTs a workflow to ComfyUI, polls for the metadata file, and parses state and outputs to grab results. If you're running ComfyUI by hand in a browser, this node does nothing useful for you; skip it. If you're building a small pipeline around ComfyUI's HTTP API, it's a workable (if barebones) way to signal completion without parsing the API's own outputs.

      The contract to keep straight:

      • The file lives in ComfyUI's output folder, named exactly {request_id}.json.
      • state is "started" at first, then "complete" or "failed".
      • outputs lists the resource files the API nodes registered.

      The catches

      • Only one per workflow. If a template ends up with two, the run errors with "You may have more than one CreateRequestMetadata node."
      • "insert_id" is a sentinel, not a default you can run with. The error message will tell you exactly that.
      • It writes files into your output directory by design - that's the mechanism, and it means every request leaves a JSON breadcrumb behind.
      • The README's honest note stands: for serious API work, look at the well-documented request frameworks before committing to this.

      Install

      cd ComfyUI/custom_nodes
      git clone https://github.com/bmad4ever/comfyui_bmad_nodes
      cd comfyui_bmad_nodes
      pip install -r requirements.txt
      

      or install "comfyui_bmad_nodes" via ComfyUI Manager and restart. No models, no extra dependencies. If you're not scripting ComfyUI, you don't need it - but if you are, this is the pack's answer to "how does my script know it's done?"

      CategoryBmad/api

      Inputs (1)

      NameTypeDefaultDescription
      request_idSTRINGinsert_id

      Outputs (0)

      No outputs