opencode plugin that provides a BochaWebSearch tool powered by 博查 (Bocha) search engine.
npm install opencode-bocha
Then add it to your opencode.json:
{
"plugin": ["opencode-bocha"]
}Get your API key at open.bochaai.com → API KEY 管理。
Option 1 — Environment variable (recommended):
export BOCHA_API_KEY="sk-your-key-here"
PowerShell:
$env:BOCHA_API_KEY = "sk-your-key-here"
Option 2 — opencode auth:
opencode auth login other # Provider name: bocha # Paste your API key when prompted
Once loaded, opencode's AI will automatically use the BochaWebSearch tool when it needs to search the web.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query |
string | yes | — | Search query |
count |
number | no | 10 |
Number of results (1–50) |
freshness |
string | no | noLimit |
Time range: noLimit, oneDay, oneWeek, oneMonth, oneYear, or custom YYYY-MM-DD..YYYY-MM-DD |
summary |
boolean | no | false |
Include detailed long-text summary per result |
include |
string | no | — | Only include results from these sites. Pipe or comma separated, max 20 domains |
exclude |
string | no | — | Exclude results from these sites. Pipe or comma separated, max 20 domains |
BochaWebSearch(query="2024年人工智能发展趋势", count=5, freshness="oneYear", summary=true)
npm install npm run build # compile to dist/ npm run dev # watch mode
To test locally, reference the compiled output in your config:
{
"plugin": ["./path/to/opencode-bocha/dist/index.js"]
}MIT