05 Gemini JSON
Getting structured output instead of prose
- session
- json
- parsed_or_text
- success
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- defaultgemini-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_textis 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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| prompt | STRING | Return a JSON object. | — |
| schema_json | STRING | {} | — |
| model | STRING | gemini-2.5-flash | — |
| max_output_tokens | INT | 20481–65536 | — |
| temperature | FLOAT | 0.200–2 | — |
| system_instructionopt | STRING | — | |
| gemini_prefixopt | STRING | /gemini | — |
| refresh_tokenopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| parsed_or_text | STRING | — |
| success | BOOLEAN | — |