Nodes/AI_Text_Comfyui/Gemini Image 2 Prompt
ComfyUI Node

Gemini Image 2 Prompt

The name is a lie — it's OpenAI vision, and it's handy anyway

By Zch6111·Created about a year ago·Updated about a year ago· 1
Gemini Image 2 Prompt
  • main_image
  • background_image
  • prompt
api_key
model

Let's get the elephant out of the room: this node is called Gemini Image 2 Prompt, and there is no Gemini anywhere in it. The model dropdown offers gpt-4o, gpt-4, and gpt-3.5-turbo. The code calls OpenAI's vision endpoint. Whatever the author had in mind when they picked the name, what you're getting is an OpenAI-vision captioner that reads two images and writes you one combined prompt. Read the box before you buy, as they say - then note it's actually a decent little tool.

It's the third node in the AI_Text_Comfyui pack by Zch6111, and the README's "added a node to read image style and theme" is this one. The idea: give it a subject image and a background scene image, and it produces a prompt describing the subject placed within the scene - ready to feed back into img2img, Redux, or any re-render workflow where you want a natural-language description of a composite instead of guessing at words.

How it works

Mechanically it's straightforward. Each input image tensor gets normalized, converted to PNG bytes, and base64-encoded. Then the node makes two separate vision calls to api.openai.com/v1/chat/completions - one asking for a description of the "main subject," one for the "background scene" - each prompting for Description, Style, and Language fields at temperature 0.5.

A small parser reads those labeled lines out of each response, and the node stitches them into a single prompt:

<main subject description> placed within <background scene description>.
This image is rendered in <style> style, using <language> language.
Focus on mood, lighting, and artistic detail.

If the model skips a field, it falls back to cinematic style and natural language, so the output always comes back valid - just sometimes blander than you'd like.

The inputs

Only four, and they're mostly self-explanatory:

  • api_key - note the default here is empty, not sk-xxx. You must paste a key or the calls fail.
  • main_image (IMAGE) - the subject shot: the person, character, or object you want described.
  • background_image (IMAGE) - the scene it should live in.
  • model - and here's the trap: pick gpt-4o. It's the only realistic choice, because gpt-3.5-turbo can't accept image content at all, and gpt-4 is ancient by now. If you choose wrong, you'll get an error back from the API.

Output is a single prompt (STRING) - the composed description, ready to drop into any positive-prompt input.

Install

Same story as the rest of the pack: no dependencies, no model downloads, no requirements file. It only needs Python's stdlib plus PIL/numpy/torch that ComfyUI already bundles.

cd ComfyUI/custom_nodes
git clone https://github.com/Zch6111/AI_Text_Comfyui

Restart and it shows up as Gemini Image 2 Prompt under flux/prompt. Or ComfyUI Manager → Install Custom Nodes → search AI_Text_Comfyui → install → restart.

Gotchas

Two worth naming. First, unlike the other two nodes in this pack, this one calls api.openai.com directly - no third-party relay. That's actually good for privacy (your key goes to OpenAI and nowhere else), but it means it needs a genuine OpenAI key, not whatever compatible key a proxy would accept. Second, a single run costs two vision API calls, one per image, so it's not free to spam in a batch queue. And if the composed prompt feels stiff, that's the fixed template talking - you'll want to massage the output before it goes into your sampler.

It's a niche node for a specific move - merging a subject and a backdrop into one caption - but when that's exactly what you're doing, it beats handwriting the description yourself.

Categoryflux/prompt

Inputs (4)

NameTypeDefaultDescription
api_keySTRING
main_imageIMAGE
background_imageIMAGE
modelCOMBO3 options: gpt-4o, gpt-4, gpt-3.5-turbo

Outputs (1)

NameTypeDescription
promptSTRING