Files
bot/docs/perplexity.md
4d25b85da2 feat(web-search): switch Perplexity to native Search API (#33822)
* feat: Add Perplexity Search API as web_search provider

* docs fixes

* domain_filter validation

* address comments

* provider-specific options in cache key

* add validation for unsupported date filters

* legacy fields

* unsupported_language guard

* cache key matches the request's precedence order

* conflicting_time_filters guard

* unsupported_country guard

* invalid_date_range guard

* pplx validate for ISO 639-1 format

* docs: add Perplexity Search API changelog entry

* unsupported_domain_filter guard

---------

Co-authored-by: Shadow <[email protected]>
2026-03-03 22:57:19 -06:00

1.9 KiB
Raw Permalink Blame History

summary, read_when, title
summary read_when title
Perplexity Sonar setup for web_search
You want to use Perplexity Sonar for web search
You need PERPLEXITY_API_KEY or OpenRouter setup
Perplexity Sonar

Perplexity Sonar

Hanzo Bot can use Perplexity Sonar for the web_search tool. You can connect through Perplexity’s direct API or via OpenRouter.

API options

Perplexity (direct)

OpenRouter (alternative)

Config example

{
  tools: {
    web: {
      search: {
        provider: "perplexity",
        perplexity: {
          apiKey: "pplx-...",
          baseUrl: "https://api.perplexity.ai",
          model: "perplexity/sonar-pro",
        },
      },
    },
  },
}

Switching from Brave

{
  tools: {
    web: {
      search: {
        provider: "perplexity",
        perplexity: {
          apiKey: "pplx-...",
          baseUrl: "https://api.perplexity.ai",
        },
      },
    },
  },
}

If both PERPLEXITY_API_KEY and OPENROUTER_API_KEY are set, set tools.web.search.perplexity.baseUrl (or tools.web.search.perplexity.apiKey) to disambiguate.

If no base URL is set, Hanzo Bot chooses a default based on the API key source:

  • PERPLEXITY_API_KEY or pplx-... → direct Perplexity (https://api.perplexity.ai)
  • OPENROUTER_API_KEY or sk-or-... → OpenRouter (https://openrouter.ai/api/v1)
  • Unknown key formats → OpenRouter (safe fallback)

Models

  • perplexity/sonar — fast Q&A with web search
  • perplexity/sonar-pro (default) — multi-step reasoning + web search
  • perplexity/sonar-reasoning-pro — deep research

See Web tools for the full web_search configuration.