05 Gemini Chat and Save to ZMongo
One node, generate and persist in a single run
- session
- json
- gemini_text
- refresh
- success
05 Gemini Chat and Save to ZMongo is the automation-focused Gemini node: it sends a prompt to Gemini and writes the response into a ZMongo document, all in one execution. Where Prompt from ZMongo Doc reads a document into Gemini, this one writes Gemini's output back out - closing the loop in the other direction.
Think of the workflow it's built for: a batch of jobs, each of which should end with "generate an analysis with Gemini, then store it with its source." One node, one run, and the result is already filed in your database - no separate save step, no manual copy-paste, no chance of the response getting lost between nodes.
How it works
Required inputs:
session- from the API Key Session node.prompt- what to ask Gemini.collection_name/document_id- where the response lands. If you supply adocument_id, it updates that document; if not, it creates (upserts) one.query_json- Mongo-style selector (default{}) to locate the target document.target_field_path- where in the document the response goes, defaultgemini.response. Dot-paths work.model,max_output_tokens,temperature- usual knobs.upsert- defaulttrue: insert if the document doesn't exist, update if it does.
Optional: system_instruction, save_full_payload (default false - when true it stores the entire Gemini response object instead of just the text), gemini_prefix.
Outputs:
json- merged payload (Gemini response + save result).gemini_text- the generated text, so downstream nodes can use it without re-reading the database.refresh- dirty token for forcing downstream refreshes after the write.success- boolean. Note it's the AND of both halves: Gemini succeeded and the save succeeded. The message distinguishes "Gemini response generated, but ZMongo save failed."
Notes
- Two things can fail independently. The node is honest about that:
successis false if either the call or the write failed, and the message tells you which. When debugging, readjson- it nests both payloads. save_full_payloadis the power option. False saves just the text; true stores the whole response object (metadata, usage, the works) - great when you want an audit trail of every call, at the cost of fatter documents.- Keep
target_field_pathunique per purpose (gemini.response,gemini.summary, …) so different analyses don't overwrite each other in the same document.
Install
ComfyUI Manager → ComfyUI-ZMongo, or:
cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo
restart. Server-side Gemini via the API session; the save goes through the same session. The pack's heavy requirements.txt still installs on first import, but this node is a thin client.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| prompt | STRING | — | |
| collection_name | STRING | — | |
| document_id | STRING | — | |
| query_json | STRING | {} | — |
| target_field_path | STRING | gemini.response | — |
| model | STRING | gemini-2.5-flash | — |
| max_output_tokens | INT | 20481–65536 | — |
| temperature | FLOAT | 0.500–2 | — |
| upsert | BOOLEAN | true | — |
| system_instructionopt | STRING | — | |
| save_full_payloadopt | BOOLEAN | false | — |
| gemini_prefixopt | STRING | /gemini | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| gemini_text | STRING | — |
| refresh | STRING | — |
| success | BOOLEAN | — |