Skip to main content

Web 工具

OpenClaw 隨附兩個輕量級的 Web 工具:
  • web_search — 透過 Brave Search API(預設)或 Perplexity Sonar(直接或經由 OpenRouter)搜尋網頁。
  • web_fetch — HTTP 擷取+可讀內容抽取(HTML → markdown/文字)。
These are not browser automation. 對於 JS 密集型網站或登入,請使用 Browser tool

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 預設為啟用(除非明確停用)。

選擇搜尋提供者

請參閱 Brave Search 設定Perplexity Sonar 以取得提供者專屬細節。 在設定中指定提供者:
範例:切換為 Perplexity Sonar(直接 API):

取得 Brave API 金鑰

  1. 前往 https://brave.com/search/api/ 建立 Brave Search API 帳戶
  2. 在儀表板中選擇 Data for Search 方案(不是「Data for AI」),並產生 API 金鑰。
  3. 執行 openclaw configure --section web 將金鑰儲存至設定(建議),或在環境中設定 BRAVE_API_KEY
Brave 提供免費方案與付費方案;請查看 Brave API 入口網站以了解 目前的限制與定價。

在哪裡設定金鑰(建議)

建議: 執行 openclaw configure --section web建議: 執行 openclaw configure --section web建議: 執行 openclaw configure --section web。它會將金鑰儲存在 ~/.openclaw/openclaw.jsontools.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 金鑰

  1. 前往 https://openrouter.ai/ 建立帳戶
  2. 加值(支援加密貨幣、預付或信用卡)
  3. 在帳戶設定中產生 API 金鑰

設定 Perplexity 搜尋

Environment alternative: set BRAVE_API_KEY in the Gateway process environment. 對於 Gateway 安裝,請將其放在 ~/.openclaw/.env(或你的 服務環境)。 See Env vars. 如果未設定 base URL,OpenClaw 會根據 API 金鑰來源選擇預設值:
  • PERPLEXITY_API_KEYpplx-...https://api.perplexity.ai
  • OPENROUTER_API_KEYsk-or-...https://openrouter.ai/api/v1
  • 未知的金鑰格式 → OpenRouter(安全的後備)

可用的 Perplexity 模型

使用你設定的提供者進行網頁搜尋。

需求

  • tools.web.search.enabled 不得為 false(預設:啟用)
  • 你選擇之提供者的 API 金鑰:
    • BraveBRAVE_API_KEYtools.web.search.apiKey
    • PerplexityOPENROUTER_API_KEYPERPLEXITY_API_KEYtools.web.search.perplexity.apiKey

設定

工具參數

  • query(必填)
  • count(1–10;預設來自設定)
  • country(選填):用於地區限定結果的 2 碼國家代碼(例如「DE」、「US」、「ALL」)。若省略,Brave 會選擇其預設地區。 若省略,Brave 會選擇其預設地區。
  • search_lang(選填):搜尋結果的 ISO 語言代碼(例如「de」、「en」、「fr」)
  • ui_lang(選填):UI 元素的 ISO 語言代碼
  • freshness(選用):依發現時間篩選
    • Brave:pdpwpmpyYYYY-MM-DDtoYYYY-MM-DD
    • Perplexity:pdpwpmpy
範例:

web_fetch

擷取一個 URL 並萃取可讀內容。

web_fetch 需求

  • tools.web.fetch.enabled 不得為 false(預設:啟用)
  • 選用的 Firecrawl 後備:設定 tools.web.fetch.firecrawl.apiKeyFIRECRAWL_API_KEY

web_fetch 設定

web_fetch 工具參數

  • url(必填,僅 http/https)
  • extractModemarkdown | 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_fetchgroup:web
  • 若缺少 Brave 金鑰,web_search 會回傳簡短的設定提示並附上文件連結。