Start with the direct examples. They need no agent SDK extra. These commands use
the published package and add python-dotenv so the scripts can load .env:
uv run --isolated --no-project --with serpapi-search-tools --with python-dotenv examples/direct_search.py
uv run --isolated --no-project --with serpapi-search-tools --with python-dotenv examples/direct_travel.py
uv run --isolated --no-project --with serpapi-search-tools --with python-dotenv examples/direct_multi_search.py
uv run --isolated --no-project --with serpapi-search-tools --with python-dotenv examples/direct_marketplace_comparison.py
uv run --isolated --no-project --with serpapi-search-tools --with python-dotenv examples/direct_regioned_search.py
uv run --isolated --no-project --with serpapi-search-tools --with python-dotenv examples/direct_cached_search.pyEvery script loads .env before reading credentials. Copy examples/sample.env
to .env, or export values in your shell. You always need SERPAPI_API_KEY or
SERPAPI_KEY; agent examples also need their model provider key.
Run an agent example with its extra:
uv run --isolated --no-project --with 'serpapi-search-tools[openai-agents]' --with python-dotenv examples/openai_agents_openai.py
uv run --isolated --no-project --with 'serpapi-search-tools[openai-agents]' --with python-dotenv examples/openai_agents_travel_planner.py
uv run --isolated --no-project --with 'serpapi-search-tools[langchain]' --with python-dotenv --with langchain-openai examples/langchain_grok.py
uv run --isolated --no-project --with 'serpapi-search-tools[langgraph]' --with python-dotenv --with langchain-openai examples/langgraph_openai.py
uv run --isolated --no-project --with 'serpapi-search-tools[llamaindex]' --with python-dotenv --with llama-index-llms-openai \
examples/llamaindex_openai.py
uv run --isolated --no-project --with 'serpapi-search-tools[microsoft-agent-framework]' --with python-dotenv examples/microsoft_agent_framework_openai.py
uv run --isolated --no-project --with 'serpapi-search-tools[claude-agent-sdk]' --with python-dotenv examples/claude_agent_sdk_sonnet.py
uv run --isolated --no-project --with 'serpapi-search-tools[google-adk]' --with python-dotenv examples/google_adk_gemini.py--no-project keeps these commands independent of the repository's local
package and development environment.
The examples default to gpt-5.4-mini, claude-sonnet-5,
gemini-flash-lite-latest, and grok-4.5. Override the corresponding model
environment variable when needed.
The two multi-tool OpenAI Agents scenarios use _logging_client.py to log safe request metadata and response format. Agent examples use compact Markdown by default. Direct examples that inspect named response fields request JSON explicitly. result_limit controls how many rows or items are kept in each result section, and compact mode omits supporting sections.
