← 返回
未分类

brave-shim

Set up brave_shim as a free local proxy for OpenClaw web_search, routing Brave API requests to DuckDuckGo. Use when user asks to enable free web search, conf...
Set up brave_shim as a free local proxy for OpenClaw web_search, routing Brave API requests to DuckDuckGo. Use when user asks to enable free web search, conf...
weare20202020 weare20202020 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 297
下载
💾 0
安装
1
版本
#latest

概述

brave-shim

Local proxy that makes OpenClaw's Brave Search provider route to DuckDuckGo for free,

without any API key.

How it works

  1. A Python FastAPI service (brave_shim) runs locally on http://127.0.0.1:8000
  2. It implements the Brave Search API format but fetches results from DuckDuckGo via ddgs
  3. OpenClaw's built-in Brave provider is redirected to this local service

Setup

1. Install brave_shim

# Clone the repo
git clone https://github.com/asoraruf/brave_shim <clone-path>

# Create venv and install dependencies
python -m venv <clone-path>/venv
# Windows:
<clone-path>\venv\Scripts\activate
pip install fastapi uvicorn ddgs pyyaml
# Linux/Mac:
source <clone-path>/venv/bin/activate
pip install fastapi uvicorn ddgs pyyaml

2. Patch OpenClaw Brave provider URL

The Brave provider in OpenClaw's bundled JS calls https://api.search.brave.com. Replace it with http://127.0.0.1:8000:

import subprocess, re, os

dist_dir = r"<openclaw-dist>"
pattern = r'(const BRAVE_SEARCH_ENDPOINT|const BRAVE_LLM_CONTEXT_ENDPOINT) = "[^"]+"'
replacement = {
    "const BRAVE_SEARCH_ENDPOINT": 'const BRAVE_SEARCH_ENDPOINT = "http://127.0.0.1:8000/res/v1/web/search"',
    "const BRAVE_LLM_CONTEXT_ENDPOINT": 'const BRAVE_LLM_CONTEXT_ENDPOINT = "http://127.0.0.1:8000/res/v1/llm/context"',
}

for fname in os.listdir(dist_dir):
    if fname.startswith("brave-web-search-provider") and fname.endswith(".js"):
        fpath = os.path.join(dist_dir, fname)
        content = open(fpath).read()
        new_content = re.sub(pattern, lambda m: replacement.get(m.group(1), m.group(0)), content)
        open(fpath, "w").write(new_content)

3. Configure OpenClaw

# Enable brave plugin (disabled by default)
openclaw config set plugins.entries.brave.enabled true

# Set Brave as search provider
openclaw config set tools.web.search.provider brave

# Restart gateway
openclaw gateway restart

4. Start shim service

# From brave_shim directory
.\venv\Scripts\python brave_shim.py
# Keep running in background

5. Verify

curl "http://127.0.0.1:8000/res/v1/web/search?q=hello+world"
# Should return JSON with web results

openclaw
# Then test: web_search { query: "test" }

Scripts

  • scripts/setup_brave_shim.py — Automated install: clone, venv, pip install
  • scripts/patch_openclaw.py — Patch OpenClaw dist JS files to redirect Brave API
  • scripts/start_shim.py — Start brave_shim service

Troubleshooting

"fetch failed" after setup:

  • Check shim is running: Invoke-WebRequest http://127.0.0.1:8000/res/v1/web/search?q=test
  • If shim is DOWN: re-run python brave_shim.py
  • If NO_PROXY blocks localhost: remove from env or set NO_PROXY=localhost,127.0.0.1

"missing_brave_api_key" error:

  • plugins.entries.brave needs enabled: true — run openclaw config set plugins.entries.brave.enabled true

"missing_gemini_api_key" instead:

  • Brave plugin still not enabled — check openclaw doctor for disabled plugin warnings

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 20:33 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,378 📥 320,405
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 676 📥 325,408
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,081 📥 809,876