Web 工具
OpenClaw 隨附兩個輕量級的 Web 工具:web_search— 透過 Brave Search API(預設)或 Perplexity Sonar(直接或經由 OpenRouter)搜尋網頁。web_fetch— HTTP 擷取+可讀內容抽取(HTML → markdown/文字)。
How it works
web_search會呼叫你設定的提供者並回傳結果。- Brave (default): returns structured results (title, URL, snippet).
- Perplexity:回傳含引用的 AI 綜合答案,來源為即時網頁搜尋。
- 結果會依查詢快取 15 分鐘(可設定)。
web_fetch會執行單純的 HTTP GET,並抽取可讀內容 (HTML → markdown/文字)。它不會執行 JavaScript。 It does not execute JavaScript. It does not execute JavaScript.web_fetch預設為啟用(除非明確停用)。
選擇搜尋提供者
| 提供者 | Pros | Cons | API 金鑰 |
|---|---|---|---|
| Brave(預設) | 快速、結構化結果、免費方案 | 傳統搜尋結果 | BRAVE_API_KEY |
| Perplexity | AI 綜合答案、引用、即時 | 需要 Perplexity 或 OpenRouter 存取 | OPENROUTER_API_KEY 或 PERPLEXITY_API_KEY |
取得 Brave API 金鑰
- 前往 https://brave.com/search/api/ 建立 Brave Search API 帳戶
- 在儀表板中選擇 Data for Search 方案(不是「Data for AI」),並產生 API 金鑰。
- 執行
openclaw configure --section web將金鑰儲存至設定(建議),或在環境中設定BRAVE_API_KEY。
在哪裡設定金鑰(建議)
建議: 執行openclaw configure --section web。 建議: 執行 openclaw configure --section web。 建議: 執行 openclaw configure --section web。它會將金鑰儲存在
~/.openclaw/openclaw.json 的 tools.web.search.apiKey 之下。
Environment alternative: set BRAVE_API_KEY in the Gateway process
environment. 對於 Gateway 安裝,請將其放在 ~/.openclaw/.env(或你的
服務環境)。 See Env vars.
使用 Perplexity(直接或經由 OpenRouter)
Perplexity Sonar 模型具備內建的網頁搜尋能力,並回傳含引用的 AI 綜合答案。 Perplexity Sonar 模型具備內建的網頁搜尋能力,並回傳含引用的 AI 綜合答案。 You can use them via OpenRouter (no credit card required - supports crypto/prepaid).取得 OpenRouter API 金鑰
- 前往 https://openrouter.ai/ 建立帳戶
- 加值(支援加密貨幣、預付或信用卡)
- 在帳戶設定中產生 API 金鑰
設定 Perplexity 搜尋
BRAVE_API_KEY in the Gateway process
environment. 對於 Gateway 安裝,請將其放在 ~/.openclaw/.env(或你的
服務環境)。 See Env vars.
如果未設定 base URL,OpenClaw 會根據 API 金鑰來源選擇預設值:
PERPLEXITY_API_KEY或pplx-...→https://api.perplexity.aiOPENROUTER_API_KEY或sk-or-...→https://openrouter.ai/api/v1- 未知的金鑰格式 → OpenRouter(安全的後備)
可用的 Perplexity 模型
| 模型 | Description | 最適合 |
|---|---|---|
perplexity/sonar | 具網頁搜尋的快速問答 | 快速查詢 |
perplexity/sonar-pro(預設) | 具網頁搜尋的多步推理 | 複雜問題 |
perplexity/sonar-reasoning-pro | 思維鏈分析 | 深度研究 |
web_search
使用你設定的提供者進行網頁搜尋。需求
tools.web.search.enabled不得為false(預設:啟用)- 你選擇之提供者的 API 金鑰:
- Brave:
BRAVE_API_KEY或tools.web.search.apiKey - Perplexity:
OPENROUTER_API_KEY、PERPLEXITY_API_KEY或tools.web.search.perplexity.apiKey
- Brave:
設定
工具參數
query(必填)count(1–10;預設來自設定)country(選填):用於地區限定結果的 2 碼國家代碼(例如「DE」、「US」、「ALL」)。若省略,Brave 會選擇其預設地區。 若省略,Brave 會選擇其預設地區。search_lang(選填):搜尋結果的 ISO 語言代碼(例如「de」、「en」、「fr」)ui_lang(選填):UI 元素的 ISO 語言代碼freshness(選用):依發現時間篩選- Brave:
pd、pw、pm、py或YYYY-MM-DDtoYYYY-MM-DD - Perplexity:
pd、pw、pm、py
- Brave:
web_fetch
擷取一個 URL 並萃取可讀內容。web_fetch 需求
tools.web.fetch.enabled不得為false(預設:啟用)- 選用的 Firecrawl 後備:設定
tools.web.fetch.firecrawl.apiKey或FIRECRAWL_API_KEY。
web_fetch 設定
web_fetch 工具參數
url(必填,僅 http/https)extractMode(markdown|text)maxChars(截斷過長頁面)
web_fetch會先使用 Readability(主內容抽取),再使用 Firecrawl(若已設定)。若兩者皆失敗,工具會回傳錯誤。 如果兩者都失敗,工具會回傳錯誤。 如果兩者都失敗,工具會回傳錯誤。- Firecrawl 請求預設使用規避機器人模式並快取結果。
web_fetch預設送出類 Chrome 的 User-Agent 與Accept-Language;必要時可覆寫userAgent。web_fetch會封鎖私人/內部主機名稱並重新檢查重新導向(可用maxRedirects限制)。maxChars會被限制為tools.web.fetch.maxCharsCap。web_fetch為盡力而為的抽取;部分網站需要使用瀏覽器工具。- 金鑰設定與服務細節請參閱 Firecrawl。
- 回應會被快取(預設 15 分鐘)以減少重複擷取。
- 若你使用工具設定檔/允許清單,請加入
web_search/web_fetch或group:web。 - 若缺少 Brave 金鑰,
web_search會回傳簡短的設定提示並附上文件連結。