# Introducing SerpApi Search Tools: Real-Time Web Search for Python AI Agents

> Source: <https://serpapi.com/blog/introducing-serpapi-search-tools-real-time-web-search-for-python-ai-agents/>
> Published: 2026-08-06 05:01:41+00:00

`serpapi-search-tools`

gives Python AI agents real-time access to the web, news, maps, images, shopping, videos, hotels, flights, and travel search, powered by SerpApi. It works with 14 popular agent SDKs, including LangChain, Agno, CrewAI, OpenAI Agents, Pydantic AI, and Google ADK.

AI agents are useful, but they cannot answer questions about current news, prices, places, or travel options unless they have a way to search. [SerpApi](https://serpapi.com/) lets applications search services such as Google, Bing, Google Maps, Google News, Google Shopping, YouTube, Google Hotels, and Google Flights, then returns organized data that the agent can use.

We released [serpapi-search-tools](https://pypi.org/project/serpapi-search-tools/) to make that search data easy to use in Python agents. The package gives your agent ready-to-use search tools, so you can focus on what the agent should do instead of building a search integration from scratch.

The package is open source on [GitHub](https://github.com/serpapi/serpapi-search-tools-python), and the complete guides and examples are available in the [documentation](https://serpapi.github.io/serpapi-search-tools-python/).

## Add real-time web search to your first Python agent

This example uses the OpenAI Agents SDK and gives a simple agent access to web search.

### Install

You need Python 3.10 or newer, a SerpApi account, and an API key for the model provider your agent uses. This example uses OpenAI.

For this tutorial, install `serpapi-search-tools`

and the OpenAI Agents SDK together using pip:

```
pip install "serpapi-search-tools[openai-agents]"
```

If OpenAI Agents is already installed, you can install only the search tools:

```
pip install serpapi-search-tools
```

If you use uv, run:

```
uv add "serpapi-search-tools[openai-agents]"
```

For another agent SDK, choose its install option from the [SDK examples](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/).

### Add your API keys

Your agent needs a SerpApi key for search and an OpenAI key for the model:

```
export SERPAPI_API_KEY="your-serpapi-key"
export OPENAI_API_KEY="your-openai-key"
```

You can [create a SerpApi account](https://serpapi.com/users/sign_up) and copy your private API key from the [SerpApi dashboard](https://serpapi.com/dashboard).

### Build your first agent

Save this as `search_agent.py`

:

``` python
import asyncio

from agents import Agent, Runner
from serpapi_search_tools import web_search

async def main():
    agent = Agent(
        name="research-agent",
        model="gpt-5.6-luna",
        instructions=(
            "Use web search for current facts."
        ),
        tools=[web_search()],
    )

    result = await Runner.run(
        agent,
        "Find three new Python features and briefly explain them.",
    )

    for item in result.new_items:
        if item.type == "tool_call_item":
            print(f"Tool called: {item.tool_name}")
            print(f"Arguments: {item.raw_item.arguments}")

    print("Agent Response: ", result.final_output)

asyncio.run(main())
```

Run it:

```
python search_agent.py
```

The example prints each tool call and its arguments before the final answer. This makes the agent's search process visible, including the queries it created and the search engine it selected.

Here is the output from an actual run:

```
Tool called: web_search
Arguments: {"query":"Python latest release new features Python 3.14 official what's new","engine":"google_light"}

Tool called: web_search
Arguments: {"query":"site:python.org/downloads/release Python 3.14 new features","engine":"google_light"}

Agent Response:  According to the official Python 3.14 documentation, three notable new features are:

1. **Template string literals (t-strings)** — A flexible way to create customized string-processing templates, useful for safer formatting and domain-specific text handling.

2. **Deferred evaluation of annotations** — Type annotations are evaluated later rather than immediately, reducing import problems and improving compatibility with forward references.

3. **Standard-library subinterpreters** — Python now provides tools for running isolated interpreters within one process, enabling better parallelism and isolation.

Source: [Python 3.14 “What’s New”](https://docs.python.org/3/whatsnew/3.14.html)
```

The two printed calls show that the agent searched more than once to verify the answer. `web_search()`

gave it the search capability, while the instruction told it to use that capability for current facts.

## Nine search tools for common agent tasks

Different searches need different information. A hotel search needs stay dates, while a flight search needs airports and a travel date. `serpapi-search-tools`

gives your agent a focused tool for each task so it knows what information to provide.

| What you want your agent to do | Search tool | Search source |
|---|---|---|
| Research a current topic |
`web_search` |

[Google Light](https://serpapi.com/google-light-api)by default, with Google, Bing, Yahoo, or DuckDuckGo available`news_search`

[Google News](https://serpapi.com/google-news-api)`maps_search`

[Google Maps](https://serpapi.com/google-maps-api)`images_search`

[Google Images](https://serpapi.com/google-images-api)`shopping_search`

[Google Shopping](https://serpapi.com/google-shopping-api), Amazon, Walmart, or eBay`videos_search`

[YouTube](https://serpapi.com/youtube-search-api)`hotels_search`

[Google Hotels](https://serpapi.com/google-hotels-api)`flights_search`

[Google Flights](https://serpapi.com/google-flights-api)`travel_explore_search`

[Google Travel Explore](https://serpapi.com/google-travel-explore-api)Choose only the tools your agent needs. A shopping assistant might use web, shopping, and image search. A trip planner might use flights, hotels, maps, and travel exploration.

## One package for 14 Python agent SDKs

An agent SDK is the Python library you use to build and run an agent. You can use `serpapi-search-tools`

with the SDK you already know, and each link below opens a complete example.

| Supported SDK | Start here |
|---|---|
| OpenAI Agents SDK |
|

[Pydantic AI example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/pydantic_ai.html)[LangChain example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/langchain.html)[LangGraph example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/langgraph.html)[CrewAI example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/crewai.html)[LlamaIndex example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/llamaindex.html)[Claude Agent SDK example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/claude_agent_sdk.html)[Microsoft Agent Framework example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/microsoft_agent_framework.html)[AutoGen example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/autogen.html)[Haystack example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/haystack.html)[Semantic Kernel example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/semantic_kernel.html)[Agno example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/agno.html)[smolagents example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/smolagents.html)[Google ADK example](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/google_adk.html)### The same search tools in every SDK

The search tool names stay the same across supported SDKs:

``` python
from serpapi_search_tools import maps_search, news_search, web_search

search_tools = [
    web_search(),
    news_search(),
    maps_search(),
]
```

Add these to your SDK the way you normally add tools. If you later switch SDKs, the surrounding agent code changes but your search setup stays familiar: `web_search()`

is still `web_search()`

. The [SDK examples](https://serpapi.github.io/serpapi-search-tools-python/docs/sdk-examples/) show the complete setup for every supported integration.

### The package recognizes your SDK automatically

In a typical project, you install one supported agent SDK and call a search tool such as `web_search()`

. The package recognizes the installed SDK and prepares the tool for it automatically.

You usually do not need any extra setup. If your project has more than one supported SDK installed, the [agent SDK guide](https://serpapi.github.io/serpapi-search-tools-python/user-guide/frameworks.html) shows how to select the one you want.

## Customize search for your agent

The defaults are a good place to start, so you can use a simple call such as `web_search()`

in your first agent. When you need more control, these six recipes cover common search and response settings.

### 1. Use one fast web search engine

Google Light is the default web engine. You can make it the agent's only choice and set the language, country, result count, and timeout in your application:

``` python
from serpapi_search_tools import web_search

search = web_search(
    allowed_engines=["google_light"],
    default_params={"num": 3, "hl": "en", "gl": "us"},
    timeout=20.0,
)
```

The agent still chooses the search query. Your application keeps control of the search engine and settings.

### 2. Give the agent regional search choices

Create separately named tools when the agent needs to search different countries or languages:

``` python
from serpapi_search_tools import web_search

search_us = web_search(
    allowed_engines=["google_light"],
    default_params={"gl": "us", "hl": "en", "num": 3},
    name="web_search_us",
)
search_de = web_search(
    allowed_engines=["google_light"],
    default_params={"gl": "de", "hl": "de", "num": 3},
    name="web_search_de",
)

tools = [search_us, search_de]
```

The names help the agent choose the right regional search for the question.

### 3. Compare products across marketplaces

Create separate shopping tools when you want the agent to compare results from different marketplaces:

``` python
from serpapi_search_tools import shopping_search

google_products = shopping_search(
    allowed_engines=["google_shopping"],
    default_params={"gl": "us", "hl": "en", "num": 5},
    name="google_products",
)
amazon_products = shopping_search(
    allowed_engines=["amazon"],
    default_params={"num": 5},
    name="amazon_products",
)

tools = [google_products, amazon_products]
```

Google Shopping can compare products across merchants, while Amazon searches its own marketplace. You can create similar tools for Walmart and eBay.

### 4. Add safe, localized image search

Keep safe search, language, and country settings under your application's control:

``` python
from serpapi_search_tools import images_search

safe_images = images_search(
    default_params={"safe": "active", "hl": "en", "gl": "us"},
    name="safe_image_search",
)
```

The agent only needs to describe what images it wants to find; your application applies the search policy every time.

### 5. Keep travel prices in one currency

Use the same currency and locale across flight and hotel tools so their prices are easier to compare:

``` python
from serpapi_search_tools import flights_search, hotels_search

travel_defaults = {"currency": "USD", "hl": "en", "gl": "us"}

flight_search = flights_search(
    default_params=travel_defaults,
    name="us_flights",
)
hotel_search = hotels_search(
    default_params=travel_defaults,
    name="us_hotel_prices",
)

tools = [flight_search, hotel_search]
```

The agent still provides the route, destination, and dates. Your application keeps the display currency and locale consistent.

### 6. Choose compact or full results

Every search tool uses compact results by default. Compact mode keeps the response focused, which is usually the best choice for an agent:

``` python
from serpapi_search_tools import web_search

search = web_search()
```

If your application needs the complete SerpApi response, including additional sections and metadata, choose full mode:

``` python
from serpapi_search_tools import SearchResultMode, web_search

search = web_search(mode=SearchResultMode.FULL)
```

Use full results only when your application needs the extra data; compact results help avoid filling the model's context with information it may not use.

You can also configure locations, result limits, and other tool-specific settings. The [configuration guide](https://serpapi.github.io/serpapi-search-tools-python/user-guide/configuration.html) contains the complete set of options and examples. Visit the [full documentation](https://serpapi.github.io/serpapi-search-tools-python/) for installation, SDK guides, recipes, and API details.

## Complete agent projects you can copy

The [agent cookbook](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/) contains complete projects for every supported SDK. Each guide includes setup instructions, a prompt you can edit, runnable code, and an output you can inspect.

| SDK | Cookbook agent | SerpApi capabilities used |
|---|---|---|
|

[LangGraph](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/langgraph.html)[CrewAI](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/crewai.html)[LlamaIndex](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/llamaindex.html)[OpenAI Agents](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/openai-agents.html)[Claude Agent SDK](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/claude-agent-sdk.html)[Pydantic AI](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/pydantic-ai.html)[Microsoft Agent Framework](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/microsoft-agent-framework.html)[AutoGen](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/autogen.html)[Haystack](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/haystack.html)[Semantic Kernel](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/semantic-kernel.html)[Agno](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/agno.html)[smolagents](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/smolagents.html)[Google ADK](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/google-adk.html)Start with the cookbook project closest to your idea, then change the prompt and search tools to fit your use case.

## Learn more about building agents

If you are new to AI agents or want a longer tutorial, continue with these guides:

[Building an AI Agent in Python](https://serpapi.com/blog/building-an-ai-agent-in-python/)explains agents, prompts, context, memory, tools, MCP, and skills from the beginning.[Build Smarter Pydantic AI Agents with Real-Time Search](https://serpapi.com/blog/smarter-pydantic-ai-agents-with-real-time-search/)shows how to add SerpApi search to a Pydantic AI agent step by step.[Build an AI Agent with the Claude Agent SDK](https://serpapi.com/blog/build-an-ai-agent-with-claude-agent-sdk/)shows how to build a Claude agent and connect it to custom tools.

## Start building

Install the option for your SDK, add one or two search tools, and start from the [cookbook project](https://serpapi.github.io/serpapi-search-tools-python/docs/cookbook/) closest to your idea. The package is on [PyPI](https://pypi.org/project/serpapi-search-tools/), the source is on [GitHub](https://github.com/serpapi/serpapi-search-tools-python), and issues and pull requests are welcome.

If you are new to SerpApi, [create a free account](https://serpapi.com/users/sign_up) and give your Python agent real-time search data in a few minutes.
