Nodes/ComfyUI-relayapi/Relay Image Generator
ComfyUI Node

Relay Image Generator

Closed Image Models, Dropped Straight Into Your Graph

By flywhale-666·Created 5 months ago·Updated 3 months ago· 49
Relay Image Generator
  • image1
  • image2
  • image3
  • image4
  • image5
  • image6
  • image7
  • image8
  • image9
  • image10
  • image11
  • image12
  • image13
  • image14
  • image15
  • image16
  • image
  • response
  • image_url
prompt
ratio1:1
size2K
qualitymedium
formatjpeg
moderationlow
seed0
info

Nano Banana, GPT Image, the Gemini image models - you cannot download any of them, no matter how much VRAM you own. RelayImageGenerator is the back door: it takes your prompt (and up to sixteen reference images), phones a relay station that fronts those closed models, and drops the result back onto your canvas as a plain IMAGE tensor. To the rest of your workflow it looks like a local sampler. Underneath it's an HTTP client with a key baked in, and a job that can take a while.

This is the node people actually buy the pack for. The other generators are nice-to-have; this one is the reason a "relay API" pack exists at all.

How it works

The node reads the info JSON from Relay API Settings, grabs api_base, apikey, model and api_format, and dispatches to one of four request styles:

  • v1beta/models - Gemini's native API, sending your prompt and images as inline base64 parts with a structured imageConfig for ratio and size.
  • v1/images - the OpenAI images endpoint. For gpt-image2 the node converts your ratio + size into exact pixel dimensions (2K + 1:1 becomes 2048x2048), and it explicitly asks for base64 output because several relays' URL mode runs slow or not at all.
  • v1/chat/completions - chat-based generation. The node doesn't trust the relay to honor a structured size, so it pastes your ratio into the prompt itself ("请生成宽高比为 21:9 的图片…" - please generate an image with a 21:9 aspect ratio).
  • runninghub-/openapi/v2 - the RunningHub async path: upload your reference images via /openapi/v2/media/upload/binary, submit a text-to-image or image-to-image job, then poll /openapi/v2/query until it's done.

The node then decodes the returned image (base64 or a URL it downloads) into a tensor. On failure it doesn't crash the queue - it emits an ExecutionBlocker on the image output and a {"code":"error","message":...} JSON on response, so your workflow keeps running and you can see what went wrong.

Inputs and outputs that matter

  • prompt - the text prompt (or the edit instruction, if you're feeding reference images).
  • ratio - auto, 1:1, 16:9, 9:21, up to extreme 1:8 / 8:1 on banana-2. The list is filtered per platform.
  • size - 1K / 2K / 4K.
  • image1image16 - optional IMAGE inputs; wire a reference for image-to-image or edit. Which count matters depends on the model (gpt-image2 takes up to 16, Nano Banana up to 14).
  • quality / moderation / format - mostly aimed at gpt-image2; format is a leftover slot you can leave at jpeg.
  • seed - ComfyUI-local only. It never goes to the API, it just controls re-runs and caching.

Outputs: image (wire it into a Save Image or any IMAGE consumer), response (a trimmed JSON - big base64 chunks are elided so display nodes don't choke), and image_url (the URL, when the relay returned one).

Installing the pack

cd ComfyUI/custom_nodes
git clone https://github.com/flywhale-666/ComfyUI-relayapi

…or search "ComfyUI-relayapi" in ComfyUI Manager, then restart. Nothing extra to pip-install or download - ComfyUI already bundles the requests and Pillow this node runs on.

Gotchas

Timeouts are the first thing you'll meet: a 4K job can legitimately run 300–800 seconds, and the node's timeouts are tuned for that, so "it hung" is often just "it's still cooking." Second, remember the key-to-relay rule - a key from yunwu won't work against RunningHub's base, and you'll get a JSON parse error that looks nothing like an auth failure. Third, this is the pay-per-call world: every queue run bills you, and unlike the local path there's no "free after electricity." If your content would trip a hosted filter, the relay's model still refuses at the source - no local bypass exists. RelayImageGenerator is the right tool for a model you cannot run, and the wrong default for one you can.

CategoryRelayAPI

Inputs (24)

NameTypeDefaultDescription
promptSTRING
ratioCOMBO1:116 options: auto, 1:1, 2:3, 3:2, 4:3, 3:4, +10
sizeCOMBO2K3 options: 1K, 2K, 4K
qualityCOMBOmedium4 options: low, medium, high, auto
formatCOMBOjpeg3 options: jpeg, png, webp
moderationCOMBOlow2 options: auto, low
seedINT00–18446744073709550000
infooptSTRING
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
image5optIMAGE
image6optIMAGE
image7optIMAGE
image8optIMAGE
image9optIMAGE
image10optIMAGE
image11optIMAGE
image12optIMAGE
image13optIMAGE
image14optIMAGE
image15optIMAGE
image16optIMAGE

Outputs (3)

NameTypeDescription
imageIMAGE
responseSTRING
image_urlSTRING