Perplexity Web Search Provider Setup: API Key, Modes, Filtering

Learn how to configure the Perplexity web search provider, including API key setup, search modes (native API vs. Sonar chat completions), and filtering options. This guide is for developers integrating Perplexity search into their agents.

Read this when

  • You want to configure Perplexity as a web search provider
  • You need the Perplexity API key or OpenRouter proxy setup

The Perplexity plugin adds a web_search provider that offers two transport mechanisms: the native Perplexity Search API (which returns structured results with filtering capabilities) and Perplexity Sonar chat completions (which produce AI-generated answers with citations), the latter available either directly or through OpenRouter.

Note

This document explains how to configure the Perplexity provider. For details on the Perplexity tool (how the agent interacts with it), refer to Perplexity search.

PropertyValue
TypeWeb search provider (not a model provider)
AuthPERPLEXITY_API_KEY (native) or OPENROUTER_API_KEY (via OpenRouter)
Config pathplugins.entries.perplexity.config.webSearch.apiKey
Overridesplugins.entries.perplexity.config.webSearch.baseUrl / .model
Get a keyperplexity.ai/settings/api

Install plugin

openclaw plugins install @openclaw/perplexity-plugin
openclaw gateway restart

Getting started

Set the API key

openclaw configure --section web

Alternatively, set the key directly:

openclaw config set plugins.entries.perplexity.config.webSearch.apiKey "pplx-xxxxxxxxxxxx"

A key exported as PERPLEXITY_API_KEY or OPENROUTER_API_KEY in the Gateway environment will also be recognized.

Start searching

web_search automatically identifies Perplexity when its key is the only available search credential, requiring no additional configuration. To explicitly specify the provider:

openclaw config set tools.web.search.provider perplexity

Search modes

The plugin determines which transport to use in the following priority order:

  1. If webSearch.baseUrl or webSearch.model is set: traffic always goes through Sonar chat completions against that endpoint, regardless of the key type.
  2. If not, the key source dictates the endpoint: a configured key's prefix selects the transport (configuration takes precedence over environment variables); an environment key uses its corresponding endpoint directly.
Key prefixTransportFeatures
pplx-Native Perplexity Search API (https://api.perplexity.ai)Structured results, domain/language/date filters
sk-or-OpenRouter (https://openrouter.ai/api/v1), Sonar modelAI-synthesized answers with citations

A configured key with any other prefix will also use the native Search API. The chat-completions path defaults to the perplexity/sonar-pro model; you can change it with plugins.entries.perplexity.config.webSearch.model.

Native API filtering

FilterDescriptionTransport
countNumber of results per search, 1-10 (default 5)Native only
freshnessRecency filter: day, week, month, yearBoth
country2-letter country code (us, de, jp)Native only
languageISO 639-1 language code (en, fr, zh)Native only
date_after / date_beforePublished-date range in YYYY-MM-DDNative only
domain_filterMax 20 domains; allowlist or --prefixed denylist, never mixedNative only
max_tokens / max_tokens_per_pageContent budget across all results / per pageNative only

Filters exclusive to the native transport will return a descriptive error when used on the chat-completions path. freshness cannot be used together with date_after/date_before.

Advanced configuration

Environment variable for daemon processes

Warning

A key exported only within an interactive shell session will not be accessible to a launchd/systemd Gateway daemon unless that environment is explicitly imported. Set the key in ~/.openclaw/.env or using env.shellEnv so the Gateway process can read it. See Environment variables for the complete precedence order.

OpenRouter proxy setup

If you already have an OpenRouter billing arrangement and prefer to consolidate providers there, use an OPENROUTER_API_KEY (prefixed with sk-or-) rather than a native Perplexity key. OpenClaw automatically detects this key type and switches to the Sonar transport. This is convenient when you want to route Perplexity searches through OpenRouter.

628 words · updated Jul 27, 2026