Actions2
Overview
The Gemini Search node enables you to perform web searches using the Google Gemini API. Specifically, with the Web Search operation, it allows you to send a prompt to Gemini, optionally restrict the search to specific URLs, and receive AI-generated responses based on real-time web data. This is useful for scenarios where you need up-to-date information, summaries, or insights from the web within your n8n workflows.
Practical examples:
- Summarizing recent news articles about a topic.
- Extracting product information from specific websites.
- Researching competitors by restricting search to their domains.
Properties
Display Name | Type | Description |
---|---|---|
Model | options | The Gemini model to use (e.g., Gemini 1.0 Pro, Gemini 2.0 Flash, etc.). |
Prompt | string | The prompt to send to Gemini. Required. |
Organization Context | string | Optional organization name to use as context for search. |
Restrict Search to URLs | string | Optional comma-separated list of URLs to restrict search to (e.g., example.com,docs.example.com). |
System Instruction | string | Optional system instruction to guide the model behavior. |
Options | collection | Additional settings: |
- Temperature | number | Controls randomness in the response (0-1). Default: 0.6 |
- Max Output Tokens | number | Maximum number of tokens to generate. Default: 2048 |
- Top P | number | Nucleus sampling parameter. Default: 1 |
- Top K | number | Top K sampling parameter. Default: 1 |
- Extract Source URL | boolean | Whether to extract the source URL from the response. Default: false |
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 present if 'Restrict Search to URLs' was set
"sourceUrl": "<URL>", // Only present if 'Extract Source URL' is enabled and a source is found
"redirectedSourceUrl": "<final URL after redirects>", // Only present if 'Extract Source URL' is enabled and redirection occurs
"redirectError": "<error message>" // Only present if there was an error resolving the redirected URL
}
response
: The main text answer generated by Gemini.fullResponse
: The complete raw response from the Gemini API.restrictedUrls
: Echoes the restriction if provided.sourceUrl
: The original source URL extracted from the Gemini response (if enabled).redirectedSourceUrl
: The final destination URL after following HTTP redirects (if enabled).redirectError
: Error message if there was a problem resolving the redirected URL.
If an error occurs and "Continue On Fail" is enabled, the output will be:
{
"error": "<error message>"
}
Dependencies
- External Service: Requires access to the Google Gemini API.
- Credentials: You must configure the
geminiSearchApi
credential in n8n. - Network Access: Outbound HTTPS requests to the Gemini API and any referenced URLs (for source extraction).
Troubleshooting
Common Issues:
- Missing Credentials: If the
geminiSearchApi
credential is not configured, the node will fail. - Invalid Model Selection: Using an unsupported model value may result in errors from the Gemini API.
- Prompt Required: The "Prompt" field is mandatory; leaving it empty will cause an error.
- API Quotas/Rate Limits: Exceeding Gemini API quotas can lead to request failures.
- Source URL Extraction Fails: If "Extract Source URL" is enabled but no source is found,
sourceUrl
will be empty. Redirect resolution may also fail due to network issues or timeouts, resulting in aredirectError
.
Error Messages:
"Error fetching redirected URL: ..."
: Indicates a problem when trying to resolve the final URL after redirects. Usually caused by network issues or invalid URLs."Request failed with status code ..."
: Indicates an issue with the Gemini API request, possibly due to authentication, quota, or input errors.
How to resolve:
- Double-check credentials and permissions.
- Ensure required fields are filled.
- Review API usage limits.
- For source extraction issues, verify that the Gemini response includes grounding metadata.