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 searches and content generation. It allows users to send prompts to Gemini models, retrieve search results or generated text, and optionally extract source URLs from responses.

Common scenarios include:

  • Performing enhanced web searches that can be restricted by URL or organization context.
  • Generating creative or informative content based on user prompts.
  • Using advanced Gemini models with configurable parameters for tailored output.

Practical examples:

  • A marketing team could generate blog post drafts using the "Generate Content" operation.
  • A researcher might perform a focused web search limited to specific domains or organizations to gather relevant information.
  • Developers can automate content creation workflows or enrich data pipelines with AI-generated insights.

Properties

Name Meaning
Model The Gemini model to use. Options are dynamically loaded via the getModels method.
Options Collection of optional parameters controlling response generation:
- Temperature Controls randomness in the response (0-1).
- Max Output Tokens Maximum number of tokens to generate.
- Top P Nucleus sampling parameter (0-1).
- Top K Top K sampling parameter (integer 1-40). Only included if set.
- Extract Source URL Whether to extract the source URL from the response.

Note: The above options allow fine-tuning of the AI model's output behavior.

Output

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

  • response: The main textual response generated by the Gemini model.
  • fullResponse: The complete raw response object returned by the Gemini API.
  • urlContextMetadata (optional): Metadata about URL context if available and applicable.
  • restrictedUrls (only for web search): The list of URLs used to restrict the search, if any.
  • sourceUrl (optional): The extracted source URL from the response, if enabled.
  • redirectedSourceUrl (optional): The final redirected URL after following HTTP redirects, if extraction is enabled and successful.
  • redirectError (optional): Error message if redirect URL fetching failed.

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.

The 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.
  • Relies on internal helper functions for building system instructions and user queries.
  • The node expects network access to the Gemini API endpoints and any URLs involved in URL context or source URL extraction.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Network connectivity problems may prevent reaching the Gemini API or resolving URLs.
    • Incorrect model names or unsupported options may result in API errors.
    • Enabling URL context without specifying valid URLs may lead to unexpected results.
  • Error messages:

    • Errors from the Gemini API are propagated as error messages in the output or thrown exceptions.
    • Redirect URL fetching errors are logged and included in the output under redirectError.
    • If the node is set to continue on fail, errors appear in the output JSON; otherwise, execution stops.
  • Resolutions:

    • Verify API credentials and permissions.
    • Check network connectivity and firewall settings.
    • Ensure model names and options conform to supported values.
    • Provide valid URLs when enabling URL context features.

Links and References

Discussion