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. For the "Generate Content" operation, it sends a user-provided prompt along with optional system instructions and generation parameters to a selected Gemini language model. The node then returns the generated text content, optionally including source URLs if requested.

Typical use cases include:

  • Automatically generating articles, summaries, or creative text based on prompts.
  • Producing tailored content for marketing, documentation, or chatbots.
  • Enhancing workflows that require AI-generated textual data without manual intervention.

For example, you could input a prompt like "Write a summary of the latest trends in AI" and receive a coherent, model-generated summary as output.

Properties

Name Meaning
Model The Gemini model to use. Options: Gemini 1.0 Pro, Gemini 1.5 Pro, Gemini 2.0 Flash, Gemini 2.5 Pro Preview, Gemini 2.5 Flash Preview.
Prompt The text prompt sent to the Gemini model to generate content.
System Instruction Optional instructions to guide the model's behavior during content generation.
Options Collection of generation parameters:
- Temperature Controls randomness in the response (range 0 to 1).
- Max Output Tokens Maximum number of tokens to generate in the output.
- Top P Nucleus sampling parameter controlling diversity.
- Top K Top K sampling parameter controlling diversity.
- Extract Source URL Boolean flag to extract and return the source URL from the model's response if available.

Output

The node outputs JSON objects containing:

  • response: The generated text content from the Gemini model.
  • fullResponse: The complete raw response object returned by the Gemini API, which includes detailed metadata.
  • sourceUrl (optional): If enabled, the URL source extracted from the response grounding metadata.
  • redirectedSourceUrl (optional): The final resolved URL after following HTTP redirects, if applicable.
  • restrictedUrls (only for web search operation): The list of URLs used to restrict the search scope.
  • error (if any): Error message if the execution failed and "continue on fail" is enabled.

The node does not output binary data.

Dependencies

  • Requires an active connection to the Google Gemini API via an API key credential configured in n8n.
  • Uses Axios library internally to handle HTTP requests and follow redirects when extracting source URLs.
  • No additional environment variables are explicitly required beyond the API authentication setup.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Network timeouts or connectivity issues may prevent successful API calls.
    • Providing an empty prompt will likely result in errors or empty responses.
    • Enabling source URL extraction may fail if the response lacks grounding metadata or if the URL is unreachable.
  • Error messages:

    • Errors from the Gemini API are propagated; typical messages relate to invalid parameters or quota limits.
    • HTTP request errors during URL resolution are logged but do not stop execution; the original URL is returned instead.
  • Resolutions:

    • Verify API key validity and permissions.
    • Ensure network access to Gemini API endpoints.
    • Provide meaningful prompts and valid options.
    • Disable source URL extraction if not needed or if causing issues.

Links and References

Discussion