2026-01-15 04:07:29 +00:00
---
2026-03-27 12:41:02 -04:00
title: "Web Search"
sidebarTitle: "Web Search"
summary: "web_search, x_search, and web_fetch -- search the web, search X posts, or fetch page content"
2026-01-15 04:07:29 +00:00
read_when:
2026-03-22 15:00:56 -07:00
- You want to enable or configure web_search
2026-03-27 12:41:02 -04:00
- You want to enable or configure x_search
2026-03-22 15:00:56 -07:00
- You need to choose a search provider
- You want to understand auto-detection and provider fallback
2026-01-15 04:07:29 +00:00
---
2026-03-22 15:00:56 -07:00
# Web Search
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
The `web_search` tool searches the web using your configured provider and
returns results. Results are cached by query for 15 minutes (configurable).
2026-01-15 04:07:29 +00:00
2026-03-27 12:41:02 -04:00
OpenClaw also includes `x_search` for X (formerly Twitter) posts and
`web_fetch` for lightweight URL fetching. In this phase, `web_fetch` stays
local while `web_search` and `x_search` can use xAI Responses under the hood.
2026-03-22 15:00:56 -07:00
<Info>
`web_search` is a lightweight HTTP tool, not browser automation. For
JS-heavy sites or logins, use the [Web Browser ](/tools/browser ). For
fetching a specific URL, use [Web Fetch ](/tools/web-fetch ).
</Info>
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
## Quick start
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
<Steps>
2026-04-03 13:41:24 -07:00
<Step title="Choose a provider">
Pick a provider and complete any required setup. Some providers are
key-free, while others use API keys. See the provider pages below for
details.
2026-03-22 15:00:56 -07:00
</Step>
<Step title="Configure">
```bash
openclaw configure --section web
` ``
2026-04-03 13:41:24 -07:00
This stores the provider and any needed credential. You can also set an env
var (for example ` BRAVE_API_KEY`) and skip this step for API-backed
providers.
2026-03-22 15:00:56 -07:00
</Step>
<Step title="Use it">
The agent can now call ` web_search`:
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
` ``javascript
await web_search({ query: "OpenClaw plugin SDK" });
` ``
2026-01-15 04:07:29 +00:00
2026-03-27 12:41:02 -04:00
For X posts, use:
` ``javascript
await x_search({ query: "dinner recipes" });
` ``
2026-03-22 15:00:56 -07:00
</Step>
</Steps>
2026-01-18 08:08:36 +08:00
2026-03-22 15:00:56 -07:00
## Choosing a provider
2026-03-22 14:24:34 -07:00
<CardGroup cols={2}>
<Card title="Brave Search" icon="shield" href="/tools/brave-search">
2026-03-22 15:00:56 -07:00
Structured results with snippets. Supports ` llm-context` mode, country/language filters. Free tier available.
2026-03-22 14:24:34 -07:00
</Card>
2026-03-22 21:17:10 -07:00
<Card title="DuckDuckGo" icon="bird" href="/tools/duckduckgo-search">
Key-free fallback. No API key needed. Unofficial HTML-based integration.
</Card>
2026-03-22 21:27:21 -07:00
<Card title="Exa" icon="brain" href="/tools/exa-search">
Neural + keyword search with content extraction (highlights, text, summaries).
</Card>
2026-03-22 15:00:56 -07:00
<Card title="Firecrawl" icon="flame" href="/tools/firecrawl">
Structured results. Best paired with ` firecrawl_search` and ` firecrawl_scrape` for deep extraction.
2026-03-22 14:24:34 -07:00
</Card>
<Card title="Gemini" icon="sparkles" href="/tools/gemini-search">
2026-03-22 15:00:56 -07:00
AI-synthesized answers with citations via Google Search grounding.
2026-03-22 14:24:34 -07:00
</Card>
<Card title="Grok" icon="zap" href="/tools/grok-search">
2026-03-22 15:00:56 -07:00
AI-synthesized answers with citations via xAI web grounding.
2026-03-22 14:24:34 -07:00
</Card>
<Card title="Kimi" icon="moon" href="/tools/kimi-search">
2026-03-22 15:00:56 -07:00
AI-synthesized answers with citations via Moonshot web search.
2026-03-22 14:24:34 -07:00
</Card>
2026-03-25 18:41:35 -04:00
<Card title="MiniMax Search" icon="globe" href="/tools/minimax-search">
Structured results via the MiniMax Coding Plan search API.
</Card>
2026-04-03 13:41:24 -07:00
<Card title="Ollama Web Search" icon="globe" href="/tools/ollama-search">
Key-free search via your configured Ollama host. Requires ` ollama signin`.
</Card>
2026-03-22 14:24:34 -07:00
<Card title="Perplexity" icon="search" href="/tools/perplexity-search">
2026-03-22 15:00:56 -07:00
Structured results with content extraction controls and domain filtering.
2026-03-22 14:24:34 -07:00
</Card>
2026-04-01 19:18:03 +09:00
<Card title="SearXNG" icon="server" href="/tools/searxng-search">
Self-hosted meta-search. No API key needed. Aggregates Google, Bing, DuckDuckGo, and more.
</Card>
2026-03-22 14:24:34 -07:00
<Card title="Tavily" icon="globe" href="/tools/tavily">
2026-03-22 15:00:56 -07:00
Structured results with search depth, topic filtering, and ` tavily_extract` for URL extraction.
2026-03-22 14:24:34 -07:00
</Card>
</CardGroup>
2026-03-22 15:00:56 -07:00
### Provider comparison
2026-03-16 03:38:51 +00:00
2026-04-04 10:16:02 +01:00
| Provider | Result style | Filters | API key |
| ----------------------------------------- | -------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------- |
| [Brave](/tools/brave-search) | Structured snippets | Country, language, time, ` llm-context` mode | ` BRAVE_API_KEY` |
| [DuckDuckGo](/tools/duckduckgo-search) | Structured snippets | -- | None (key-free) |
| [Exa](/tools/exa-search) | Structured + extracted | Neural/keyword mode, date, content extraction | ` EXA_API_KEY` |
| [Firecrawl](/tools/firecrawl) | Structured snippets | Via ` firecrawl_search` tool | ` FIRECRAWL_API_KEY` |
| [Gemini](/tools/gemini-search) | AI-synthesized + citations | -- | ` GEMINI_API_KEY` |
| [Grok](/tools/grok-search) | AI-synthesized + citations | -- | ` XAI_API_KEY` |
| [Kimi](/tools/kimi-search) | AI-synthesized + citations | -- | ` KIMI_API_KEY` / ` MOONSHOT_API_KEY` |
2026-03-25 18:41:35 -04:00
| [MiniMax Search](/tools/minimax-search) | Structured snippets | Region (` global` / ` cn`) | ` MINIMAX_CODE_PLAN_KEY` / ` MINIMAX_CODING_API_KEY` |
2026-04-04 10:16:02 +01:00
| [Ollama Web Search](/tools/ollama-search) | Structured snippets | -- | None by default; ` ollama signin` required, can reuse Ollama provider bearer auth |
| [Perplexity](/tools/perplexity-search) | Structured snippets | Country, language, time, domains, content limits | ` PERPLEXITY_API_KEY` / ` OPENROUTER_API_KEY` |
| [SearXNG](/tools/searxng-search) | Structured snippets | Categories, language | None (self-hosted) |
| [Tavily](/tools/tavily) | Structured snippets | Via ` tavily_search` tool | ` TAVILY_API_KEY` |
2026-03-20 01:06:26 -04:00
2026-03-22 15:00:56 -07:00
## Auto-detection
2026-03-20 01:06:26 -04:00
2026-03-15 11:20:05 +01:00
## Native Codex web search
Codex-capable models can optionally use the provider-native Responses ` web_search` tool instead of OpenClaw's managed ` web_search` function.
- Configure it under ` tools.web.search.openaiCodex`
- It only activates for Codex-capable models (` openai-codex/*` or providers using ` api: "openai-codex-responses"`)
- Managed ` web_search` still applies to non-Codex models
- ` mode: "cached"` is the default and recommended setting
- ` tools.web.search.enabled: false` disables both managed and native search
` ``json5
{
tools: {
web: {
search: {
enabled: true,
openaiCodex: {
enabled: true,
mode: "cached",
allowedDomains: ["example.com"],
contextSize: "high",
userLocation: {
country: "US",
city: "New York",
timezone: "America/New_York",
},
},
},
},
},
}
` ``
If native Codex search is enabled but the current model is not Codex-capable, OpenClaw keeps the normal managed ` web_search` behavior.
## Setting up web search
2026-03-23 01:45:38 -07:00
Provider lists in docs and setup flows are alphabetical. Auto-detection keeps a
2026-04-04 10:16:02 +01:00
separate precedence order.
2026-03-23 01:45:38 -07:00
2026-04-03 13:41:24 -07:00
If no ` provider` is set, OpenClaw checks providers in this order and uses the
first one that is ready:
2026-03-20 01:06:26 -04:00
2026-04-04 10:16:02 +01:00
API-backed providers first:
2026-01-18 08:08:36 +08:00
2026-04-04 10:16:02 +01:00
1. **Brave** -- ` BRAVE_API_KEY` or ` plugins.entries.brave.config.webSearch.apiKey` (order 10)
2026-03-25 18:41:35 -04:00
2. **MiniMax Search** -- ` MINIMAX_CODE_PLAN_KEY` / ` MINIMAX_CODING_API_KEY` or ` plugins.entries.minimax.config.webSearch.apiKey` (order 15)
3. **Gemini** -- ` GEMINI_API_KEY` or ` plugins.entries.google.config.webSearch.apiKey` (order 20)
4. **Grok** -- ` XAI_API_KEY` or ` plugins.entries.xai.config.webSearch.apiKey` (order 30)
5. **Kimi** -- ` KIMI_API_KEY` / ` MOONSHOT_API_KEY` or ` plugins.entries.moonshot.config.webSearch.apiKey` (order 40)
6. **Perplexity** -- ` PERPLEXITY_API_KEY` / ` OPENROUTER_API_KEY` or ` plugins.entries.perplexity.config.webSearch.apiKey` (order 50)
7. **Firecrawl** -- ` FIRECRAWL_API_KEY` or ` plugins.entries.firecrawl.config.webSearch.apiKey` (order 60)
8. **Exa** -- ` EXA_API_KEY` or ` plugins.entries.exa.config.webSearch.apiKey` (order 65)
9. **Tavily** -- ` TAVILY_API_KEY` or ` plugins.entries.tavily.config.webSearch.apiKey` (order 70)
2026-04-01 19:18:03 +09:00
2026-04-04 10:16:02 +01:00
Key-free fallbacks after that:
2026-03-25 18:41:35 -04:00
10. **DuckDuckGo** -- key-free HTML fallback with no account or API key (order 100)
11. **Ollama Web Search** -- key-free fallback via your configured Ollama host; requires Ollama to be reachable and signed in with ` ollama signin` and can reuse Ollama provider bearer auth if the host needs it (order 110)
12. **SearXNG** -- ` SEARXNG_BASE_URL` or ` plugins.entries.searxng.config.webSearch.baseUrl` (order 200)
2026-04-01 19:18:03 +09:00
If no provider is detected, it falls back to Brave (you will get a missing-key
error prompting you to configure one).
2026-01-18 08:08:36 +08:00
2026-03-22 15:00:56 -07:00
<Note>
All provider key fields support SecretRef objects. In auto-detect mode,
OpenClaw resolves only the selected provider key -- non-selected SecretRefs
stay inactive.
</Note>
2026-03-08 14:10:26 +00:00
2026-03-22 15:00:56 -07:00
## Config
2026-03-08 13:54:50 +00:00
` ``json5
{
tools: {
web: {
search: {
2026-03-22 15:00:56 -07:00
enabled: true, // default: true
provider: "brave", // or omit for auto-detection
maxResults: 5,
timeoutSeconds: 30,
cacheTtlMinutes: 15,
2026-03-08 13:54:50 +00:00
},
},
},
}
` ``
2026-03-22 15:00:56 -07:00
Provider-specific config (API keys, base URLs, modes) lives under
` plugins.entries.<plugin>.config.webSearch.*`. See the provider pages for
examples.
2026-04-04 20:21:16 +01:00
` web_fetch` fallback provider selection is separate:
- choose it with ` tools.web.fetch.provider`
- or omit that field and let OpenClaw auto-detect the first ready web-fetch
provider from available credentials
- today the bundled web-fetch provider is Firecrawl, configured under
` plugins.entries.firecrawl.config.webFetch.*`
2026-04-04 09:14:51 +01:00
When you choose **Kimi** during ` openclaw onboard` or
` openclaw configure --section web`, OpenClaw can also ask for:
- the Moonshot API region (` https://api.moonshot.ai/v1` or ` https://api.moonshot.cn/v1`)
- the default Kimi web-search model (defaults to ` kimi-k2.5`)
2026-04-02 22:51:20 +09:00
For ` x_search`, configure ` plugins.entries.xai.config.xSearch.*`. It uses the
same ` XAI_API_KEY` fallback as Grok web search.
Legacy ` tools.web.x_search.*` config is auto-migrated by ` openclaw doctor --fix`.
2026-03-29 00:12:15 +00:00
When you choose Grok during ` openclaw onboard` or ` openclaw configure --section web`,
OpenClaw can also offer optional ` x_search` setup with the same key.
2026-03-29 00:24:48 +00:00
This is a separate follow-up step inside the Grok path, not a separate top-level
web-search provider choice. If you pick another provider, OpenClaw does not
show the ` x_search` prompt.
2026-03-27 12:41:02 -04:00
2026-03-22 15:00:56 -07:00
### Storing API keys
<Tabs>
<Tab title="Config file">
Run ` openclaw configure --section web` or set the key directly:
` ``json5
{
plugins: {
entries: {
brave: {
config: {
webSearch: {
apiKey: "YOUR_KEY", // pragma: allowlist secret
},
},
2026-03-17 23:59:17 -05:00
},
},
},
2026-03-22 15:00:56 -07:00
}
` ``
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
</Tab>
<Tab title="Environment variable">
Set the provider env var in the Gateway process environment:
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
` ``bash
export BRAVE_API_KEY="YOUR_KEY"
` ``
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
For a gateway install, put it in ` ~/.openclaw/.env`.
2026-03-22 15:28:27 -07:00
See [Env vars](/help/faq#env-vars-and-env-loading).
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
</Tab>
</Tabs>
2026-03-08 20:37:54 +05:30
2026-03-22 15:00:56 -07:00
## Tool parameters
2026-03-04 04:57:19 +00:00
| Parameter | Description |
| --------------------- | ----------------------------------------------------- |
| ` query` | Search query (required) |
| ` count` | Results to return (1-10, default: 5) |
2026-03-22 15:00:56 -07:00
| ` country` | 2-letter ISO country code (e.g. "US", "DE") |
| ` language` | ISO 639-1 language code (e.g. "en", "de") |
2026-04-04 09:18:58 +01:00
| ` search_lang` | Search-language code (Brave only) |
2026-03-04 04:57:19 +00:00
| ` freshness` | Time filter: ` day`, ` week`, ` month`, or ` year` |
| ` date_after` | Results after this date (YYYY-MM-DD) |
| ` date_before` | Results before this date (YYYY-MM-DD) |
| ` ui_lang` | UI language code (Brave only) |
| ` domain_filter` | Domain allowlist/denylist array (Perplexity only) |
| ` max_tokens` | Total content budget, default 25000 (Perplexity only) |
| ` max_tokens_per_page` | Per-page token limit, default 2048 (Perplexity only) |
2026-01-16 23:48:40 +01:00
2026-03-22 15:00:56 -07:00
<Warning>
Not all parameters work with all providers. Brave ` llm-context` mode
rejects ` ui_lang`, ` freshness`, ` date_after`, and ` date_before`.
2026-04-04 09:17:40 +01:00
Gemini, Grok, and Kimi return one synthesized answer with citations. They
accept ` count` for shared-tool compatibility, but it does not change the
grounded answer shape.
2026-04-04 09:20:37 +01:00
Perplexity behaves the same way when you use the Sonar/OpenRouter
compatibility path (` plugins.entries.perplexity.config.webSearch.baseUrl` /
` model` or ` OPENROUTER_API_KEY`).
2026-04-04 09:22:23 +01:00
SearXNG accepts ` http://` only for trusted private-network or loopback hosts;
public SearXNG endpoints must use ` https://`.
2026-03-22 15:00:56 -07:00
Firecrawl and Tavily only support ` query` and ` count` through ` web_search`
-- use their dedicated tools for advanced options.
</Warning>
2026-03-20 01:06:26 -04:00
2026-03-27 12:41:02 -04:00
## x_search
` x_search` queries X (formerly Twitter) posts using xAI and returns
AI-synthesized answers with citations. It accepts natural-language queries and
optional structured filters. OpenClaw only enables the built-in xAI ` x_search`
tool on the request that serves this tool call.
2026-03-28 11:01:19 -04:00
<Note>
xAI documents ` x_search` as supporting keyword search, semantic search, user
search, and thread fetch. For per-post engagement stats such as reposts,
replies, bookmarks, or views, prefer a targeted lookup for the exact post URL
or status ID. Broad keyword searches may find the right post but return less
complete per-post metadata. A good pattern is: locate the post first, then
run a second ` x_search` query focused on that exact post.
</Note>
2026-03-27 12:41:02 -04:00
### x_search config
` ``json5
{
2026-04-02 22:51:20 +09:00
plugins: {
entries: {
xai: {
config: {
xSearch: {
enabled: true,
model: "grok-4-1-fast-non-reasoning",
inlineCitations: false,
maxTurns: 2,
timeoutSeconds: 30,
cacheTtlMinutes: 15,
},
webSearch: {
apiKey: "xai-...", // optional if XAI_API_KEY is set
},
},
2026-03-27 12:41:02 -04:00
},
},
},
}
` ``
### x_search parameters
| Parameter | Description |
| ---------------------------- | ------------------------------------------------------ |
| ` query` | Search query (required) |
| ` allowed_x_handles` | Restrict results to specific X handles |
| ` excluded_x_handles` | Exclude specific X handles |
| ` from_date` | Only include posts on or after this date (YYYY-MM-DD) |
| ` to_date` | Only include posts on or before this date (YYYY-MM-DD) |
| ` enable_image_understanding` | Let xAI inspect images attached to matching posts |
| ` enable_video_understanding` | Let xAI inspect videos attached to matching posts |
### x_search example
` ``javascript
await x_search({
query: "dinner recipes",
allowed_x_handles: ["nytfood"],
from_date: "2026-03-01",
});
` ``
2026-03-28 11:01:19 -04:00
` ``javascript
// Per-post stats: use the exact status URL or status ID when possible
await x_search({
query: "https://x.com/huntharo/status/1905678901234567890",
});
` ``
2026-03-22 15:00:56 -07:00
## Examples
2026-01-16 23:48:40 +01:00
` ``javascript
2026-03-22 15:00:56 -07:00
// Basic search
await web_search({ query: "OpenClaw plugin SDK" });
2026-01-16 23:48:40 +01:00
// German-specific search
2026-03-22 15:00:56 -07:00
await web_search({ query: "TV online schauen", country: "DE", language: "de" });
2026-01-16 23:48:40 +01:00
2026-03-04 04:57:19 +00:00
// Recent results (past week)
2026-03-22 15:00:56 -07:00
await web_search({ query: "AI developments", freshness: "week" });
2026-01-25 04:17:42 +00:00
2026-03-22 15:00:56 -07:00
// Date range
2026-01-25 04:17:42 +00:00
await web_search({
2026-03-22 15:00:56 -07:00
query: "climate research",
2026-03-04 04:57:19 +00:00
date_after: "2024-01-01",
date_before: "2024-06-30",
});
// Domain filtering (Perplexity only)
await web_search({
query: "product reviews",
domain_filter: ["-reddit.com", "-pinterest.com"],
});
2026-01-16 23:48:40 +01:00
` ``
2026-01-15 04:07:29 +00:00
2026-03-22 15:00:56 -07:00
## Tool profiles
2026-01-15 04:07:29 +00:00
2026-03-27 12:41:02 -04:00
If you use tool profiles or allowlists, add ` web_search`, ` x_search`, or ` group:web`:
2026-01-15 04:07:29 +00:00
` ``json5
{
tools: {
2026-03-27 12:41:02 -04:00
allow: ["web_search", "x_search"],
// or: allow: ["group:web"] (includes web_search, x_search, and web_fetch)
2026-01-31 21:13:13 +09:00
},
2026-01-15 04:07:29 +00:00
}
` ``
2026-03-22 15:00:56 -07:00
## Related
- [Web Fetch](/tools/web-fetch) -- fetch a URL and extract readable content
- [Web Browser](/tools/browser) -- full browser automation for JS-heavy sites
2026-03-27 12:41:02 -04:00
- [Grok Search](/tools/grok-search) -- Grok as the ` web_search` provider
2026-04-03 13:41:24 -07:00
- [Ollama Web Search ](/tools/ollama-search ) -- key-free web search through your Ollama host