# Pydantic AI

Pydantic AI accepts the returned search function directly in its `tools` list.


# Install

``` bash
pip install "serpapi-search-tools[pydantic-ai]"
```

If Pydantic AI is already installed in your project, use `pip install serpapi-search-tools` instead.

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


# Run it

``` python
import os

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIResponsesModel
from pydantic_ai.providers.openai import OpenAIProvider
from serpapi_search_tools import images_search, web_search

model = OpenAIResponsesModel(
    "gpt-5.6-luna",
    provider=OpenAIProvider(api_key=os.getenv("OPENAI_API_KEY")),
)

agent = Agent(
    model,
    instructions="Use live search when current information helps.",
    tools=[
        web_search(),
        images_search(),
    ],
)

result = agent.run_sync("Find current visual trends in minimal desk setups.")
print(result.output)
```


# Try it

Ask: "Search Google Images for minimal desk setups and summarize three visual themes."


# Customize the search

``` python
image_search = images_search(
    default_params={"hl": "en", "gl": "us"},
    result_limit=5,
    include_examples=False,
)
```

Use [images_search](../../reference/images_search.md#serpapi_search_tools.images_search) when you want the agent to look specifically for images rather than general web pages.
