ComfyUI Node

Image (OpenRouter)

Gemini image generation from ComfyUI with nothing but an API key

By ZUENS2020·Created 8 months ago·Updated 8 months ago· 0
Image (OpenRouter)
  • config
  • image_1
  • image_2
  • image_3
  • image_4
  • image_5
  • IMAGE
promptA beautiful landscape
n1
additional_text

This is the node you actually came for. "Image (OpenRouter)" is what turns a text prompt into a picture using Gemini - and it does it with zero model downloads, zero VRAM math, and zero sampler arguments. No checkpoint file, no LoRA stack, no scheduler debate. Paste a key, type a prompt, and an IMAGE tensor comes out the other side that you can save, upscale, or feed into whatever else your graph does.

It's the OpenRouter half of the ComfyUI Gemini LiteLLM pack, which splits cleanly in two: a Gemini-LiteLLM category for people running their own LiteLLM proxy, and a Gemini-OpenRouter category for everyone else. This node is the "everyone else" path - OpenRouter gives you Gemini without standing up any server, which is why it's the version beginners actually get working.

How it works

Despite the "Image" name, this node doesn't call an image endpoint. It POSTs to OpenRouter's /chat/completions with modalities: ["image", "text"] and an image_config block carrying your chosen aspect_ratio and image_size. That's the modern Gemini trick: the image model is reached through the chat API, and images come back inline in the message. The node base64-decodes them, converts to a [B, H, W, 3] float tensor, and hands you a perfectly normal ComfyUI IMAGE. It makes a second attempt if the first call fails, then surfaces the error - and the timeout scales with how much work you asked for - 3 minutes at 1K, 5 at 2K, 10 at 4K.

The inputs that matter

  • config - the OR_IMAGE_CONFIG from Image Params (OpenRouter). Not optional; the node has no idea what to do without it.
  • prompt - keep it a plain, descriptive image description. More on that below.
  • n - 1 to 4, default 1. And here's the honest part: it doesn't ask Gemini for n different images. It takes what the API returned and tiles the first one to fill the batch. n=4 gets you four copies of the same picture. Fine if you want a batch, misleading if you expect variety.

Optional image_1 through image_5 turn this into image editing / reference generation - wire in a Load Image and Gemini will treat your picture as input to the prompt. additional_text is a second text field that rides along as an extra message part, handy when you want instructions separated from the prompt.

The single IMAGE output goes straight into Preview Image or Save Image, exactly like a sampler's output would.

Installing it

The pack installs like any custom node, and it's unusually clean:

# ComfyUI Manager: search "Gemini LiteLLM", Install, then restart

# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ZUENS2020/ComfyUI-Gemini-LiteLLM

There's no requirements.txt and nothing to pip install - the whole pack is Python's standard urllib plus numpy/torch/Pillow, which ComfyUI already ships. No model files to hunt down. The only "download" is the API key from openrouter.ai/keys.

Gotchas worth knowing

The one that gets everyone: Gemini will sometimes return text instead of an image. The node then throws "Model returned text instead of image." The README says the fix plainly - overly complex or question-phrased prompts trip it up. Write "a red ceramic bowl on a linen tablecloth, soft window light" not "can you please help me create an image of a bowl with nice lighting in the style that I like?".

Also expect the console to be chatty. The OpenRouter nodes log debug step-by-step noise on every run - that's by design, not an error. And remember you're paying per image, not per render; 4K with retries can get spendy.

Security, briefly: your key sits in the node's value, which means it's embedded in the workflow JSON. Don't share workflows with the key in them, and don't expose ComfyUI to the internet unauthenticated - the ecosystem has had a real malware incident and unauthenticated API warnings for a reason.

CategoryGemini-OpenRouter

Inputs (9)

NameTypeDefaultDescription
configOR_IMAGE_CONFIG
promptSTRINGA beautiful landscape
nINT11–4
image_1optIMAGE
image_2optIMAGE
image_3optIMAGE
image_4optIMAGE
image_5optIMAGE
additional_textoptSTRING

Outputs (1)

NameTypeDescription
IMAGEIMAGE