web_search: add searxng provider
This commit is contained in:
1 parent
613724c26e
commit
8d4270bcd6
12 files changed
+453
-40
No files matched your search
@@ -1942,8 +1942,16 @@ of `every`, keep `HEARTBEAT.md` tiny, and/or choose a cheaper `model`.
|
||||
Note: `applyPatch` is only under `tools.exec`.
|
||||
|
||||
`tools.web` configures web search + fetch tools:
|
||||
- `tools.web.search.enabled` (default: true when key is present)
|
||||
- `tools.web.search.apiKey` (recommended: set via `openclaw configure --section web`, or use `BRAVE_API_KEY` env var)
|
||||
- `tools.web.search.enabled` (default true)
|
||||
- `tools.web.search.provider` (`brave` | `perplexity` | `searxng`)
|
||||
- `tools.web.search.apiKey` (Brave; recommended: set via `openclaw configure --section web`, or use `BRAVE_API_KEY` env var)
|
||||
- `tools.web.search.perplexity.apiKey` (Perplexity/OpenRouter; optional if `PERPLEXITY_API_KEY` or `OPENROUTER_API_KEY` is set)
|
||||
- `tools.web.search.perplexity.baseUrl` (optional override)
|
||||
- `tools.web.search.perplexity.model` (optional override)
|
||||
- `tools.web.search.searxng.baseUrl` (SearXNG; optional if `SEARXNG_BASE_URL` is set)
|
||||
- `tools.web.search.searxng.apiKey` (optional auth token; sent as Authorization header)
|
||||
- `tools.web.search.searxng.headers` (optional extra headers)
|
||||
- `tools.web.search.searxng.params` (optional default query params)
|
||||
- `tools.web.search.maxResults` (1–10, default 5)
|
||||
- `tools.web.search.timeoutSeconds` (default 30)
|
||||
- `tools.web.search.cacheTtlMinutes` (default 15)
|
||||
|
||||
+8
-4
@@ -1319,10 +1319,13 @@ The Gateway watches the config and supports hot‑reload:
|
||||
|
||||
### How do I enable web search and web fetch
|
||||
|
||||
`web_fetch` works without an API key. `web_search` requires a Brave Search API
|
||||
key. **Recommended:** run `openclaw configure --section web` to store it in
|
||||
`tools.web.search.apiKey`. Environment alternative: set `BRAVE_API_KEY` for the
|
||||
Gateway process.
|
||||
`web_fetch` works without an API key. `web_search` requires provider setup:
|
||||
|
||||
- Brave: `tools.web.search.apiKey` or `BRAVE_API_KEY`
|
||||
- Perplexity: `tools.web.search.perplexity.apiKey` or `PERPLEXITY_API_KEY` / `OPENROUTER_API_KEY`
|
||||
- SearXNG: `tools.web.search.searxng.baseUrl` or `SEARXNG_BASE_URL`
|
||||
|
||||
**Recommended:** run `openclaw configure --section web` to set these in config.
|
||||
|
||||
```json5
|
||||
{
|
||||
@@ -1330,6 +1333,7 @@ Gateway process.
|
||||
web: {
|
||||
search: {
|
||||
enabled: true,
|
||||
provider: "brave",
|
||||
apiKey: "BRAVE_API_KEY_HERE",
|
||||
maxResults: 5
|
||||
},
|
||||
|
||||
@@ -62,11 +62,12 @@ You can keep it local with `memorySearch.provider = "local"` (no API usage).
|
||||
|
||||
See [Memory](/concepts/memory).
|
||||
|
||||
### 4) Web search tool (Brave / Perplexity via OpenRouter)
|
||||
### 4) Web search tool (Brave / Perplexity / SearXNG)
|
||||
`web_search` uses API keys and may incur usage charges:
|
||||
|
||||
- **Brave Search API**: `BRAVE_API_KEY` or `tools.web.search.apiKey`
|
||||
- **Perplexity** (via OpenRouter): `PERPLEXITY_API_KEY` or `OPENROUTER_API_KEY`
|
||||
- **SearXNG** (self-hosted): `tools.web.search.searxng.baseUrl` or `SEARXNG_BASE_URL` (no external API billing; depends on your instance)
|
||||
|
||||
**Brave free tier (generous):**
|
||||
- **2,000 requests/month**
|
||||
|
||||
@@ -44,9 +44,8 @@ run on host, set an explicit per-agent override:
|
||||
|
||||
- Node `>=22`
|
||||
- `pnpm` (optional; recommended if you build from source)
|
||||
- **Recommended:** Brave Search API key for web search. Easiest path:
|
||||
`openclaw configure --section web` (stores `tools.web.search.apiKey`).
|
||||
See [Web tools](/tools/web).
|
||||
- **Recommended:** configure a `web_search` provider (Brave, Perplexity, or SearXNG) for web search.
|
||||
Easiest path: `openclaw configure --section web`. See [Web tools](/tools/web).
|
||||
|
||||
macOS: if you plan to build the apps, install Xcode / CLT. For the CLI + gateway only, Node is enough.
|
||||
Windows: use **WSL2** (Ubuntu recommended). WSL2 is strongly recommended; native Windows is untested, more problematic, and has poorer tool compatibility. Install WSL2 first, then run the Linux steps inside WSL. See [Windows (WSL2)](/platforms/windows).
|
||||
|
||||
@@ -27,9 +27,9 @@ Follow‑up reconfiguration:
|
||||
openclaw configure
|
||||
```
|
||||
|
||||
Recommended: set up a Brave Search API key so the agent can use `web_search`
|
||||
(`web_fetch` works without a key). Easiest path: `openclaw configure --section web`
|
||||
which stores `tools.web.search.apiKey`. Docs: [Web tools](/tools/web).
|
||||
Recommended: set up a `web_search` provider (Brave, Perplexity, or SearXNG) so the
|
||||
agent can search the web when needed (`web_fetch` works without a key). Easiest
|
||||
path: `openclaw configure --section web`. Docs: [Web tools](/tools/web).
|
||||
|
||||
## QuickStart vs Advanced
|
||||
|
||||
|
||||
+2
-2
@@ -205,14 +205,14 @@ Notes:
|
||||
- `process` is scoped per agent; sessions from other agents are not visible.
|
||||
|
||||
### `web_search`
|
||||
Search the web using Brave Search API.
|
||||
Search the web using your configured provider (Brave, Perplexity, or SearXNG).
|
||||
|
||||
Core parameters:
|
||||
- `query` (required)
|
||||
- `count` (1–10; default from `tools.web.search.maxResults`)
|
||||
|
||||
Notes:
|
||||
- Requires a Brave API key (recommended: `openclaw configure --section web`, or set `BRAVE_API_KEY`).
|
||||
- Requires provider setup (recommended: `openclaw configure --section web`).
|
||||
- Enable via `tools.web.search.enabled`.
|
||||
- Responses are cached (default 15 min).
|
||||
- See [Web tools](/tools/web) for setup.
|
||||
|
||||
+42
-4
@@ -1,16 +1,17 @@
|
||||
---
|
||||
summary: "Web search + fetch tools (Brave Search API, Perplexity direct/OpenRouter)"
|
||||
summary: "Web search + fetch tools (Brave Search API, Perplexity direct/OpenRouter, SearXNG)"
|
||||
read_when:
|
||||
- You want to enable web_search or web_fetch
|
||||
- You need Brave Search API key setup
|
||||
- You want to use Perplexity Sonar for web search
|
||||
- You want to use SearXNG for web search
|
||||
---
|
||||
|
||||
# Web tools
|
||||
|
||||
OpenClaw ships two lightweight web tools:
|
||||
|
||||
- `web_search` — Search the web via Brave Search API (default) or Perplexity Sonar (direct or via OpenRouter).
|
||||
- `web_search` — Search the web via Brave Search API (default), Perplexity Sonar (direct or via OpenRouter), or a self-hosted SearXNG instance.
|
||||
- `web_fetch` — HTTP fetch + readable extraction (HTML → markdown/text).
|
||||
|
||||
These are **not** browser automation. For JS-heavy sites or logins, use the
|
||||
@@ -21,6 +22,7 @@ These are **not** browser automation. For JS-heavy sites or logins, use the
|
||||
- `web_search` calls your configured provider and returns results.
|
||||
- **Brave** (default): returns structured results (title, URL, snippet).
|
||||
- **Perplexity**: returns AI-synthesized answers with citations from real-time web search.
|
||||
- **SearXNG**: returns structured results (title, URL, snippet) from your own meta-search instance.
|
||||
- Results are cached by query for 15 minutes (configurable).
|
||||
- `web_fetch` does a plain HTTP GET and extracts readable content
|
||||
(HTML → markdown/text). It does **not** execute JavaScript.
|
||||
@@ -32,6 +34,7 @@ These are **not** browser automation. For JS-heavy sites or logins, use the
|
||||
|----------|------|------|---------|
|
||||
| **Brave** (default) | Fast, structured results, free tier | Traditional search results | `BRAVE_API_KEY` |
|
||||
| **Perplexity** | AI-synthesized answers, citations, real-time | Requires Perplexity or OpenRouter access | `OPENROUTER_API_KEY` or `PERPLEXITY_API_KEY` |
|
||||
| **SearXNG** | Self-hosted, works in private environments, flexible | Requires running SearXNG and enabling JSON format | None (needs base URL) |
|
||||
|
||||
See [Brave Search setup](/brave-search) and [Perplexity Sonar](/perplexity) for provider-specific details.
|
||||
|
||||
@@ -42,7 +45,7 @@ Set the provider in config:
|
||||
tools: {
|
||||
web: {
|
||||
search: {
|
||||
provider: "brave" // or "perplexity"
|
||||
provider: "brave" // or "perplexity" or "searxng"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +71,34 @@ Example: switch to Perplexity Sonar (direct API):
|
||||
}
|
||||
```
|
||||
|
||||
## Using SearXNG
|
||||
|
||||
SearXNG exposes a simple HTTP API at `/search`. To get JSON results you need
|
||||
`format=json` enabled on your instance; some public instances disable it and will
|
||||
return `403 Forbidden`.
|
||||
|
||||
Example config:
|
||||
|
||||
```json5
|
||||
{
|
||||
tools: {
|
||||
web: {
|
||||
search: {
|
||||
enabled: true,
|
||||
provider: "searxng",
|
||||
searxng: {
|
||||
baseUrl: "http://localhost:8080",
|
||||
// Optional extra query params merged into each request:
|
||||
// params: { categories: "general", safesearch: 1 }
|
||||
// Optional auth via headers (for reverse-proxy auth):
|
||||
// headers: { "X-Api-Key": "..." }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Getting a Brave API key
|
||||
|
||||
1) Create a Brave Search API account at https://brave.com/search/api/
|
||||
@@ -145,9 +176,10 @@ Search the web using your configured provider.
|
||||
### Requirements
|
||||
|
||||
- `tools.web.search.enabled` must not be `false` (default: enabled)
|
||||
- API key for your chosen provider:
|
||||
- Provider setup:
|
||||
- **Brave**: `BRAVE_API_KEY` or `tools.web.search.apiKey`
|
||||
- **Perplexity**: `OPENROUTER_API_KEY`, `PERPLEXITY_API_KEY`, or `tools.web.search.perplexity.apiKey`
|
||||
- **SearXNG**: `tools.web.search.searxng.baseUrl` or `SEARXNG_BASE_URL`
|
||||
|
||||
### Config
|
||||
|
||||
@@ -175,6 +207,12 @@ Search the web using your configured provider.
|
||||
- `search_lang` (optional): ISO language code for search results (e.g., "de", "en", "fr")
|
||||
- `ui_lang` (optional): ISO language code for UI elements
|
||||
- `freshness` (optional, Brave only): filter by discovery time (`pd`, `pw`, `pm`, `py`, or `YYYY-MM-DDtoYYYY-MM-DD`)
|
||||
- `categories` (optional, SearXNG only): comma-separated categories
|
||||
- `engines` (optional, SearXNG only): comma-separated engines
|
||||
- `language` (optional, SearXNG only): language code (if omitted, falls back to `search_lang`)
|
||||
- `time_range` (optional, SearXNG only): `day`, `month`, `year`
|
||||
- `safesearch` (optional, SearXNG only): `0`, `1`, `2`
|
||||
- `pageno` (optional, SearXNG only): page number (default `1`)
|
||||
|
||||
**Examples:**
|
||||
|
||||
|
||||
Reference in new issue
Block a user