Nodes/ComfyUI API Toolkit/Gemini Text Generation
ComfyUI Node

Gemini Text Generation

Full-featured Gemini text generation with every knob on the table

By IxMxAMAR·Created 5 months ago·Updated 2 months ago· 1
Gemini Text Generation
    • text
    api_key
    modelgemini-2.5-flash
    custom_model
    prompt
    system_instruction
    temperature0.70
    top_p0.95
    top_k0
    max_output_tokens0
    thinking_levelNONE
    thinking_budget0
    seed-1
    safety_settings_json

    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.

    CategoryAPI Toolkit/Gemini/Text

    Inputs (13)

    NameTypeDefaultDescription
    api_keySTRINGGemini API key. Leave blank to use GEMINI_API_KEY env var.
    modelCOMBOgemini-2.5-flashGemini model for text generation.
    custom_modelSTRINGOverride with a custom model ID.
    promptSTRINGThe user prompt to send to the model.
    system_instructionoptSTRINGSystem instruction to guide model behavior.
    temperatureoptFLOAT0.700–2Controls randomness. Lower = more deterministic.
    top_poptFLOAT0.950–1Nucleus sampling probability cutoff.
    top_koptINT00–1000Top-K sampling (0 = disabled).
    max_output_tokensoptINT00–65536Max tokens in response (0 = model default).
    thinking_leveloptCOMBONONEHow much the model should reason before answering.
    thinking_budgetoptINT00–100000Max thinking tokens (0 = model default).
    seedoptINT-1-1–2147483647Random seed for reproducibility (-1 = random).
    safety_settings_jsonoptSTRINGJSON safety settings from Safety Settings node.

    Outputs (1)

    NameTypeDescription
    textSTRING