Gemini 3.5 Flash (openai)
Rewriting prompts mid-graph without leaving the canvas
- text
- raw_json
- credits_consumed
- usage_json
- credits_left
The pattern that earns an LLM its place in a graph isn't chat, it's translation. You have a caption from a captioner, or a rough idea, or a list of scene notes, and you need it in the specific register a diffusion model wants. A text node and an LLM node and you've automated a step you were doing in a browser tab.
This is the Gemini 3.5 Flash node that actually talks to the API: the (openai) route, /gemini-3-5-flash-openai/v1/chat/completions. If you already tried the plain "Gemini 3.5 Flash" node in the same folder and got an unresolved-endpoint error, this is the one you want - same model, same inputs, and an endpoint that's known from first launch.
How it works
Standard chat completion. The pack assembles an OpenAI-style messages array, posts it to KIE, and walks the response looking for text fields - text, output_text, content - joining whatever it finds into one string. It's de-duplicated and order-preserving, which in practice means you get a clean string rather than a JSON blob you have to parse.
Nothing runs on your GPU and there's no image socket. This node is a text transformer with a credit meter.
Wiring it in
The useful shape is a chain: whatever produced your raw text feeds prompt, and text feeds a prompt widget on a generation node. A worked version the community keeps reaching for is local captioning into an API rewrite - a VLM describes the image in full detail locally, then a hosted model turns that description into a prompt tuned for the model you're actually rendering with. Cheap, and it keeps your expensive calls to one per generation.
Two things make chains like that behave:
system_prompt should state the job and forbid the preamble. "Rewrite the input as a single-paragraph prompt for an image model. Output the paragraph only." Without that instruction you'll get "Here is your rewritten prompt:" as the first tokens of your conditioning.
history_json is a prior-messages array, forwarded untouched, so multi-turn is possible if you keep the array yourself. It's also the only route to anything multimodal on this node, because the pack doesn't declare an image input for the Gemini family.
The rest of the inputs
prompt - required, the user message.
tools_json - OpenAI-schema function definitions, [] if you're not using tools. KIE's own docs examples for this family include a googleSearch entry, which is the sort of thing that ends up in here.
stream - off by default, and here's the honest version: the pack reassembles a streamed response into a single string before it reaches you, so switching it on is a transport change, not live typing in the UI. Leave it.
expert_override_json - a raw request override for anything KIE's documentation left undeclared. The tooltip says it's expert-only; take that literally.
Outputs
text is the string you wire. raw_json is the whole provider response when something looks off. usage_json is your token report - the output that tells you a chain is more expensive than it looks. credits_consumed and credits_left are floats, mirrored on the node's face after each run.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/felipederosilva/ComfyUI-KIE-Nodes-Next
Restart, or install via ComfyUI Manager by searching "KIE.ai Nodes Next". The dependency list is requests, Pillow, numpy, PyYAML - nothing model-shaped. Then a one-time key: Settings → KIE.ai Nodes Next → Connection. It's validated against KIE before it overwrites a working key, never goes into workflow JSON, and a headless box can set KIE_API_KEY instead (it wins over the saved key).
Traps
- It runs every queue, and it's metered. An LLM in a loop is a bill in a loop. Put it behind a bypass or a toggle when you're iterating on the image side.
- Flash-tier prose is fine for rewriting and bad for planning. Long structured reasoning is the Pro node's job; using Flash for it is how you end up debugging JSON that was never going to be valid.
- Refusals are the model's, not the node's. There are no weights here to strip; if Google's model declines, you rewrite or you go local.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | User prompt / message. | |
| system_promptopt | STRING | — | |
| streamopt | BOOLEAN | false | — |
| tools_jsonopt | STRING | [] | Optional function/tool definitions supported by this model endpoint. |
| history_jsonopt | STRING | [] | Optional prior message/input array as JSON. |
| expert_override_jsonopt | STRING | {} | Expert-only request overrides. Normal use does not require this. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| raw_json | STRING | — |
| credits_consumed | FLOAT | — |
| usage_json | STRING | — |
| credits_left | FLOAT | — |