✍️ Grsai LLM/VLM Writer
Ask Gemini for prompts, get a CSV ready for your batch node
- image_1
- image_2
- image_3
- file_path
- status
The pack's most self-aware node. Its default prompt is literally "请为我生成5条关于'夏日海滩'的Midjourney绘画prompt" - "generate 5 Midjourney drawing prompts about summer beach" - which tells you the whole intended job: use Gemini to write a batch of generation prompts, then save them straight to a CSV/Excel file that the pack's batch nodes can consume. It's the missing handoff between "thinking about prompts" and "GrsaiNanoBananaBatch / MJ batch reads a prompt column."
The practical loop the author is clearly running: GRSAIVLMNode or this node looks at reference images (it accepts up to three) or just reads the main prompt → Gemini produces a JSON-ish list → the node parses it → writes generated_prompts.csv into your ComfyUI output folder → point a batch node at that file. End to end, closed model writes the plan, another closed model executes it, all inside ComfyUI.
The inputs that matter
model- the same Gemini family; defaultgemini-3-flash(cheap and fast - right default for bulk prompt-writing).main_prompt(multiline) - the instruction. "Give me 5 prompts about X in Y style" is the shape it's tuned for.system_prompt(default "You are a helpful assistant.") - the system context, useful for constraining tone or format.output_filename(defaultgenerated_prompts.csv) - where the file lands, relative to the ComfyUI output dir. Must end in.csv,.xls, or.xlsx.column_name(defaultprompt) - the header for the single written column. Match this to what your batch node expects.api_key,image_1…image_3(optional) - reference images for vision-guided prompt generation.
Outputs: file_path (STRING - the full written path) and status (STRING - record count + filename).
How it works
Readable source. It builds a chat request (system + text prompt, plus base64 images if connected), POSTs to the Grsai /v1/chat/completions endpoint, then extracts a list from the reply - it looks for a [...] JSON block first, and falls back to splitting the text into non-empty lines. That flexibility matters, because Gemini doesn't always return clean JSON; the fallback keeps the pipeline alive. It writes with utf-8-sig for CSV so Excel opens Chinese text without mojibake - a small detail, but a deliberate one.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/jieg9341-lab/ComfyUI-nkxx
restart (or ComfyUI Manager, "ComfyUI-nkxx"). Auto-installs requests, pandas, openpyxl, yt-dlp, opencv-python, aiohttp. Grsai key from nkxx.grsai.ai.
Common issues
- File written but only one row: the list-extraction fell back to line-splitting and the model returned prose. Ask explicitly for "a numbered list" or "JSON array" in
main_promptand retry. - Output not found: it lands in your ComfyUI
output/folder (same place Save Image writes), not the pack folder - check there. - Column mismatch downstream: whatever you set as
column_namehere must match thecolumn_nameof the batch node that reads it. Keep both asprompt. - Cost: flash is cheap per call, but it's still metered - batch prompt-writing across thousands of variants adds up line by line.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | gemini-3-flash | 5 options: gemini-3-flash, gemini-3-pro, gemini-3.1-pro, gemini-2.5-flash, gemini-2.5-flash-lite |
| main_prompt | STRING | 请为我生成5条关于“夏日海滩”的Midjourney绘画prompt | — |
| system_prompt | STRING | You are a helpful assistant. | — |
| output_filename | STRING | generated_prompts.csv | — |
| column_name | STRING | prompt | — |
| api_keyopt | STRING | — | |
| image_1opt | IMAGE | — | |
| image_2opt | IMAGE | — | |
| image_3opt | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| file_path | STRING | — |
| status | STRING | — |