Overview
The Gemini Search Tool node enables n8n workflows to perform advanced search queries using Google Gemini's AI models. It allows users to submit a query, select a specific Gemini model, and optionally provide organizational context or restrict the search to certain URLs. The node is ideal for scenarios where you want to leverage Gemini's AI-powered search capabilities within automated processes, such as:
- Enriching data with AI-generated answers.
- Research automation (e.g., summarizing web content).
- Contextual search restricted to specific domains.
- Integrating Gemini search results into business workflows.
Example use cases:
- Automatically answering customer support questions by searching documentation.
- Generating summaries of recent news articles from specified sources.
- Extracting relevant information from internal knowledge bases.
Properties
| Display Name | Type | Description |
|---|---|---|
| Query | String | The search query to execute with Gemini. (Required) |
| Model | Options | The Gemini model to use. Choices include: Gemini 1.0 Pro, 1.5 Pro, 2.0 Flash, 2.0 Pro, 2.5 Pro. Default: Gemini 2.0 Flash. |
| 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). |
| Options | Collection | Additional options: - Temperature (Number, 0–1): Controls randomness in the response. - Max Output Tokens (Number): Maximum number of tokens to generate. - Custom System Instruction (String): Override the default system instruction. - Return Full Response (Boolean): Whether to return the full API response. - Extract Source URL (Boolean): Whether to extract the source URL from the response. |
Output
The node outputs an array of objects, each containing the following fields in the json property:
| Field | Type | Description |
|---|---|---|
| result | String | The main text result generated by Gemini for the given query. |
| query | String | The original query submitted. |
| organization | String | The organization context used (if provided). |
| restrictedUrls | String | The URLs the search was restricted to (if provided). |
| sourceUrl | String | (If "Extract Source URL" is enabled and available) The source URL extracted from the response. |
| redirectedSourceUrl | String | (If "Extract Source URL" is enabled and available) The final URL after following redirects. |
| fullResponse | Object | (If "Return Full Response" is enabled) The complete raw response from the Gemini API. |
| error | String | (Only if an error occurred and "Continue On Fail" is enabled) The error message. |
Note:
- If "Extract Source URL" is not enabled or no source URL is found,
sourceUrlandredirectedSourceUrlwill be omitted. - If "Return Full Response" is not enabled,
fullResponsewill be omitted. - Binary data is not produced by this node.
Dependencies
- External Service: Requires access to the Google Gemini API.
- API Key: You must configure Gemini API credentials in n8n under the credential type
geminiSearchApi. - Network Access: The node makes HTTP requests to the Gemini API and may follow redirects when extracting source URLs.
Troubleshooting
Common Issues:
Missing or Invalid API Key:
Error messages related to authentication failures indicate that the Gemini API credentials are missing or incorrect. Ensure yourgeminiSearchApicredentials are set up properly in n8n.Model Not Supported:
If you select a model that is not available to your account or region, the API may return an error. Try switching to another supported model.Timeouts or Network Errors:
If the node cannot reach the Gemini API or a source URL (when extracting), you may see timeout errors. Check your network connection and firewall settings.No Results Returned:
If the query is too vague or restricted URLs do not contain relevant information, theresultfield may be empty.Error in Source URL Extraction:
If "Extract Source URL" is enabled but the response does not contain a valid source,sourceUrlwill be empty. Redirect resolution errors will log to the console and fall back to the original URL.
Error Handling:
- If "Continue On Fail" is enabled, errors for individual items will be output in the
errorfield of the corresponding result object.