Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Building ComfyUI custom nodes for a remote generation API: polling, tensors, VIDEO outputs and keeping keys out of workflows

ComfyUI is usually about running models on your own GPU, but a growing number of node packs call remote APIs instead: the graph stays local, the heavy lifting happens on someone else's hardware. I recently wrote one of these, comfyui-vellria , which wraps Vellria, a hosted image and video generation API ( vellria.com ). It is MIT licensed and small (five short Python modules), so it makes a…

ComfyUI is commonly used for running models locally on a GPU, but many node packs now call remote APIs instead. One example is comfyui-vellria, which wraps a hosted image and video generation API called Vellria. This post focuses on the more challenging aspects of creating custom nodes for such remote generation APIs.

ComfyUI discovers custom nodes in the ComfyUI/custom_nodes/ directory and imports them as Python packages. Each node is a simple class with several key components: INPUT_TYPES defines the necessary widgets and sockets, RETURN_TYPES specifies the outputs, and FUNCTION indicates the method ComfyUI will call. This classic interface is kept for compatibility with older ComfyUI installations.

For the root __init__.py file, ComfyUI checks if it's being loaded as a package (as in a ComfyUI environment) or as a standalone module (like when being tested with pytest). This ensures the module imports cleanly in both contexts. Additionally, the node pack fetches the list of available models via a GET /v1/models request, with a 5-second timeout and several fallback options in case of network issues or JSON errors.

The asynchronous nature of image and video generation on the Vellria API means that a POST request returns a 202 status code with a job ID. The client then needs to poll the GET /v1/generations/{id} endpoint until the job's status is either completed or failed. The poll interval starts at 2 seconds and increases by 1.25 times for each subsequent attempt, up to a maximum of 8 seconds. The node must handle transient errors gracefully, retrying up to five times before raising an exception.

Cancellation is often overlooked but crucial. When a user cancels a job in the ComfyUI queue, the node must check for a cancellation flag using comfy.model_management.throw_exception_if_processing_interrupted(). This ensures that the Python thread dedicated to the job can be interrupted, preventing it from running indefinitely. If a node simply sleeps for a fixed duration without checking for cancellation, it may continue running for up to 8 seconds per poll, wasting resources.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Why 1.26 cubic metres of concrete comes out as 70 bags, or 71, depending on where you round

A 4 by 3 metre slab at 100 mm deep is 1.2 cubic metres. Add the usual 5 percent margin and you have 1.26. Divide by the yield on the bag and the order should be 70 bags.

  • Concrete volume, margin, bag yield, and rounding precision determine bag count
  • 4 m by 3 m slab with 0.1 m depth requires 1.26 cubic meters of concrete
  • Rounding 70.00000000000001 up yields 71 bags, but rounding ratio first yields 70 bags

Multipath TCP vs Single-Path TCP: Why One Connection Refuses to Pick a Lane

For decades, a TCP connection has been defined by four numbers: the two addresses and the two ports at either end. Change one of them and the connection is over.

  • Multipath TCP (MP-TCP) maintains connection identity across network changes.
  • MP-TCP adds connection-level layer for seamless handshakes and subflow management.
  • Benefits include bandwidth aggregation and network continuity, but deployment faces challenges.

A peso that is worth zero for 55 steps, and the median ceases to be the median

A weight that is worth zero for 55 steps, and the median ceases to be the median The number An estimator of mine published 2.2380708362e+251 as the median of 3894 values.

  • A fictitious weight of zero affected 55 steps in a calculation
  • Median changed from correct value of 6.8003333871e+250 to 2.2380708362e+251
  • Problem occurred when scale exceeded representable state

Twelve questions before any code

We're building a product for small organizations, and its newest piece is a tracked list of work with approval steps. When someone asks for something, it's held until a person says yes, then handed to…

  • Twelve questions addressed before coding began for small organization software
  • Final decision rested with intended users, not developers
  • Privacy ensured by limiting access to relevant roles only

My O(n ) Algorithm Ran in O(n) — and Why That Meant My Stress Test Was Wrong

For my algorithms course, I solved three variants of the text segmentation problem with dynamic programming, proved them correct, and stress-tested them. The most useful part wasn't the algorithms.

  • Student ran three variants of text segmentation problem using dynamic programming
  • Stress test showed variant (b) was linear (O(n)) instead of expected O(n²)
  • Inner loop optimization reduced IsWord calls from 2,001,000 to 2,000

More from Saturday, 28 November 2026 →