Gemini Search icon

Gemini Search

Use Google Gemini as a search tool

Overview

This node integrates with Google Gemini to perform advanced search queries using a specified Gemini model. It allows users to execute natural language search queries and retrieve AI-generated responses based on those queries. The node supports enhanced context features such as restricting searches to specific URLs or organizational domains, which can improve the relevance of results in specialized scenarios.

Common use cases include:

  • Performing AI-powered web searches within a workflow.
  • Restricting search scope to certain websites or an organization’s domain for targeted information retrieval.
  • Customizing the behavior of the Gemini model via parameters like temperature and token limits.
  • Extracting source URLs from the search results for further processing or validation.

Practical example:

  • A user wants to query "latest trends in renewable energy" but only from their company’s internal documentation site. They enable URL context and restrict URLs to their intranet domain, ensuring the response is tailored to their organization's knowledge base.

Properties

Name Meaning
Query The search query string to send to the Gemini model.
Model The Gemini model to use for generating the search response. Options are dynamically loaded (e.g., "gemini-2.0-flash").
Enable URL Context Tool When enabled, the model uses specific URLs as context for the search instead of general web search.
Restrict Search to URLs Comma-separated list of URLs to limit the search scope to. Only applicable if URL Context Tool is enabled.
Enable Organization Context When enabled, restricts the search to a specific organization domain.
Organization Context The name of the organization domain to use as context for the search. Only used if Organization Context is enabled.
Options Collection of additional parameters to customize the search request:
- Temperature Controls randomness in the generated response; value between 0 (deterministic) and 1 (more random).
- Max Output Tokens Maximum number of tokens to generate in the response. Default is 2048.
- Top P Nucleus sampling parameter (between 0 and 1) controlling diversity. Included only if set.
- Top K Top K sampling parameter controlling diversity; integer between 1 and 40.
- Custom System Instruction Overrides the default system instruction sent to the Gemini model, allowing customization of the model's behavior.
- Return Full Response If true, returns the entire raw API response from Gemini instead of just the processed result.
- Extract Source URL If true, attempts to extract the source URL from the response and also fetches any redirected URL for that source.

Output

The node outputs JSON data with the following structure:

  • result: The main text response generated by the Gemini model based on the query.
  • query: The original search query string.
  • organization: The organization context used, if any.
  • restrictedUrls: The URLs the search was restricted to, if any.
  • urlContextMetadata: Metadata about the URL context when URL context tool is enabled.
  • sourceUrl: The extracted source URL from the response, if extraction is enabled.
  • redirectedSourceUrl: The final redirected URL after following HTTP redirects, if source URL extraction is enabled.
  • fullResponse: The complete raw response from the Gemini API, included only if requested.

If the node is configured to extract source URLs, it performs an HTTP HEAD request to resolve any redirects and provide the final URL.

Dependencies

  • Requires an API key credential for authenticating requests to the Gemini API.
  • Uses Axios library internally to perform HTTP requests for URL redirection resolution.
  • The node depends on helper functions (geminiRequest, getModels, and instruction builders) bundled with the node implementation.
  • No additional environment variables are explicitly required beyond the API authentication credential.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Enabling URL context without specifying valid URLs may lead to empty or irrelevant results.
    • Network errors during URL redirection checks can cause fallback to the original URL.
    • Setting incompatible or out-of-range values for options like temperature, topP, or topK may cause API errors.
  • Error messages:

    • Errors returned from the Gemini API will be surfaced in the node output if "Continue On Fail" is enabled.
    • Timeout or network errors during redirect URL fetching will log errors but do not fail the node execution.
  • Resolutions:

    • Ensure the API key credential is correctly configured and has necessary permissions.
    • Validate URL lists and organization names before enabling context restrictions.
    • Adjust sampling parameters within allowed ranges.
    • Check network connectivity if redirect URL resolution fails.

Links and References

Discussion