Ask Gemini

Action ID: google_gen_ai_ask_gemini

Description

Ask a Gemini anything you want! This node supports multiple Google Gemini models for generating AI-powered responses with text and image analysis capabilities.

Provider

Google Generative AI

Connection

Name
Description
Required
Category

Google Gen AI Connection

The Google Gen AI connection to use for the Gemini.

google_gen_ai

Input Parameters

Name
Type
Required
Default
Description

model

dropdown

-

gemini-2.0-flash

The model to use for the chat. Available options: gemini-2.0-flash, gemini-2.0-pro-exp-02-05, gemini-2.0-flash-exp, gemini-2.0-flash-lite, gemini-2.0-flash-thinking-exp-01-21, gemini-1.5-flash, gemini-1.5-pro, gemini-2.0-flash-exp-image-generation, gemini-2.5-flash-preview-05-20, gemini-2.5-pro-preview-05-06

model_response_modalities

dropdown

-

[]

Model response modalities for multi-modal outputs. Available options depend on the selected model.

prompt

string

-

The question to ask the model

images

array

-

-

The images to use for the chat. Supported formats: JPG, PNG

temperature

number

-

0.9

Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive. Range: 0.0 to 1.0

max_tokens

integer

-

2048

The maximum number of tokens to generate. Requests can use up to 2,048 or 4,096 tokens shared between prompt and completion depending on the model

top_p

number

-

1.0

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.

system_message

string

-

-

Instructions for the AI assistant on how to behave and respond.

response_schema

object

-

-

Controls the format of the response to be returned by the node. Visit https://ai.google.dev/gemini-api/docs/structured-output?lang=python#json-schemas for more information.

View JSON Schema
{
  "description": "Ask Gemini node input.",
  "properties": {
    "model": {
      "default": "gemini-2.0-flash",
      "description": "The model to use for the chat.",
      "enum": [
        "gemini-2.0-flash",
        "gemini-2.0-pro-exp-02-05",
        "gemini-2.0-flash-exp",
        "gemini-2.0-flash-lite",
        "gemini-2.0-flash-thinking-exp-01-21",
        "gemini-1.5-flash",
        "gemini-1.5-pro",
        "gemini-2.0-flash-exp-image-generation",
        "models/gemini-2.5-flash-preview-05-20",
        "gemini-2.5-pro-preview-05-06"
      ],
      "title": "Model",
      "type": "string"
    },
    "model_response_modalities": {
      "default": [],
      "title": "Model Response Modalities",
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Model response modalities for multi-modal outputs."
    },
    "prompt": {
      "description": "The question to ask the model.",
      "title": "Question",
      "type": "string"
    },
    "images": {
      "default": null,
      "description": "The images to use for the chat.",
      "items": {
        "type": "string"
      },
      "title": "Images",
      "type": "array"
    },
    "temperature": {
      "default": 0.9,
      "description": "Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.",
      "maximum": 1.0,
      "minimum": 0.0,
      "title": "Temperature",
      "type": "number"
    },
    "max_tokens": {
      "default": 2048,
      "description": "The maximum number of tokens to generate. Requests can use up to 2,048 or 4,096 tokens shared between prompt and completion depending on the model.",
      "title": "Maximum Tokens",
      "type": "integer"
    },
    "top_p": {
      "default": 1.0,
      "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.",
      "title": "Top P",
      "type": "number"
    },
    "system_message": {
      "default": null,
      "description": "Instructions for the AI assistant on how to behave and respond.",
      "title": "System Message",
      "type": "string"
    },
    "response_schema": {
      "default": null,
      "description": "Controls the format of the response to be returned by the node. Visit https://ai.google.dev/gemini-api/docs/structured-output?lang=python#json-schemas for more information.",
      "title": "Response Schema",
      "type": "object"
    }
  },
  "required": [
    "prompt"
  ],
  "title": "AskGeminiInput",
  "type": "object"
}

Output Parameters

Name
Type
Description

content

any

The response from Gemini

View JSON Schema
{
  "description": "Ask Gemini node output.",
  "properties": {
    "content": {
      "title": "Content",
      "description": "The response from Gemini."
    }
  },
  "required": [
    "content"
  ],
  "title": "AskGeminiOutput",
  "type": "object"
}

How It Works

This node sends your prompt to Google's Gemini API along with your configuration parameters. Gemini processes your question using the specified system message as context, then generates a response based on the temperature and other settings you've configured. If you provide images, they are analyzed alongside the text prompt. The response is returned as text or structured data that can be used by subsequent nodes in your workflow.

Usage Examples

Example 1: Simple Question

Input:

prompt: "What are the main benefits of renewable energy?"
model: "gemini-2.0-flash"
temperature: 0.3

Output:

content: "Renewable energy offers several key benefits: 1) Reduced greenhouse gas emissions, 2) Sustainable long-term energy supply, 3) Lower operating costs after initial setup, 4) Job creation in clean energy sectors..."

Example 2: Image Analysis

Input:

prompt: "Analyze this chart and provide insights"
model: "gemini-1.5-pro"
temperature: 0.5
images: ["https://example.com/chart.png"]

Output:

content: "This bar chart shows quarterly revenue trends. Key observations: Q2 saw a 25% increase compared to Q1, Q3 peaked at $2.5M, and Q4 declined by 15%..."

Example 3: Structured Output with Schema

Input:

prompt: "Extract person details from: John Smith, age 30, email: [email protected]"
model: "gemini-2.0-flash"
response_schema: {
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "age": {"type": "integer"},
    "email": {"type": "string"}
  }
}

Output:

content: {
  "name": "John Smith",
  "age": 30,
  "email": "[email protected]"
}

Common Use Cases

  • Content Generation: Create blog posts, marketing content, and product descriptions

  • Information Analysis: Analyze images, documents, and data to extract insights

  • Customer Support: Generate helpful responses to customer inquiries

  • Research Assistance: Summarize information and explain complex topics

  • Data Extraction: Extract structured information from unstructured text or images

  • Code Generation: Generate or explain code snippets across multiple languages

  • Translation: Translate content between languages with context awareness

Error Handling

Error Type
Cause
Solution

Authentication Error

Invalid or missing Google API key

Verify your Google Gen AI connection is properly configured with a valid API key

Rate Limit Error

Too many requests in a short period

Implement delays between requests or check API quota limits

Invalid Model

Model name doesn't exist or access not granted

Verify the model name and ensure your API key has access to it

Token Limit Exceeded

Prompt + response exceeds model's context window

Reduce prompt length or decrease max_tokens parameter

Invalid Image Format

Unsupported image format provided

Ensure images are in JPG or PNG format only

Schema Validation Error

Response doesn't match the specified schema

Review and adjust your response_schema definition

Notes

  • Model Selection: Choose a model based on your needs. Gemini 2.0 Flash is fast and cost-effective for most tasks. Gemini 1.5 Pro and Gemini 2.0 Pro offer superior reasoning for complex queries.

  • Multi-Modal Support: Some models like Gemini 2.0 Flash Exp support image generation and other modalities. Use model_response_modalities to specify the desired output type.

  • Temperature Control: Lower temperature (0.0-0.3) for factual, deterministic responses. Higher temperature (0.7-1.0) for creative content.

  • Image Analysis: You can provide images (JPG or PNG) alongside your prompt for analysis and discussion.

  • Structured Output: Use the response_schema parameter to enforce a specific JSON structure in the response. See Google's documentation for schema syntax.

  • System Messages: Craft clear system messages to guide Gemini's behavior, tone, and response format.

  • Cost Optimization: Gemini 2.0 Flash is the most cost-effective option for most use cases.

Last updated

Was this helpful?