ComfyUI Node

AQ_Gemini

JSON out, images in

By 2frames·Created about a year ago·Updated 6 months ago· 1
AQ_Gemini
  • image
  • response
  • formatted_response
  • instruction
gemini_api_key
model_selectiongemma-3-12b-it
custom_model
prompt
system_messageYou are a helpful assistant.
temperature1.00
top_k64
top_p0.95
enable_jsonfalse
json_schema{ "type": "object", "required": ["description", "style"], "properties": { "description": { "type": "string" }, "style": { "type": "string" }, "tags": { "type": "array", "items": { "type": "string" } } } }
result_template

The general-purpose LLM call node in this pack. No local model, no GPU - just a Google AI API key. Text in, text out, with an optional image input, structured JSON output, and a template formatter. It's the "ask an LLM anything inside a workflow" node, and it's genuinely useful for prompt building, captioning, and structured metadata extraction without installing a local model.

How it works

It uses the google-genai client and streams generate_content. The model_selection dropdown covers the gemma-3 family (1b/4b/12b/27b - served on Google's AI API, which has a real free tier) plus gemini 2.5, 2.0, and 1.5. Pick custom and fill in custom_model to point at anything the API serves.

The JSON path is the interesting part. Enable enable_json, paste a JSON schema into json_schema, and - for non-gemma models - the node sets response_mime_type: application/json plus response_schema, so the API itself enforces valid JSON. Gemma models don't support schema-based JSON on this API, so for those it just instructs via the prompt and hopes. result_template then formats the returned JSON into a plain string using {json[field]} placeholders - the same trick as AQ_Qwen - so you can convert a structured answer into, say, a ready-to-use prompt.

Images: any IMAGE tensor gets baked to a PNG and sent inline as base64, so you can ask the model about a picture. System message, temperature (0–2), top_k (default 64), and top_p are all there.

Inputs that matter

  • gemini_api_key - paste your key. It's a plain string field and it's stored in the workflow file, so don't share the workflow.
  • model_selection / custom_model - pick the brain.
  • prompt, system_message - the ask and the persona.
  • enable_json, json_schema, result_template - the structured-output path.
  • image (optional) - vision input.

Outputs

response (raw text), formatted_response (template-applied), and instruction (a string the node carries that explains how to use it - handy when you forget).

Install

Part of AQnodes:

cd ComfyUI/custom_nodes
git clone https://github.com/2frames/ComfyUI-AQnodes
cd ComfyUI-AQnodes
pip install -r requirements.txt

or search "AQnodes" in ComfyUI Manager and restart. The requirements file pulls in google-generativeai and google-genai for this family.

Gotchas

Three things to know. First, the default model is gemma-3-12b-it - and schema-based JSON silently doesn't apply to gemma models, so if you need guaranteed-valid JSON, pick a gemini model instead. Second, this node swallows errors by design: a bad key returns empty strings plus the instruction string instead of crashing, which means blank outputs and no obvious error. Check the console if you get nothing. Third, the key lives in plain text inside the workflow JSON - fine for personal use, a leak waiting to happen if you share files. And if you want the same idea with a fixed music-metadata schema, that's AQ_Gemini_acstep15.

CategoryAquasite/LLM

Inputs (12)

NameTypeDefaultDescription
gemini_api_keySTRING
model_selectionCOMBOgemma-3-12b-it17 options: gemma-3-12b-it, gemma-3-1b-it, gemma-3-4b-it, gemma-3-27b-it, gemini-2.5-flash-preview-04-17, gemini-2.5-pro-preview-05-06, +11
custom_modelSTRING
promptSTRING
system_messageSTRINGYou are a helpful assistant.
temperatureFLOAT1.000–2
top_kINT640–100
top_pFLOAT0.950–1
enable_jsonBOOLEANfalse
json_schemaSTRING{ "type": "object", "required": ["description", "style"], "properties": { "description": { "type": "string" }, "style": { "type": "string" }, "tags": { "type": "array", "items": { "type": "string" } } } }
result_templateSTRING
imageoptIMAGE

Outputs (3)

NameTypeDescription
responseSTRING
formatted_responseSTRING
instructionSTRING