Nodes/ComfyUI-ZMongo/05 Gemini JSON
ComfyUI Node

05 Gemini JSON

Getting structured output instead of prose

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
05 Gemini JSON
  • session
  • json
  • parsed_or_text
  • success
promptReturn a JSON object.
schema_json{}
modelgemini-2.5-flash
max_output_tokens2048
temperature0.20
system_instruction
gemini_prefix/gemini
refresh_token

05 Gemini JSON sends a prompt to Gemini and gets back a JSON object shaped to your spec, instead of freeform prose. It's the node that turns an LLM from a text generator into something you can actually build a pipeline around - because JSON you can parse is data, and data can drive logic.

This is where ZMongo's two halves click together. Everything in this pack is built around structured documents in a database; a Gemini call that returns unstructured text is awkward to store. Gemini JSON's whole point is producing output that fits naturally into a ZMongo document - parameters, decisions, metadata - without you parsing a wall of prose.

How it works

Required inputs:

  • session - from the API Key Session node.
  • prompt - what you're asking for (default "Return a JSON object.").
  • schema_json - the shape you want back, as a JSON schema. Defaults to {} (anything goes); the more you fill this in, the more reliably the model conforms. Give it fields, types, required keys - the backend passes the schema through to Gemini's structured-output handling.
  • model - default gemini-2.5-flash.
  • max_output_tokens - default 2048.
  • temperature - default 0.2. For structured output, low is right; you want deterministic-ish, not creative.

Optional: system_instruction, gemini_prefix, refresh_token.

It POSTs to /gemini/api/json. Outputs:

  • json - the full backend payload (for debugging).
  • parsed_or_text - the useful one: the parsed JSON object serialized back to text if the model returned parseable structured output, or the raw text if it didn't. Either way you get something usable.
  • success - boolean.

Notes

  • Write a real schema. schema_json: {} is a "best effort" - Gemini may return JSON, but it won't be your JSON. A schema with explicit keys and types ({"type":"object","properties":{"positive":{"type":"string"},"cfg":{"type":"number"}}}) is the difference between data you can use and text you have to wrangle.
  • Temperature 0.2 default is deliberate. Structured output and high temperature fight each other. If your JSON keeps coming back malformed, lower it, don't raise it.
  • Because parsed_or_text is a plain STRING, you can drop it straight into a ZMongo document field or feed it to a JSON-parse node downstream.

Install

ComfyUI Manager → ComfyUI-ZMongo, or:

cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo

restart. Server-side Gemini call through the API session - thin local client, heavy pack requirements.txt on first import regardless.

CategoryZMongo/06 Gemini

Inputs (9)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
promptSTRINGReturn a JSON object.
schema_jsonSTRING{}
modelSTRINGgemini-2.5-flash
max_output_tokensINT20481–65536
temperatureFLOAT0.200–2
system_instructionoptSTRING
gemini_prefixoptSTRING/gemini
refresh_tokenoptSTRING

Outputs (3)

NameTypeDescription
jsonSTRING
parsed_or_textSTRING
successBOOLEAN