Skip to content

Repository files navigation

opencode-bocha

opencode plugin that provides a BochaWebSearch tool powered by 博查 (Bocha) search engine.

Installation

npm install opencode-bocha

Then add it to your opencode.json:

{
"plugin": ["opencode-bocha"]
}

Configuration

API Key

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

BochaWebSearch Tool

Once loaded, opencode's AI will automatically use the BochaWebSearch tool when it needs to search the web.

Parameters

ParameterTypeRequiredDefaultDescription
querystringyesSearch query
countnumberno10Number of results (1–50)
freshnessstringnonoLimitTime range: noLimit, oneDay, oneWeek, oneMonth, oneYear, or custom YYYY-MM-DD..YYYY-MM-DD
summarybooleannofalseInclude detailed long-text summary per result
includestringnoOnly include results from these sites. Pipe or comma separated, max 20 domains
excludestringnoExclude results from these sites. Pipe or comma separated, max 20 domains

Example

BochaWebSearch(query="2024年人工智能发展趋势", count=5, freshness="oneYear", summary=true)

Development

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"]
}

License

MIT

About

opencode plugin that provides a BochaWebSearch tool powered by 博查 (Bocha) search engine.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages