Relay Image Generator
Closed Image Models, Dropped Straight Into Your Graph
- image1
- image2
- image3
- image4
- image5
- image6
- image7
- image8
- image9
- image10
- image11
- image12
- image13
- image14
- image15
- image16
- image
- response
- image_url
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 structuredimageConfigfor ratio and size.v1/images- the OpenAI images endpoint. Forgpt-image2the node converts yourratio+sizeinto exact pixel dimensions (2K+1:1becomes2048x2048), 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/queryuntil 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.image1…image16- 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 atgpt-image2;formatis 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.
Inputs (24)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| ratio | COMBO | 1:1 | 16 options: auto, 1:1, 2:3, 3:2, 4:3, 3:4, +10 |
| size | COMBO | 2K | 3 options: 1K, 2K, 4K |
| quality | COMBO | medium | 4 options: low, medium, high, auto |
| format | COMBO | jpeg | 3 options: jpeg, png, webp |
| moderation | COMBO | low | 2 options: auto, low |
| seed | INT | 00–18446744073709550000 | — |
| infoopt | STRING | — | |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| image5opt | IMAGE | — | |
| image6opt | IMAGE | — | |
| image7opt | IMAGE | — | |
| image8opt | IMAGE | — | |
| image9opt | IMAGE | — | |
| image10opt | IMAGE | — | |
| image11opt | IMAGE | — | |
| image12opt | IMAGE | — | |
| image13opt | IMAGE | — | |
| image14opt | IMAGE | — | |
| image15opt | IMAGE | — | |
| image16opt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| response | STRING | — |
| image_url | STRING | — |