Gemini Search icon

Gemini Search

Perform searches and generate content using Google Gemini API

Overview

This node integrates with the Google Gemini API to perform two main operations: web search and content generation. It allows users to send prompts to a Gemini language model, optionally guiding the model with system instructions and various generation parameters. The node is useful for automating content creation, summarizing information from web searches, or enhancing workflows that require AI-generated text based on custom prompts.

Common scenarios include:

  • Generating blog posts, articles, or marketing copy using AI.
  • Performing web searches enhanced by AI to extract relevant information.
  • Combining search results with AI-generated summaries or answers.
  • Customizing AI responses with system instructions and sampling options.

Practical example:
A user wants to generate a product description by providing a prompt describing the product features. They select a Gemini model, set temperature and max tokens, and optionally add system instructions to control style or tone. The node returns generated text ready for use in their CMS.

Properties

Name Meaning
Model The Gemini model to use for generating content. Options are dynamically loaded (e.g., "gemini-2.0-flash").
Prompt The input text prompt sent to the Gemini model to guide content generation. Required.
System Instruction Optional instructions to guide the model's behavior, such as tone, style, or specific constraints.
Options A collection of optional parameters controlling generation behavior:
- Temperature: Controls randomness in the response (0 to 1).
- Max Output Tokens: Maximum number of tokens to generate.
- Top P: Nucleus sampling parameter (0 to 1).
- Top K: Top K sampling parameter (integer 1 to 40).
- Extract Source URL: Whether to extract the source URL from the response.

Output

The node outputs an array of JSON objects, each corresponding to an input item processed. Each output object contains:

  • response: The generated text content from the Gemini model.
  • fullResponse: The complete raw response object returned by the Gemini API, including metadata.
  • urlContextMetadata (optional): Metadata about URL context if applicable.
  • restrictedUrls (only for web search): The URLs used to restrict the search if specified.
  • sourceUrl (optional): Extracted source URL from the response if enabled.
  • redirectedSourceUrl (optional): The final redirected URL after following HTTP redirects, if extraction was enabled and successful.
  • redirectError (optional): Error message if there was a problem fetching the redirected URL.

If the node encounters an error and is configured to continue on failure, it outputs an object with an error field containing the error message.

Binary data: This node does not output binary data.

Dependencies

  • Requires an API key credential for authenticating with the Google Gemini API.
  • Uses the axios library internally to make HTTP requests, including HEAD requests to resolve redirected URLs.
  • No additional environment variables are explicitly required beyond the API credential configuration.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Network timeouts or connectivity issues when calling the Gemini API or resolving URLs.
    • Providing invalid parameter values (e.g., out-of-range temperature or token limits) may cause errors.
    • If "Extract Source URL" is enabled but the response lacks grounding metadata, the source URL will be empty.
  • Error messages:

    • Errors thrown by the Gemini API are propagated; check the error message for details.
    • Redirect URL fetch errors are logged and included in the output under redirectError.
    • To handle errors gracefully, enable "Continue On Fail" in the node settings.

Links and References

Discussion