Overview
Serper provides fast, affordable access to Google Search results via API. Get structured search results including web, images, news, and more.Installation
Environment Variables
How It Works
Quick Start
Usage with Agent
Available Methods
search(query, num_results=10)
Search Google for web results.news(query, num_results=10)
Search Google News.images(query, num_results=10)
Search Google Images.Configuration Options
Function-Based Usage
CLI Usage
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
SERPER_API_KEY not configured | Missing API key | Set environment variable |
Invalid API key | Wrong API key | Verify at serper.dev |
Rate limited | Too many requests | Check usage limits |
Best Practices
Let SERPER_API_KEY come from the environment
Let SERPER_API_KEY come from the environment
SerperTool() defaults to the SERPER_API_KEY env var. Set it in your shell or .env rather than passing api_key= inline.Cap num_results
Cap num_results
search(query, num_results=10) defaults to 10. Lower it so the agent processes fewer tokens and responds faster.Pick the right endpoint
Pick the right endpoint
Serper exposes
search, news, and images. Route the agent to the endpoint that matches the task to avoid noisy results.Related Tools
Tavily
AI-powered search
DuckDuckGo
Privacy-focused search
Exa
Neural search

