Skip to main content

Perplexity Search API

Velaclaw supports Perplexity Search API as a web_search provider. It returns structured results with title, url, and snippet fields. For compatibility, Velaclaw also supports legacy Perplexity Sonar/OpenRouter setups. If you use OPENROUTER_API_KEY, an sk-or-... key in plugins.entries.perplexity.config.webSearch.apiKey, or set plugins.entries.perplexity.config.webSearch.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

  1. Create a Perplexity account at perplexity.ai/settings/api
  2. Generate an API key in the dashboard
  3. Store the key in config or set PERPLEXITY_API_KEY in the Gateway environment.

OpenRouter compatibility

If you were already using OpenRouter for Perplexity Sonar, keep provider: "perplexity" and set OPENROUTER_API_KEY in the Gateway environment, or store an sk-or-... key in plugins.entries.perplexity.config.webSearch.apiKey. Optional compatibility controls:
  • plugins.entries.perplexity.config.webSearch.baseUrl
  • plugins.entries.perplexity.config.webSearch.model

Config examples

Native Perplexity Search API

OpenRouter / Sonar compatibility

Where to set the key

Via config: run velaclaw configure --section web. It stores the key in ~/.Zavianx/velaclaw-dev.json under plugins.entries.perplexity.config.webSearch.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 ~/.velaclaw/.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. For the legacy Sonar/OpenRouter compatibility path:
  • query, count, and freshness are accepted
  • count is compatibility-only there; the response is still one synthesized answer with citations rather than an N-result list
  • 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 plugins.entries.perplexity.config.webSearch.baseUrl / model switches Perplexity back to Sonar chat completions for compatibility
  • Sonar/OpenRouter compatibility returns one synthesized answer with citations, not structured result rows
  • Results are cached for 15 minutes by default (configurable via cacheTtlMinutes)