Perplexity Search API
OpenClaw supports Perplexity Search API as aweb_search provider.
It returns structured results with title, url, and snippet fields.
For compatibility, OpenClaw also supports legacy Perplexity Sonar/OpenRouter setups.
If you use OPENROUTER_API_KEY, an sk-or-... key in tools.web.search.perplexity.apiKey, or set tools.web.search.perplexity.baseUrl / model, the provider switches to the chat-completions path and returns AI-synthesized answers with citations instead of structured Search API results.
Getting a Perplexity API key
- Create a Perplexity account at perplexity.ai/settings/api
- Generate an API key in the dashboard
- Store the key in config or set
PERPLEXITY_API_KEYin the Gateway environment.
OpenRouter compatibility
If you were already using OpenRouter for Perplexity Sonar, keepprovider: "perplexity" and set OPENROUTER_API_KEY in the Gateway environment, or store an sk-or-... key in tools.web.search.perplexity.apiKey.
Optional legacy controls:
tools.web.search.perplexity.baseUrltools.web.search.perplexity.model
Config examples
Native Perplexity Search API
OpenRouter / Sonar compatibility
Where to set the key
Via config: runopenclaw configure --section web. It stores the key in
~/.openclaw/openclaw.json under tools.web.search.perplexity.apiKey.
That field also accepts SecretRef objects.
Via environment: set PERPLEXITY_API_KEY or OPENROUTER_API_KEY
in the Gateway process environment. For a gateway install, put it in
~/.openclaw/.env (or your service environment). See Env vars.
If provider: "perplexity" is configured and the Perplexity key SecretRef is unresolved with no env fallback, startup/reload fails fast.
Tool parameters
These parameters apply to the native Perplexity Search API path.| Parameter | Description |
|---|---|
query | Search query (required) |
count | Number of results to return (1-10, default: 5) |
country | 2-letter ISO country code (e.g., “US”, “DE”) |
language | ISO 639-1 language code (e.g., “en”, “de”, “fr”) |
freshness | Time filter: day (24h), week, month, or year |
date_after | Only results published after this date (YYYY-MM-DD) |
date_before | Only results published before this date (YYYY-MM-DD) |
domain_filter | Domain allowlist/denylist array (max 20) |
max_tokens | Total content budget (default: 25000, max: 1000000) |
max_tokens_per_page | Per-page token limit (default: 2048) |
query and freshness are supported.
Search API-only filters such as country, language, date_after, date_before, domain_filter, max_tokens, and max_tokens_per_page return explicit errors.
Examples:
Domain filter rules
- Maximum 20 domains per filter
- Cannot mix allowlist and denylist in the same request
- Use
-prefix for denylist entries (e.g.,["-reddit.com"])
Notes
- Perplexity Search API returns structured web search results (
title,url,snippet) - OpenRouter or explicit
baseUrl/modelswitches Perplexity back to Sonar chat completions for compatibility - Results are cached for 15 minutes by default (configurable via
cacheTtlMinutes)