Skip to main content

Generate Image

Generates images using AI models like Gemini Nano Banana or FLUX.2 through OpenRouter with support for reference images and custom aspect ratios.

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).
  • Prompt - Detailed description of the image to generate. Be specific about style, composition, colors, and details. Required and cannot be empty.
  • Reference Images - Optional array of image URLs or file paths to use as style reference or for image editing. Can be a single string or an array.

Options

Authentication

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

Model Selection

  • Model - Select which image generation model to use:
    • Gemini 2.5 Flash Image (Nano Banana) - Fast, cost-effective image generation (default)
    • Gemini 3 Pro Image (Nano Banana Pro) - Higher quality image generation
    • FLUX.2 Pro - Professional-grade image generation
    • FLUX.2 Flex - Flexible image generation
    • Custom Model - Specify any OpenRouter image generation model
  • Custom Model - Custom model identifier when "Custom Model" is selected.

Image Settings

  • Number of Images - Generate 1-4 images in a single request. Default: 1
  • Aspect Ratio - Image dimensions:
    • Square (1:1) - Default, good for avatars, icons
    • Landscape (16:9) - Widescreen format
    • Portrait (9:16) - Tall format for mobile
    • Landscape (4:3) - Classic landscape
    • Portrait (3:4) - Classic portrait
    • Landscape (3:2) - Photo landscape
    • Portrait (2:3) - Photo portrait

Advanced

  • Timeout (seconds) - Request timeout in seconds. Default: 120. Image generation may take longer than text.
  • Include Raw Response - Include full API response in output. Default: false

Outputs

  • Image - Path to the generated image file. Returns a string if single image, or an array of paths if multiple images.
  • 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. Validates that the prompt is not empty
  3. Processes reference images (if provided):
    • If URL: Uses directly
    • If local file path: Reads file and converts to base64 data URL
    • Determines MIME type from file extension
  4. Builds multimodal content array with images and text prompt
  5. Configures the request with modalities set to ["text", "image"]
  6. Sets aspect ratio in image_config (if not 1:1)
  7. Makes the API request with specified timeout
  8. Extracts image data from response (base64 or URLs)
  9. Downloads or decodes images
  10. Saves images to temporary directory with timestamped folder
  11. Returns file path(s) to saved images

Images are saved to: /tmp/openrouter/images/YYYYMMDD-HHMMSS/image_0.png

Requirements

  • Either a valid Connection Id from Connect node OR direct API Key credentials
  • Non-empty Prompt
  • Reference images (if provided) must be:
    • Valid URLs (http/https)
    • Valid local file paths to image files
    • Supported formats: PNG, JPEG, GIF, WebP

Error Handling

The node will return specific errors in the following cases:

  • Empty or missing Prompt
  • Invalid Connection Id (when not using direct credentials)
  • Empty Custom Model name when Custom Model is selected
  • Failed to read reference image file
  • Unsupported image format in reference images
  • Failed to decode generated image
  • Failed to save generated image to disk
  • 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

Prompt Engineering for Images

  • Be very specific and detailed in your descriptions
  • Include style keywords (e.g., "photorealistic", "oil painting", "minimalist")
  • Describe composition, lighting, colors, mood, and subject details
  • Reference artistic styles or artists when appropriate
  • Specify any text that should appear in the image

Reference Images

  • Use reference images for style transfer or image editing
  • Supported as URLs or local file paths
  • Can provide multiple reference images
  • Images are automatically encoded and sent with the prompt
  • Useful for: consistent style, image variations, guided generation

Aspect Ratios

  • Choose based on your use case:
    • 1:1 for social media posts, avatars
    • 16:9 for presentations, YouTube thumbnails
    • 9:16 for Instagram stories, mobile content
    • 4:3 or 3:2 for traditional photography

Model Comparison

  • Gemini Nano Banana: Fast, cost-effective, good quality
  • Gemini Nano Banana Pro: Higher quality, more detailed
  • FLUX.2 Pro: Professional quality, photorealistic
  • FLUX.2 Flex: Versatile, good balance

Multiple Images

  • Generate variations in a single request
  • More efficient than multiple separate requests
  • Each image is saved as a separate file
  • Returns array of file paths

Examples

Example 1: Basic Image Generation

Inputs:

  • Connection Id: msg.connection
  • Prompt: "A serene Japanese zen garden with cherry blossoms, koi pond, and stone lanterns, photorealistic style, golden hour lighting"

Configuration:

  • Model: Gemini 2.5 Flash Image
  • Aspect Ratio: 16:9

Output:

  • Image: "/tmp/openrouter/images/20250123-143022/image_0.png"

Example 2: Multiple Style Variations

Inputs:

  • Connection Id: msg.connection
  • Prompt: "A futuristic city skyline at sunset"

Configuration:

  • Model: FLUX.2 Pro
  • Number of Images: 4
  • Aspect Ratio: 16:9

Output:

  • Image: [ "/tmp/openrouter/images/20250123-143100/image_0.png", "/tmp/openrouter/images/20250123-143100/image_1.png", "/tmp/openrouter/images/20250123-143100/image_2.png", "/tmp/openrouter/images/20250123-143100/image_3.png" ]

Each image will be a different interpretation of the prompt.


Example 3: Using Reference Image for Style

Inputs:

  • Connection Id: msg.connection
  • Prompt: "A mountain landscape in the same artistic style as the reference image"
  • Reference Images: ["/path/to/style_reference.jpg"]

Configuration:

  • Model: FLUX.2 Flex
  • Aspect Ratio: 3:2

Output: Generated landscape matching the artistic style of the reference image.


Example 4: Portrait Generation

Inputs:

  • Connection Id: msg.connection
  • Prompt: "Professional headshot of a business executive, confident expression, modern office background, studio lighting, sharp focus on face"

Configuration:

  • Model: FLUX.2 Pro
  • Aspect Ratio: 3:4

Output: High-quality portrait suitable for professional use.


Example 5: Social Media Content

Inputs:

  • Connection Id: msg.connection
  • Prompt: "Minimalist Instagram post design with text 'Innovation Starts Here', modern gradient background in blue and purple, clean typography"

Configuration:

  • Model: Gemini 2.5 Flash Image
  • Aspect Ratio: 1:1

Output: Square image perfect for Instagram posts.


Example 6: Product Visualization

Inputs:

  • Connection Id: msg.connection
  • Prompt: "Sleek modern smartwatch on a marble surface, dramatic side lighting, reflections, product photography style, high detail"

Configuration:

  • Model: FLUX.2 Pro
  • Aspect Ratio: 4:3

Output: Professional product photo for e-commerce or marketing.


Example 7: Batch Image Generation Workflow

// Array of prompts
msg.prompts = [
"A red sports car",
"A blue sports car",
"A black sports car"
];

// Loop through prompts
msg.generated_images = [];
for (let prompt of msg.prompts) {
// Generate Image Node
// Input: prompt
// Output: msg.image

msg.generated_images.push(msg.image);
}

Example 8: Image Editing with Reference

Inputs:

  • Connection Id: msg.connection
  • Prompt: "Change the sky to a dramatic sunset with orange and purple clouds, keep everything else the same"
  • Reference Images: ["/path/to/original_photo.jpg"]

Configuration:

  • Model: Gemini 3 Pro Image

Output: Modified version of the reference image with new sky.

Best Practices

  1. Prompt Engineering:

    • Be extremely detailed and specific
    • Include artistic style, mood, lighting, and composition
    • Use keywords that describe the desired aesthetic
    • Reference specific art movements or artists when relevant
    • Specify image quality (e.g., "high detail", "sharp focus", "4K")
  2. Model Selection:

    • Use Gemini models for fast, cost-effective generation
    • Use FLUX.2 Pro for highest quality and photorealism
    • Test different models for your specific style needs
    • Consider generation time vs quality trade-offs
  3. Aspect Ratio Selection:

    • Match aspect ratio to final use case
    • Consider platform requirements (Instagram, YouTube, etc.)
    • Square (1:1) is most versatile for general use
    • Use portrait ratios for mobile-first content
  4. Reference Images:

    • Use high-quality reference images
    • Ensure reference images clearly show desired style
    • Provide multiple references for complex styles
    • Test whether URLs or local files work better
  5. Batch Generation:

    • Generate multiple variations when exploring styles
    • Use Number of Images for variations of same prompt
    • Loop for completely different prompts
    • Save all generated images with descriptive names
  6. Error Handling:

    • Set generous timeouts for image generation (120s minimum)
    • Handle timeout errors gracefully
    • Implement retry logic for failed generations
    • Validate file paths before using reference images
  7. File Management:

    • Images are saved to temporary directories
    • Copy important images to permanent storage
    • Clean up old temporary images periodically
    • Implement organized folder structure for production
  8. Cost Optimization:

    • Use appropriate model for quality needs
    • Generate multiple images per request instead of separate requests
    • Cache generated images to avoid regeneration
    • Use lower-tier models for drafts, high-tier for finals

Common Use Cases

  1. Marketing & Advertising:

    • Product photography
    • Social media content
    • Banner ads and promotional materials
    • Brand visual assets
  2. E-commerce:

    • Product mockups
    • Lifestyle product shots
    • Category page headers
    • Feature illustrations
  3. Content Creation:

    • Blog post headers
    • Video thumbnails
    • Presentation graphics
    • Infographic elements
  4. Design & Prototyping:

    • Concept art
    • Mood boards
    • UI/UX placeholders
    • Brand exploration
  5. Automation Workflows:

    • Automated thumbnail generation
    • Batch asset creation
    • Dynamic visual content
    • Personalized imagery