Gemini Search icon

Gemini Search

Perform searches and generate content using Google Gemini API

Overview

The "Gemini Search" node allows you to interact with the Google Gemini API to perform web searches or generate content using various Gemini models. It is suitable for scenarios where you need AI-powered search results, content generation, or want to leverage advanced language models within your n8n workflows.

Practical examples:

  • Automate research by querying the web and extracting summarized information.
  • Generate creative or technical content based on prompts.
  • Integrate AI-generated responses into chatbots, emails, or reports.

Properties

Display Name Type Description
Model options The Gemini model to use (e.g., Gemini 1.0 Pro, Gemini 2.5 Pro).
Options collection Additional configuration for the model's response. Includes:
- Temperature number Controls randomness in the response (0-1).
- Max Output Tokens number Maximum number of tokens to generate.
- Top P number Nucleus sampling parameter.
- Top K number Top K sampling parameter.
- Extract Source URL boolean Whether to extract the source URL from the response.

Note: Other properties such as "Prompt", "Operation", etc., are present but not listed here as per your request for Resource: Default, Operation: Default.

Output

The node outputs a JSON object with the following structure:

{
  "response": "<AI-generated text response>",
  "fullResponse": { /* Full Gemini API response object */ },
  "restrictedUrls": "<comma-separated URLs>" // Only if 'Restrict Search to URLs' was set,
  "sourceUrl": "<URL>",                     // Only if 'Extract Source URL' is enabled and available,
  "redirectedSourceUrl": "<final URL after redirects>", // If applicable,
  "redirectError": "<error message>"        // If redirect resolution fails,
  "error": "<error message>"                // Only if an error occurred and 'Continue On Fail' is enabled
}
  • response: The main text output from Gemini.
  • fullResponse: The complete raw response from the Gemini API.
  • restrictedUrls: Included if you restricted the search to specific URLs.
  • sourceUrl: The extracted source URL from the response (if requested).
  • redirectedSourceUrl: The final URL after following HTTP redirects (if applicable).
  • redirectError: Error message if there was an issue resolving redirects.
  • error: Present only if an error occurred and "Continue On Fail" is enabled.

Dependencies

  • External Service: Requires access to the Google Gemini API.
  • API Key: You must configure Gemini API credentials in n8n (geminiSearchApi).
  • HTTP Requests: Uses Axios for making HTTP requests.

Troubleshooting

Common issues:

  • Missing or invalid API key: Ensure your Gemini API credentials are correctly configured in n8n.
  • Model selection errors: Using an unavailable or deprecated model may result in errors.
  • Timeouts or network errors: If the node cannot reach the Gemini API or resolve URLs, check your network/firewall settings.
  • Invalid input parameters: Supplying out-of-range values (e.g., temperature > 1) can cause validation errors.

Common error messages:

  • "Error fetching redirected URL: ...": Indicates a problem when trying to resolve the final destination of a source URL. Check the URL validity or network connectivity.
  • "error": "<error message>": General error field populated if "Continue On Fail" is enabled; review the message for details.

Links and References

Discussion