Skip to main content

Generate Text

Generates text using Google Gemini models with optional file inputs, advanced reasoning, and tool capabilities.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Connection Id - The connection ID obtained from the Connect node (optional if API Key is provided).
  • API Key - Google AI Studio API key (optional if using Connection ID).
  • Use Robomotion AI Credits - Use Robomotion credits instead of your own API key.
  • System Prompt - System instructions for the model to guide behavior and context.
  • User Prompt - The user prompt to send to the model (required).
  • Local File Paths - Local file paths to include with the prompt (images, documents, etc.).
  • Custom Local File Paths - Additional file paths from message scope.
  • Uploaded Files - Previously uploaded files to include (from FileUpload node).

Options

Model Selection

  • Model - The Gemini model to use:
    • Gemini 3 Pro (Preview) - Best quality, advanced reasoning
    • Gemini 2.5 Pro - Balanced performance and cost
    • Gemini 2.5 Flash - Fast, cost-effective (default)
    • Gemini 2.5 Flash-Lite - Ultra-fast, lowest cost
    • Gemini 2.0 Flash - Legacy model
    • Gemini 2.0 Flash-Lite - Legacy lite model
    • Custom Model
  • Custom Model - Custom model name when "Custom Model" is selected.

Generation Settings

  • Number of Generations - Number of text responses to generate (1-4). Default is 1.
  • Stream - Enable streaming for real-time response generation. Default is false.
  • JSON Mode - Force JSON response format. Default is false.
  • Temperature - Controls randomness (0.0-2.0). Higher values make output more random.
  • TopP - Nucleus sampling (0.0-1.0). Controls diversity of responses.
  • TopK - Top-k sampling (1-100). Limits vocabulary at each step.
  • Max Output Tokens - Maximum number of tokens in the response.

Thinking Mode (Gemini 3 Pro and 2.5+ Models)

  • Thinking Mode - Controls model reasoning depth:
    • Auto (Dynamic) - Let the model decide reasoning depth (default)
    • Off - Disable thinking (2.5 Flash only)
    • Low - Minimal reasoning (budget: 1024 tokens)
    • Medium - Moderate reasoning (budget: 8192 tokens)
    • High - Deep reasoning (budget: 16384 tokens)
    • Custom Budget - Specify exact token budget
  • Thinking Budget - Custom thinking token budget (0-24576 for Flash, 128-32768 for Pro).

Tools

  • Enable Code Execution - Allow model to execute code. Default is false.
  • Enable Google Search - Ground responses with Google Search results. Default is false.

Safety Settings

  • Safety Settings Harassment - Block harassment content (Unspecified/Low and Above/Medium and Above/Only High/None).
  • Safety Settings HateSpeech - Block hate speech content.
  • Safety Settings SexuallyExplicit - Block sexually explicit content.
  • Safety Settings DangerousContent - Block dangerous content.
  • Safety Settings Civic Integrity - Block content affecting civic integrity.

Advanced Options

  • Response MIME Type - Format: application/json or text/plain.
  • Response Schema - JSON schema for structured output validation.
  • Presence Penalty - Penalty for new tokens (-2.0 to 2.0).
  • Frequency Penalty - Penalty for repeated tokens (-2.0 to 2.0).
  • Stop Sequences - Pipe-separated stop sequences (e.g., "stop1|stop2").
  • Timeout (seconds) - Request timeout in seconds (default: 60).
  • Include Raw Response - Include full API response in output. Default is false.

Output

  • Text - Generated text - string if 1 generation or array if multiple.
  • Raw Response - Complete API response object (if enabled).

How It Works

The Generate Text node creates text content using Google Gemini models with multimodal inputs. When executed:

  1. Validates connection ID/API key and user prompt
  2. Configures the selected model with all parameters
  3. Processes local files (max 20MB each) and uploaded files
  4. Sets up thinking configuration based on model and mode
  5. Configures safety settings and generation parameters
  6. Sends generation request to Gemini API (or via Robomotion gateway)
  7. Handles response as complete result or stream
  8. Returns generated text in specified format

Thinking Mode Details

Thinking mode enables models to "think" before responding, improving accuracy for complex tasks:

  • Auto: Model dynamically allocates thinking tokens based on task complexity
  • Budget-based (2.5 models): Specify exact token budget for thinking
  • Level-based (Gemini 3 Pro): Use predefined levels (Low/High)
  • Off (2.5 Flash only): Disable thinking for faster responses

Requirements

  • Valid Google Gemini API key or Robomotion credits
  • Connection ID from Connect node (or inline API key)
  • Non-empty user prompt

Error Handling

Common errors:

  • ErrInvalidArg: Empty prompt, invalid model name, missing API key
  • ErrFileNotFound: Local file path doesn't exist
  • ErrFileSize: File exceeds 20MB limit for inline data
  • ErrInvalidParam: Invalid temperature, top_p, top_k, or other parameter values
  • ErrInvalidModel: Model doesn't support requested features (e.g., files)
  • ErrContentBlocked: Content blocked by safety settings
  • ErrUnsupportedFeature: Streaming not supported with Robomotion Credits

Usage Notes

  • Local files limited to 20MB; use FileUpload for larger files
  • Streaming not available when using Robomotion Credits
  • JSON Mode forces application/json MIME type
  • Thinking mode not available on 2.0 Flash Lite
  • Multiple generations not guaranteed to be diverse without temperature > 0
  • Google Search grounding requires supported model
  • Code execution runs in sandboxed environment

Example Use Cases

Extract Structured Data from Invoice

System Prompt: "You are a data extraction assistant. Extract invoice details as JSON."
User Prompt: "Extract the invoice number, date, total amount, and line items from this document."
Local File Paths: ["/path/to/invoice.pdf"]
JSON Mode: true
Response Schema: {"type":"object","properties":{"invoice_number":"string","date":"string","total":"number","items":"array"}}
User Prompt: "Write a 100-word product description for noise-cancelling headphones. Include latest industry trends."
Enable Google Search: true
Temperature: 0.7
Max Output Tokens: 200

Complex Problem Solving

User Prompt: "Solve this math problem step by step: If a train travels at 60 mph for 2.5 hours, then at 80 mph for 1.5 hours, what's the total distance?"
Model: Gemini 3 Pro (Preview)
Thinking Mode: High
Enable Code Execution: true

Multi-turn Document Q&A

System Prompt: "You are analyzing a research paper about climate change."
User Prompt: "What are the main findings regarding ocean temperature?"
Uploaded Files: [uploaded research paper from FileUpload node]
Temperature: 0.3

Generate Multiple Variations

User Prompt: "Write a catchy slogan for an eco-friendly water bottle company."
Number of Generations: 4
Temperature: 1.0

Tips

  • Use Gemini 3 Pro for tasks requiring deep reasoning and analysis
  • Use Gemini 2.5 Flash for most production workloads (best balance)
  • Use Gemini 2.5 Flash-Lite for simple, high-volume tasks
  • Enable Thinking Mode for math, coding, and complex reasoning
  • Use System Prompt to define role, constraints, and output format
  • Set Temperature to 0 for deterministic outputs
  • Set Temperature to 0.7-1.0 for creative tasks
  • Use JSON Mode + Schema for reliable structured data extraction
  • Enable Google Search for current events and factual grounding
  • Use Code Execution for calculations and data processing
  • Adjust Safety Settings based on your use case requirements
  • For large files, use FileUpload node first, then reference in Uploaded Files