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 model, optionally guiding the model with system instructions and controlling output randomness and length.

  • Web Search: Enables searching the web using Gemini's capabilities, with options to restrict searches by URLs or organization domains, and to provide URL context for more focused results.
  • Generate Content: Allows generating text content based on a prompt, useful for creative writing, summarization, or other text generation tasks.

Practical examples:

  • Use the Web Search operation to gather up-to-date information from specific websites or within an organization's domain.
  • Use Generate Content to create blog posts, marketing copy, or answer questions based on a given prompt.
  • Combine URL context and organization context to tailor search results to trusted sources or internal documentation.

Properties

Name Meaning
Operation Choose between "Web Search" (perform a web search using Gemini) and "Generate Content" (generate text content).
Model Select the Gemini model to use for the request. Models are loaded dynamically and can vary in capability.
Prompt The input text prompt sent to the Gemini model. Required for both operations.
Enable URL Context Tool (Web Search only) When enabled, allows the model to use specific URLs as context for the search instead of general web search.
Restrict Search to URLs (Web Search + URL Context enabled) Comma-separated list of URLs to restrict the search to. Only these URLs will be considered as context.
Enable Organization Context (Web Search only) When enabled, restricts the search to a specific organization domain.
Organization Context (Web Search + Organization Context enabled) The organization domain name to restrict the search to.
System Instruction Optional instruction to guide the model’s behavior, applicable to both operations. Can be used to set tone, style, or other preferences.
Options Collection of advanced parameters controlling the generation:
- Temperature: Controls randomness (0-1).
- Max Output Tokens: Maximum tokens to generate.
- Top P: Nucleus sampling parameter (0-1).
- Top K: Top K sampling parameter (1-40).
- Extract Source URL: Whether to extract the source URL from the response.

Output

The node outputs JSON data with the following structure:

  • response: The generated text result from the Gemini model.
  • fullResponse: The complete raw response object returned by the Gemini API.
  • urlContextMetadata (optional): Metadata about URL context if URL context was used.
  • restrictedUrls (optional): The list of restricted URLs used in the search (if any).
  • sourceUrl (optional): The extracted source URL from the response if extraction is enabled.
  • redirectedSourceUrl (optional): The final redirected URL after following HTTP redirects, if available.
  • redirectError (optional): Error message if there was an issue fetching the redirected URL.

If the node encounters an error and "Continue On Fail" is enabled, it outputs an error object with 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 required beyond the API credential configuration.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Network timeouts or connectivity issues may prevent successful API calls.
    • Incorrectly formatted URL restrictions or organization names may lead to unexpected search results.
    • Enabling URL context without specifying valid URLs may reduce search effectiveness.
  • Error messages:

    • Errors from the Gemini API will be propagated with their message.
    • Redirect URL fetch errors are logged but do not fail the node; the original URL is returned instead.
    • If "Continue On Fail" is disabled, any error will stop execution; enabling it allows processing subsequent items.
  • Resolution tips:

    • Verify API credentials and permissions.
    • Ensure URLs and organization names are correctly specified.
    • Adjust timeout settings or retry logic externally if network issues persist.
    • Use system instructions to better guide the model if responses are off-target.

Links and References

Discussion