Gemini Text Generation
Full-featured Gemini text generation with every knob on the table
- text
If the Gemini service in this pack has a Swiss Army node, this is it. Text Generation is the general-purpose generate_content call with every meaningful knob exposed: temperature, top-p, top-k, max output tokens, thinking level and budget, seed, system instruction, and safety settings. One node, one prompt, text out. It's the node you reach for when the specialized ones (Prompt Refiner, Structured Output, Multi-Turn) are too specific - you just need Gemini to write something, and you need control over how.
Where it earns its place in a workflow: generating dialogue for a video you're about to lip-sync, drafting a caption from an image description, producing variation text for a batch, or driving a multi-step pipeline where one node's text output becomes the next node's input. It's the text engine; everything else is frosting.
How it works
A straightforward generate_content call wrapped in the pack's retry-with-backoff logic. All the sampling parameters - temperature, top_p, top_k - go into the generation config exactly as you'd set them on the raw API. The thinking controls are worth understanding because they're the modern twist: thinking_level (NONE/LOW/NORMAL/HIGH) tells a reasoning-capable model how much to reason before answering, and thinking_budget caps the tokens it may spend doing it. These cost extra - thinking tokens are billed - so the default NONE is the frugal choice.
Inputs and outputs that matter
The required trio: api_key (or GEMINI_API_KEY env var), model (35 options spanning Gemini 3 previews, 2.5, 2.0, the Gemma open-models-on-Google's-infra, and specialized previews), and prompt.
The optional set is where the power is:
system_instruction- the personality/rules input. Underused by beginners, and it's the difference between a generic answer and a targeted one.temperature- 0.7 default; lower for deterministic, higher for variety.max_output_tokens- 0 means the model's default cap; set it to bound a long-winded model.thinking_level/thinking_budget- reasoning depth and its token budget.seed- defaults to -1 (random); set ≥0 for reproducible runs.safety_settings_json- wire the Safety Settings node's output here.
One output: text (STRING).
How to install it
Pack-level, like the rest:
cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-API-Toolkit
cd ComfyUI-API-Toolkit
pip install -r requirements.txt
or "API Toolkit" from ComfyUI Manager. Needs google-genai>=0.8.0 and a key.
Common issues
The one that bites people: thinking models and cost. Bump thinking_level to HIGH on gemini-3-pro-preview and every call gets noticeably slower and pricier, because you're paying for the reasoning tokens. If your workflow just needs text, keep it at NONE and spend the budget where it matters.
Also remember this is an API node - the pack forces re-execution on every queue, so each run is a fresh paid call, and the content filter applies. If your prompt gets a refusal, that's Google's policy at the platform level, not something the node can route around. For the kind of text a local uncensored model would give you, this isn't the tool - but for anything above-board that needs frontier-chat quality inside a graph, it's the one to use.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | Gemini API key. Leave blank to use GEMINI_API_KEY env var. | |
| model | COMBO | gemini-2.5-flash | Gemini model for text generation. |
| custom_model | STRING | Override with a custom model ID. | |
| prompt | STRING | The user prompt to send to the model. | |
| system_instructionopt | STRING | System instruction to guide model behavior. | |
| temperatureopt | FLOAT | 0.700–2 | Controls randomness. Lower = more deterministic. |
| top_popt | FLOAT | 0.950–1 | Nucleus sampling probability cutoff. |
| top_kopt | INT | 00–1000 | Top-K sampling (0 = disabled). |
| max_output_tokensopt | INT | 00–65536 | Max tokens in response (0 = model default). |
| thinking_levelopt | COMBO | NONE | How much the model should reason before answering. |
| thinking_budgetopt | INT | 00–100000 | Max thinking tokens (0 = model default). |
| seedopt | INT | -1-1–2147483647 | Random seed for reproducibility (-1 = random). |
| safety_settings_jsonopt | STRING | JSON safety settings from Safety Settings node. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |