跳到內容

使用 Perplexity Sonar 強化 OpenClaw 的網頁搜尋功能

做 AI 應用的時候,最煩人的就是模型輸出的資訊太舊,或是沒辦法即時抓取網路上的最新消息。你自己寫爬蟲不只累,還要處理各種防爬機制和資料清洗,這對開發者來說真的是個不小的負擔。

如果你的 AI 需要處理需要即時資訊的任務,整合一個強大的搜尋工具是最好的選擇。OpenClaw 現在支援使用 Perplexity Sonar 作為 web_search 的後端,讓你直接跳過繁瑣的抓取流程。

  • Perplexity API Key(環境變數:PERPLEXITY_API_KEY)
  • 或 OpenRouter API Key(環境變數:OPENROUTER_API_KEY)
  • OpenClaw 專案環境

你可以選擇直接連接 Perplexity 官方 API,或是透過支援加密貨幣儲值的 OpenRouter 來存取。

將以下內容貼進你的設定檔,即可啟用搜尋功能:

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

根據你的需求,可以選擇不同的 Sonar 模型:

  • perplexity/sonar: 適合快速的網頁搜尋與簡單問答。
  • perplexity/sonar-pro (預設): 支援多步驟推理,適合複雜的搜尋任務。
  • perplexity/sonar-reasoning-pro: 針對深度研究需求設計。

如果你之前是用 Brave Search,切換到 Perplexity 的配置非常簡單:

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

如果你在環境變數中同時設定了 PERPLEXITY_API_KEY 和 OPENROUTER_API_KEY,OpenClaw 可能會混淆。這時候請務必在配置中明確設定 tools.web.search.perplexity.baseUrl 或 apiKey 來指定來源。

當你沒有設定 Base URL 時,OpenClaw 會根據 Key 的格式自動判斷:

  • pplx-... 開頭:自動導向 https://api.perplexity.ai。
  • sk-or-... 開頭:自動導向 https://openrouter.ai/api/v1。
  • 其他未知格式:預設會使用 OpenRouter 作為安全備案。

有任何設定上的問題嗎?可以直接詢問 AI Setup Assistant。

  • Web tools: 查看完整的 web_search 配置選項。
OpenClaw

OpenClaw Expert

還是卡住了?

如果這篇文件沒有解決你的情境,直接問 OpenClaw Expert,拿到可執行步驟。