Imagen Image Generation
Imagen 4 in ComfyUI, using the other Google image endpoint
- network
- images
Google runs two different image generation APIs, and they are not interchangeable. The ImageGen node in this pack talks to Nano Banana - Gemini's native image output, great at reference-image editing. This node talks to Imagen, which lives on a separate generate_images endpoint and behaves like a classic text-to-image model: prompt in, clean image out, with an explicit negative prompt and no reference-image slot. Imagen is Google's "photorealistic, no-fuss" option, and it's the one you reach for when you want a polished render and you don't need to edit anything.
The node offers the full Imagen 4 lineup: Ultra (highest quality, slowest), Standard (the default, balanced), and Fast (cheaper and quicker). Same prompt works across all three, which makes it easy to A/B your prompt before committing to the expensive pass.
How it works
It calls client.models.generate_images() with a GenerateImagesConfig - a different code path than the Nano Banana node's streaming generate_content. The response comes back as a batch of generated images, which the node decodes into a batched IMAGE tensor.
The inputs that matter:
- model -
imagen-4.0-ultra-generate-001,imagen-4.0-generate-001, orimagen-4.0-fast-generate-001. - prompt - describe the image.
- negative_prompt - things to avoid. Imagen actually honors this, unlike Gemini's image models.
- number_of_images - up to 4 in a single call; all come back as one batch.
- aspect_ratio - Imagen's narrower set: 1:1, 3:4, 4:3, 9:16, 16:9.
- seed - -1 for random; note this release honors seed=0 too (older versions silently dropped it).
- safety_filter_level - defaults to
block_low_and_above. Here's the catch worth reading twice: the free Developer API tier often only acceptsblock_low_and_above; Vertex AI accepts all four levels. If you set a stricter option on the free tier, the API surfaces a clear error rather than quietly ignoring you. - person_generation - whether/how to generate people (
dont_allow,allow_adult,allow_all). Some models enforce stricter defaults regardless.
Output: images - a batched IMAGE tensor.
Installation
Part of the NanoBanana2 pack:
cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai
ComfyUI Manager: search NanoBanana2. Needs a Gemini API key from aistudio.google.com - same key covers both endpoints.
Gotchas
The two-image-APIs confusion is the #1 footgun: drop an Imagen model ID into the Nano Banana node (or a Nano Banana model into this one) and you'll get a confusing 400. Keep Imagen models in this node, period. And the safety filter level is genuinely account-dependent - if you see an error about an unacceptable filter level, that's the free-tier/Vertex difference, not a bug. Finally, if a call comes back with no images at all, the pack raises a "no images returned" error that almost always means the prompt was blocked by safety filters - rephrase, and check your person_generation and filter level settings.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | NanoBanana - API key. Leave blank to use GEMINI_API_KEY env var. | |
| model | COMBO | imagen-4.0-generate-001 | Imagen model. Ultra = highest quality, Standard = balanced, Fast = cheaper/faster. |
| prompt | STRING | Describe the image to generate. | |
| custom_modelopt | STRING | Override with a custom model ID (takes priority over dropdown). | |
| number_of_imagesopt | INT | 11–4 | How many images to generate in one call (Imagen supports up to 4). |
| aspect_ratioopt | COMBO | 1:1 | Output aspect ratio. Imagen supports: 1:1, 3:4, 4:3, 9:16, 16:9. |
| negative_promptopt | STRING | Things to avoid in the image. | |
| seedopt | INT | -1-1–2147483647 | Seed for reproducibility. -1 = random. (0 is a valid seed for some models — v2.0 silently dropped seed=0; v2.1 honors it. Use -1 for random.) |
| safety_filter_levelopt | COMBO | block_low_and_above | Safety filter threshold. Developer API often only accepts block_low_and_above on free tier; Vertex AI supports all four. API surfaces a clear error if the level isn't accepted for your model/account. |
| person_generationopt | COMBO | allow_adult | Whether/how to generate people. Some models enforce stricter defaults. |
| networkopt | NB_NETWORK | Optional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |