Implementation:CrewAIInc CrewAI SerpApi Google Search Tool
| Knowledge Sources | |
|---|---|
| Domains | Tools, Web_Search |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
SerpApiGoogleSearchTool performs Google web searches using the SerpApi service and returns cleaned search results.
Description
SerpApiGoogleSearchTool extends SerpApiBaseTool and configures itself with arbitrary_types_allowed and validate_assignment via ConfigDict. SerpApiGoogleSearchToolSchema defines the input with a mandatory search_query string and an optional location string for geo-targeted searches. The _run() method calls self.client.search() with a dictionary containing the query (q) and location parameters, converts the response to a dict via .as_dict(), then uses the inherited _omit_fields() method to strip out search_metadata, search_parameters, fields matching serpapi_.+, fields matching .+_token, displayed_link, and pagination keys. HTTPError exceptions from the SerpApi client are caught and returned as descriptive error strings.
Usage
Use this tool when agents need to perform Google web searches to find real-time information, verify facts, or gather current data during task execution. Requires a SERPAPI_API_KEY environment variable.
Code Reference
Source Location
- Repository: CrewAI
- File: lib/crewai-tools/src/crewai_tools/tools/serpapi_tool/serpapi_google_search_tool.py
- Lines: 1-61
Signature
class SerpApiGoogleSearchToolSchema(BaseModel):
search_query: str = Field(..., description="Mandatory search query you want to use to Google search.")
location: str | None = Field(None, description="Location you want the search to be performed in.")
class SerpApiGoogleSearchTool(SerpApiBaseTool):
name: str = "Google Search"
description: str = "A tool to perform to perform a Google search with a search_query."
args_schema: type[BaseModel] = SerpApiGoogleSearchToolSchema
def _run(self, **kwargs) -> Any
Import
from crewai_tools import SerpApiGoogleSearchTool
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| search_query | str | Yes | The search query to send to Google |
| location | str or None | No | Geographic location for the search |
Outputs
| Name | Type | Description |
|---|---|---|
| _run() returns | dict or str | Cleaned Google search results as a dictionary, or error message string on failure |
Usage Examples
Basic Usage
from crewai_tools import SerpApiGoogleSearchTool
tool = SerpApiGoogleSearchTool()
result = tool._run(search_query="latest AI research papers 2025")
# With location targeting
result = tool._run(search_query="best restaurants", location="New York, NY")