DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Classes / SerperDevTool
Class tools

SerperDevTool: Reference Guide

By DevShelfHub

Google search results via Serper.dev API — fast, low-cost web search for agents.

See the CrewAI API reference index, CrewAI introduction, and core concepts for surrounding context.

What is SerperDevTool?

SerperDevTool wraps Serper.dev's Google search JSON API so agents can discover fresh URLs, headlines, and snippets without operating your own scraping stack. Results arrive structured — titles, links, snippets — which is ideal for prompting the next reasoning step or feeding a downstream ScrapeWebsiteTool. Latency is typically dominated by Serper's upstream Google fetch, not CrewAI orchestration.

Cost is per-query and predictable enough to budget in token dashboards: every unnecessary search burns both Serper credits and downstream LLM context when you paste entire SERPs into prompts. Trim to the top-k hits in code or prompt instructions, and cache repeated queries when agents loop.

Serper answers what exists on the public web — not your VPC Drive, Notion, or database. Pair it with internal knowledge sources when answers must cite private documents, and remember snippets can be stale or wrong; always corroborate high-stakes facts with a second tool call or human review.

When to Use

Open-web research, competitor scanning, breaking-news checks, and URL discovery before deeper scraping.

Use Cases

  • Research
  • Fact-checking
  • URL discovery
  • Lead enrichment with public footprint

Key Features

  • Structured results
  • Fast
  • Cheap
  • Uses SERPER_API_KEY env by default

When NOT to Use

Proprietary corpora, paywalled journals, or compliance-sensitive queries where Google results are insufficient or prohibited.

Notes

Quota and retries

Serper enforces per-key quotas. Bubble HTTP 429s up to your orchestrator so crews can back off instead of tight-looping searches that amplify spend and get keys suspended.

Snippet != ground truth

Models sometimes treat SERP snippets as facts. In prompts, instruct agents to open the destination page or cross-check multiple sources when stakes are high.

Prompt injection via titles

Adversarial SEO can surface malicious titles. When feeding raw SERP JSON into the LLM, strip HTML and consider domain allow lists for sensitive workflows.

Regional bias

Google results vary by region and personalization on Serper's side. Log which market you target and document the assumption for reproducible research runs.

Import

python
from crewai_tools import SerperDevTool

Key Parameters

Parameter Type Default Purpose
api_key str (env) $SERPER_API_KEY Serper.dev API key.

Code Examples

Minimal agent wiring

python
import os
from crewai import Agent
from crewai_tools import SerperDevTool

os.environ.setdefault('SERPER_API_KEY', 'replace-me')

researcher = Agent(
    role='Web researcher',
    goal='Find authoritative sources',
    backstory='You prefer primary sources.',
    tools=[SerperDevTool()],
    verbose=True,
)

Pair with scraping for full article text

python
from crewai import Agent, Task, Crew
from crewai_tools import SerperDevTool, ScrapeWebsiteTool

search = SerperDevTool()
scrape = ScrapeWebsiteTool()

researcher = Agent(role='Researcher', goal='Gather facts', backstory='...', tools=[search, scrape])
select = Task(description='Pick top 3 URLs about {topic}', expected_output='Bullet URLs', agent=researcher)
detail = Task(description='Scrape each URL for quotes', expected_output='Markdown with citations', agent=researcher, context=[select])
Crew(agents=[researcher], tasks=[select, detail]).kickoff(inputs={'topic': 'CrewAI observability'})

Load API key from environment explicitly

python
import os
from crewai_tools import SerperDevTool

tool = SerperDevTool(api_key=os.environ['SERPER_API_KEY'])

Common Mistakes

❌ Forgetting to set SERPER_API_KEY

✅ Export it in the runtime environment or pass api_key explicitly from your secret manager.

❌ Dumping entire SERP JSON into the next LLM call

✅ Summarize to top titles/URLs first to save tokens and reduce hallucination surface.

SerperDevTool FAQ

What is SerperDevTool in CrewAI?

Google search results via Serper.dev API — fast, low-cost web search for agents. SerperDevTool wraps Serper.dev's Google search JSON API so agents can discover fresh URLs, headlines, and snippets without operating your own scraping stack. Results arrive structured — titles, links, snippets — which is ideal for prompting the next reasoning step or feeding a downstream ScrapeWebsiteTool. Latency is typically dominated by Serper's upstream Google fetch, not CrewAI orchestration. Cost is per-query and predictable enough to budget in token dashboards: every u…

Which package defines the CrewAI class SerperDevTool?

DevShelfHub maps SerperDevTool to Python module crewai_tools (package path crewai_tools in this reference). Pin your installed crewai version and match imports to the snippet on this page.

When should I use SerperDevTool?

Open-web research, competitor scanning, breaking-news checks, and URL discovery before deeper scraping.

When should I avoid using SerperDevTool?

Proprietary corpora, paywalled journals, or compliance-sensitive queries where Google results are insufficient or prohibited.

How do I import SerperDevTool in Python?

from crewai_tools import SerperDevTool

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.