Skip to main content

Gemini 搜尋

OpenClaw 支援 Gemini 模型與內置的 Google Search 接地,它返回由即時 Google Search 結果支援的 AI 合成答案及引用。

取得 API 金鑰

1

建立金鑰

前往 Google AI Studio 並建立 API 金鑰。
2

儲存金鑰

在 Gateway 環境中設定 GEMINI_API_KEY,或透過以下方式設定:
openclaw configure --section web

設定

{
  plugins: {
    entries: {
      google: {
        config: {
          webSearch: {
            apiKey: "AIza...", // 如果設定了 GEMINI_API_KEY 則選用
            model: "gemini-2.5-flash", // 預設值
          },
        },
      },
    },
  },
  tools: {
    web: {
      search: {
        provider: "gemini",
      },
    },
  },
}
環境替代方案: 在 Gateway 環境中設定 GEMINI_API_KEY。對於 gateway 安裝,將其放在 ~/.openclaw/.env 中。

其運作原理

與傳統搜尋提供者不同,後者返回連結和摘錄清單,Gemini 使用 Google Search 接地產生具有內嵌引用的 AI 合成答案。結果包含合成答案和來源 URL。
  • 來自 Gemini 接地的引用 URL 會自動從 Google 重新導向 URL 解析為直接 URL。
  • 重新導向解析使用 SSRF 防護路徑(HEAD + 重新導向檢查 + http/https 驗證)後才返回最終引用 URL。
  • 重新導向解析使用嚴格的 SSRF 預設值,所以重新導向到私人/內部目標會被封鎖。

支援的參數

Gemini 搜尋支援標準的 querycount 參數。不支援提供者特定篩選器如 countrylanguagefreshnessdomain_filter

模型選擇

預設模型是 gemini-2.5-flash(快速且具成本效益)。任何支援接地的 Gemini 模型都可透過 plugins.entries.google.config.webSearch.model 使用。

相關