Powering Web Search with Perplexity Sonar
I often find myself stuck when an AI agent can’t access live data. It is frustrating to get outdated answers or generic responses when I need real-time information from the web. I want my tools to actually find what is happening right now without me doing the manual digging.
If you want your agent to have better research capabilities, I recommend switching your search provider to Perplexity Sonar. It combines web searching with reasoning to give you much better results than a standard search engine.
What You’ll Need
Section titled “What You’ll Need”- A Perplexity API key or an OpenRouter API key.
- The
PERPLEXITY_API_KEYorOPENROUTER_API_KEYenvironment variable.
Quick Start
Section titled “Quick Start”You can connect through Perplexity’s direct API or via OpenRouter. I suggest using the direct API if you already have a Perplexity account, but OpenRouter is great if you prefer using prepaid or crypto credits.
To get started, update your configuration file. If you are currently using Brave and want to switch, your config should look like this:
{ tools: { web: { search: { provider: "perplexity", perplexity: { apiKey: "pplx-...", baseUrl: "https://api.perplexity.ai", }, }, }, },}If you want to specify a specific model, like the one designed for deep research, use this setup:
{ tools: { web: { search: { provider: "perplexity", perplexity: { apiKey: "pplx-...", baseUrl: "https://api.perplexity.ai", model: "perplexity/sonar-pro", }, }, }, },}You can choose from these available models:
perplexity/sonar-pro: This is the default. It uses multi-step reasoning.perplexity/sonar: Best for fast Q&A.perplexity/sonar-reasoning-pro: Use this for deep research.
Troubleshooting
Section titled “Troubleshooting”Conflicting API Keys
Section titled “Conflicting API Keys”If you have both PERPLEXITY_API_KEY and OPENROUTER_API_KEY set in your environment, OpenClaw might not know which one to use. To fix this, you should set tools.web.search.perplexity.baseUrl or tools.web.search.perplexity.apiKey in your config to tell the system which provider to prioritize.
Automatic Provider Selection
Section titled “Automatic Provider Selection”If you don’t set a base URL, OpenClaw chooses a default based on your API key format:
- Keys starting with
pplx-...use the direct Perplexity API (https://api.perplexity.ai). - Keys starting with
sk-or-...use OpenRouter (https://openrouter.ai/api/v1). - If the key format is unknown, it uses OpenRouter as a safe fallback.
If you need help with your specific configuration, check out the AI Setup Assistant.
What’s Next
Section titled “What’s Next”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.