Overview
This node integrates with Google Gemini to perform search queries using various Gemini language models. It allows users to send a search query and receive a generated response based on the selected Gemini model, optionally restricting the search context or URLs. This node is useful for scenarios where you want to leverage advanced AI-powered search capabilities within an n8n workflow, such as retrieving summarized information, generating answers from web data, or augmenting data processing pipelines with contextual search results.
Practical examples include:
- Automating research tasks by querying specific topics and extracting concise answers.
- Enhancing customer support workflows by searching knowledge bases dynamically.
- Filtering search results to specific domains or organizations for targeted insights.
Properties
| Name | Meaning |
|---|---|
| Query | The search query text to execute with Gemini. |
| Model | The Gemini model to use for the search. Options: Gemini 1.0 Pro, Gemini 1.5 Pro, Gemini 2.0 Flash, Gemini 2.5 Pro Preview, Gemini 2.5 Flash Preview. |
| Organization Context | Optional organization name to provide additional context for the search. |
| Restrict Search to URLs | Optional comma-separated list of URLs to restrict the search scope (e.g., example.com, docs.example.com). |
| Options | Collection of optional parameters: |
| - Temperature | Controls randomness in the response generation (range 0 to 1). Default is 0.6. |
| - Max Output Tokens | Maximum number of tokens to generate in the response. Default is 2048. |
| - Custom System Instruction | Override the default system instruction sent to the model. |
| - Return Full Response | Boolean flag to return the full raw API response instead of just the processed result. |
| - Extract Source URL | Boolean flag to extract the source URL from the response if available. |
Output
The node outputs JSON data with the following structure:
result: The main textual response generated by the Gemini model based on the query.query: The original search query string.organization: The optional organization context used.restrictedUrls: The optional restricted URLs used for the search.sourceUrl(optional): If enabled, the extracted source URL from the response grounding metadata.redirectedSourceUrl(optional): If enabled and applicable, the final redirected URL after following HTTP redirects.fullResponse(optional): The complete raw response object from the Gemini API when requested.
The output does not include binary data.
Dependencies
- Requires an API key credential for authenticating with the Gemini search API.
- Uses the Axios library internally to handle HTTP requests, including fetching redirected URLs.
- Requires proper configuration of the Gemini API credentials in n8n.
Troubleshooting
Common issues:
- Missing or invalid API credentials will cause authentication failures.
- Network timeouts or connectivity issues may prevent successful API calls.
- Incorrectly formatted restricted URLs could lead to unexpected search results or errors.
- Exceeding token limits or rate limits imposed by the Gemini API might cause errors.
Error messages:
- Errors returned from the Gemini API are propagated; check the error message for details.
- Timeout errors during URL redirection fetches are logged but do not block the main response.
- If "continue on fail" is enabled, errors per item are returned in the output JSON under an
errorfield.
To resolve errors:
- Verify that the API key credential is correctly set up and valid.
- Ensure network access to the Gemini API endpoints.
- Validate input parameters, especially URLs and token limits.
- Use the "Return Full Response" option to debug API responses.
Links and References
- Google Gemini AI (general info)
- Axios HTTP client
- n8n documentation on creating custom nodes