Skip to content

feat(tools): add Perplexity Search tool#5554

Open
james-pplx wants to merge 1 commit intogoogle:mainfrom
james-pplx:add-perplexity-search-tool
Open

feat(tools): add Perplexity Search tool#5554
james-pplx wants to merge 1 commit intogoogle:mainfrom
james-pplx:add-perplexity-search-tool

Conversation

@james-pplx
Copy link
Copy Markdown

Summary

Adds PerplexitySearchTool — a new built-in tool that performs web search via the Perplexity Search API (POST https://api.perplexity.ai/search).

The tool follows the existing search-tool pattern in this repo (mirrors DiscoveryEngineSearchTool / VertexAiSearchTool): it subclasses FunctionTool, exposes a single query argument to the model, and lets developers pin server-side options (max_results, search_recency_filter, search_domain_filter, etc.) at construction time. HTTP calls go through httpx.AsyncClient, which is already in core deps — no new dependency is added.

Every outgoing request includes an X-Pplx-Integration: google-adk/<version> header for attribution. The API key can be supplied via constructor or the PERPLEXITY_API_KEY environment variable.

API reference: https://docs.perplexity.ai/api-reference/search-post

Files

  • src/google/adk/tools/perplexity_search_tool.py — tool implementation
  • src/google/adk/tools/__init__.py — lazy export entry
  • tests/unittests/tools/test_perplexity_search_tool.py — 12 unit tests
  • contributing/samples/perplexity_search_agent/ — example agent (mirrors google_search_agent sample)

Testing plan

  • Unit tests added under tests/unittests/tools/test_perplexity_search_tool.py (12 tests, all passing locally with pytest).
  • Tests use httpx.MockTransport so no live HTTP calls are made.
  • Tests assert the X-Pplx-Integration attribution header, Authorization: Bearer header, request URL, request method, and the request body shape (with and without options).
  • Tests cover error paths (HTTP status error, transport error) and the lazy import in google.adk.tools.
  • pyink and isort (Google profile) clean.
$ pytest tests/unittests/tools/test_perplexity_search_tool.py -v
============================== 12 passed in 1.46s ==============================

Add a new built-in tool, PerplexitySearchTool, that calls the Perplexity
Search API (POST https://api.perplexity.ai/search) via httpx.AsyncClient.
The tool wraps a single `query` argument for the model and lets developers
pin server-side options (max_results, recency, domain filter, etc.) at
construction time, mirroring the pattern of DiscoveryEngineSearchTool.

Every outgoing request includes the X-Pplx-Integration header set to
google-adk/<package-version> for attribution. The API key can be supplied
via constructor or PERPLEXITY_API_KEY.

- src/google/adk/tools/perplexity_search_tool.py: tool implementation
- src/google/adk/tools/__init__.py: lazy export
- tests/unittests/tools/test_perplexity_search_tool.py: 12 tests with a
  mocked httpx transport, including an assertion that the attribution
  header is sent
- contributing/samples/perplexity_search_agent: example agent

Docs: https://docs.perplexity.ai/api-reference/search-post
Signed-off-by: james-pplx <james-pplx@users.noreply.github.com>
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 30, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Apr 30, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Apr 30, 2026

Response from ADK Triaging Agent

Hello @james-pplx, thank you for creating this PR!

To help us track and review this new feature, could you please create a GitHub issue and associate it with this PR?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants