Skip to main content

Generate Text

Generates text using AI models through OpenRouter with support for reasoning mode, structured outputs, and multi-generation 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 identifier from Connect node (optional if API Key is provided directly).
  • System Prompt - System instructions to guide the AI assistant behavior. Default: "You are a helpful assistant."
  • User Prompt - The message or question to send to the AI model. This is required and cannot be empty.

Options

Authentication

  • API Key - OpenRouter API key credential (optional if using Connection Id). Allows using the node without Connect.
  • Use Robomotion AI Credits - Use Robomotion AI credits instead of your own API key.

Model Selection

  • Model - Select which AI model to use. Options include:
    • Gemini 2.5 Flash - Fast and efficient (default)
    • Gemini 2.5 Pro - Advanced capabilities
    • Gemini 3 Pro Preview - Latest Gemini preview
    • Claude Sonnet 4 - Balanced performance
    • Claude Sonnet 4.5 - Latest Sonnet version
    • Claude Opus 4 - Highly capable
    • Claude Opus 4.5 - Most capable Claude
    • GPT-4.1 - Latest GPT-4 generation
    • GPT-4.1 Mini - Faster GPT-4
    • GPT-5 - Latest GPT generation
    • GPT-5 Mini - Faster GPT-5
    • o3 - OpenAI reasoning model
    • o3 Mini - Smaller reasoning model
    • o4 Mini - Latest mini reasoning model
    • Grok 4 - xAI's Grok model
    • Grok 4.1 - Latest Grok version
    • DeepSeek Chat v3 - DeepSeek model
    • Custom Model - Specify any OpenRouter model
  • Custom Model - Custom model identifier when "Custom Model" is selected (e.g., "meta-llama/llama-3.3-70b-instruct").

Generation Settings

  • Number of Generations - Generate 1-4 different responses in a single request. Default: 1
  • Stream - Enable streaming for real-time token generation. Default: false
  • JSON Mode - Force the model to output valid JSON. Default: false
  • Temperature - Sampling temperature (0.0-2.0). Higher values make output more random. Default: model default
  • Top P - Nucleus sampling (0.0-1.0). Alternative to temperature for controlling randomness. Default: model default
  • Max Tokens - Maximum number of tokens to generate. Default: model default
  • Stop Sequences - Comma-separated sequences where generation will stop (e.g., "END,STOP").

Reasoning Mode

  • Reasoning Mode - Enable reasoning/thinking mode for compatible models (Claude, o-series, Gemini, Grok):
    • Off - No reasoning mode (default)
    • Low - Minimal reasoning effort
    • Medium - Moderate reasoning effort
    • High - Maximum reasoning effort
tip

Reasoning mode is particularly effective with Claude Opus, o-series models, and Gemini Pro for complex problem-solving tasks.

Structured Output

  • Response Schema - JSON schema for structured output. Requires JSON Mode to be enabled. Example:
{
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"}
},
"required": ["name", "age"]
}

Advanced

  • Seed - Random seed for reproducible outputs. Use the same seed with identical inputs to get consistent results.
  • Timeout (seconds) - Request timeout in seconds. Default: 120
  • Include Raw Response - Include full API response in output. Default: false

Outputs

  • Text - Generated text response. Returns a string if single generation, or an array of strings if multiple generations.
  • Raw Response - Complete API response object (only when "Include Raw Response" is enabled).

How It Works

When executed, the node:

  1. Validates the connection or creates a temporary client using provided credentials
  2. Prepares the system prompt (defaults to "You are a helpful assistant" if empty)
  3. Validates that the user prompt is not empty
  4. Determines the model to use (handles custom model selection)
  5. Builds the request with all specified parameters
  6. Configures streaming, JSON mode, reasoning, and other options
  7. Makes the API request with the specified timeout
  8. Extracts text from the response (handles both single and multiple generations)
  9. Returns the text output and optional raw response

Requirements

  • Either a valid Connection Id from Connect node OR direct API Key credentials
  • Non-empty User Prompt

Error Handling

The node will return specific errors in the following cases:

  • Empty or missing User Prompt
  • Invalid Connection Id (when not using direct credentials)
  • Empty Custom Model name when Custom Model is selected
  • Invalid parameter values (temperature, top_p, etc.)
  • API authentication errors (401)
  • API rate limit errors (429)
  • Model not found errors (404)
  • API service errors (500, 502, 503, 504)
  • Request timeout errors

Usage Notes

Temperature vs Top P

  • Use Temperature for general randomness control: 0.1-0.3 for focused, 0.7-0.9 for creative
  • Use Top P as an alternative: typically 0.9-0.95 works well
  • Avoid using both together - pick one approach

JSON Mode

  • When enabled, the model will always output valid JSON
  • Combine with Response Schema for structured data extraction
  • Useful for parsing model outputs programmatically

Reasoning Mode

  • Available for: Claude Opus, Claude Sonnet, o1, o3, o4, Gemini Pro, Grok
  • Significantly improves performance on complex reasoning tasks
  • May increase latency and token usage
  • Use "Low" for simple logic, "High" for complex problem-solving

Multiple Generations

  • Generate 2-4 alternatives in a single request
  • Useful for comparing different creative outputs
  • Returns an array instead of a string
  • More efficient than making multiple separate requests

Streaming

  • Enables real-time token generation
  • Useful for responsive user interfaces
  • Currently returns the complete text after streaming finishes

Examples

Example 1: Simple Text Generation

Inputs:

  • Connection Id: msg.connection
  • System Prompt: "You are an RPA expert."
  • User Prompt: "Explain the benefits of using OpenRouter in RPA workflows"

Configuration:

  • Model: Gemini 2.5 Flash
  • Max Tokens: 500
  • Temperature: 0.3

Output: A focused, factual response about OpenRouter benefits for RPA.


Example 2: JSON Mode for Data Extraction

Inputs:

  • Connection Id: msg.connection
  • System Prompt: "Extract structured data from the text."
  • User Prompt: "John Doe, age 30, works as a Software Engineer at Acme Corp."

Configuration:

  • Model: GPT-4.1 Mini
  • JSON Mode: true
  • Response Schema:
{
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"},
"occupation": {"type": "string"},
"company": {"type": "string"}
},
"required": ["name", "age", "occupation", "company"]
}

Output:

{
"name": "John Doe",
"age": 30,
"occupation": "Software Engineer",
"company": "Acme Corp"
}

Example 3: Reasoning Mode for Complex Problems

Inputs:

  • Connection Id: msg.connection
  • System Prompt: "You are a logistics optimization expert."
  • User Prompt: "A company has 3 warehouses with capacities of 1000, 1500, and 800 units. They need to supply 5 stores requiring 400, 300, 500, 450, and 350 units. Warehouse 1 is 10km from stores, Warehouse 2 is 15km, Warehouse 3 is 8km. Minimize total distance."

Configuration:

  • Model: Claude Opus 4.5
  • Reasoning Mode: High
  • Max Tokens: 4096

Output: Detailed solution with step-by-step reasoning showing the optimal distribution strategy.


Example 4: Multiple Creative Alternatives

Inputs:

  • Connection Id: msg.connection
  • System Prompt: "You are a creative marketing writer."
  • User Prompt: "Write a tagline for an AI-powered automation platform"

Configuration:

  • Model: GPT-5
  • Number of Generations: 4
  • Temperature: 0.8

Output:

[
"Automate Everything. Intelligently.",
"AI That Works While You Think",
"Your Digital Workforce, Supercharged",
"Intelligence Meets Automation"
]

Example 5: Using Custom Model

Inputs:

  • Connection Id: msg.connection
  • User Prompt: "Explain quantum computing in simple terms"

Configuration:

  • Model: Custom Model
  • Custom Model: meta-llama/llama-3.3-70b-instruct
  • Temperature: 0.2

Output: Clear explanation using the Llama 3.3 70B model.


Example 6: Direct API Key Usage (No Connect)

Inputs:

  • User Prompt: "What is 2+2?"

Options:

  • API Key: (your credential)
  • Model: GPT-4.1 Mini
  • Max Tokens: 10

Output: "2+2 equals 4"


Example 7: Reproducible Outputs with Seed

Inputs:

  • Connection Id: msg.connection
  • User Prompt: "Generate a random product name"

Configuration:

  • Model: Gemini 2.5 Flash
  • Temperature: 0.7
  • Seed: 12345

Output: Always returns the same product name when using seed 12345 with identical settings.


Example 8: Multi-Model Comparison

Run this flow multiple times with different models:

Inputs:

  • Connection Id: msg.connection
  • System Prompt: "You are a code review expert."
  • User Prompt: "Review this code for bugs: function add(a, b) { return a + b }"

Try with:

  • Model 1: GPT-4.1 → msg.gpt_review
  • Model 2: Claude Sonnet 4.5 → msg.claude_review
  • Model 3: Gemini 2.5 Pro → msg.gemini_review

Compare outputs to get comprehensive code review feedback.

Best Practices

  1. Prompt Engineering:

    • Be specific and clear in your prompts
    • Use System Prompt to set the context and behavior
    • Include examples in prompts for better results
  2. Model Selection:

    • Use Gemini 2.5 Flash for fast, cost-effective tasks
    • Use Claude Opus 4.5 or GPT-5 for complex reasoning
    • Use o3/o4 models specifically for mathematical and logical reasoning
    • Test multiple models for your specific use case
  3. Parameter Tuning:

    • Start with default parameters and adjust based on results
    • Lower temperature (0.1-0.3) for factual, consistent outputs
    • Higher temperature (0.7-0.9) for creative, varied outputs
    • Use Max Tokens to control costs and response length
  4. JSON Mode:

    • Always test your Response Schema before production use
    • Include all required fields in the schema
    • Use JSON mode for reliable data extraction
  5. Reasoning Mode:

    • Enable for complex logic, math, and multi-step problems
    • Expect higher latency and costs with reasoning enabled
    • Review the reasoning process to improve prompts
  6. Error Handling:

    • Always handle potential errors (rate limits, timeouts)
    • Use appropriate timeout values for complex tasks
    • Consider retry logic with exponential backoff for production
  7. Cost Optimization:

    • Use the most cost-effective model that meets your needs
    • Set appropriate Max Tokens to avoid unnecessary generation
    • Use Number of Generations instead of multiple requests
    • Cache frequent queries when possible
  8. Multi-Model Workflows:

    • Route simple tasks to fast models, complex tasks to advanced models
    • Compare outputs from multiple models for critical decisions
    • Use model-specific strengths (GPT for code, Claude for long context, Gemini for multimodal)