Nodes/ComfyUI-nkxx/✍️ Grsai LLM/VLM Writer
ComfyUI Node

✍️ Grsai LLM/VLM Writer

Ask Gemini for prompts, get a CSV ready for your batch node

By nkxx188·Created 11 months ago·Updated 6 months ago· 14
✍️ Grsai LLM/VLM Writer
  • image_1
  • image_2
  • image_3
  • file_path
  • status
modelgemini-3-flash
main_prompt请为我生成5条关于“夏日海滩”的Midjourney绘画prompt
system_promptYou are a helpful assistant.
output_filenamegenerated_prompts.csv
column_nameprompt
api_key

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; default gemini-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 (default generated_prompts.csv) - where the file lands, relative to the ComfyUI output dir. Must end in .csv, .xls, or .xlsx.
  • column_name (default prompt) - the header for the single written column. Match this to what your batch node expects.
  • api_key, image_1image_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_prompt and 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_name here must match the column_name of the batch node that reads it. Keep both as prompt.
  • Cost: flash is cheap per call, but it's still metered - batch prompt-writing across thousands of variants adds up line by line.
CategoryNkxx/Grsai/语言模型

Inputs (9)

NameTypeDefaultDescription
modelCOMBOgemini-3-flash5 options: gemini-3-flash, gemini-3-pro, gemini-3.1-pro, gemini-2.5-flash, gemini-2.5-flash-lite
main_promptSTRING请为我生成5条关于“夏日海滩”的Midjourney绘画prompt
system_promptSTRINGYou are a helpful assistant.
output_filenameSTRINGgenerated_prompts.csv
column_nameSTRINGprompt
api_keyoptSTRING
image_1optIMAGE
image_2optIMAGE
image_3optIMAGE

Outputs (2)

NameTypeDescription
file_pathSTRING
statusSTRING