@steimerbyte/pi-bsearch
Brave Search API (LLM Context + Web) as pi tool extension. Wraps @steimerbyte/bsearch-cli with smart settings.json API key handling.
Package details
Install @steimerbyte/pi-bsearch from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@steimerbyte/pi-bsearch- Package
@steimerbyte/pi-bsearch- Version
0.2.0- Published
- Jul 28, 2026
- Downloads
- 147/mo · 147/wk
- Author
- steimerbyte
- License
- MIT
- Types
- extension
- Size
- 24.1 KB
- Dependencies
- 1 dependency · 3 peers
Pi manifest JSON
{
"extensions": [
"./extensions/bsearch.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-bsearch
Brave Search API as a pi tool extension. Wraps
@steimerbyte/bsearch-cli and exposes
two modes to the LLM:
mode="llm"(default) — pre-extracted LLM Context from Brave, optimized for AI/RAG pipelines.mode="web"— classic web search with links + descriptions.
Install
pi install npm:@steimerbyte/pi-bsearch
@steimerbyte/bsearch-cli is declared as a dependency, so the bsearch CLI is
fetched and installed alongside the extension automatically.
Configuration
Add a bsearch block to ~/.pi/agent/settings.json:
{
"bsearch": {
"apiKey": "BSA...",
"defaultMode": "llm",
"defaultMaxUrls": 20
}
}
The API key is resolved in this order at every tool call:
settings.json → bsearch.apiKey(user-curated, wins)process.env.BRAVE_API_KEY~/.bsearch-env(bsearch-cli's own env file — read for consistency)- Interactive prompt (persisted back to settings.json)
Get a key at https://api.search.brave.com/app/keys.
⚠️ bsearch-cli reads
~/.bsearch-envbeforeprocess.env. If both paths exist, the env-file wins inside bsearch. To use a settings.json key, either remove~/.bsearch-envor mirror the key there.
Tool
The extension registers a single bsearch tool. Schema:
| Parameter | Type | Description |
|---|---|---|
query |
string (required) | Search query |
mode |
"llm" | "web" |
Search mode (default: llm) |
count |
int 1–50 | Number of web results |
freshness |
"pd" | "pw" | "pm" | "py" |
Freshness filter |
max_tokens |
int 1024–32768 | Max tokens in LLM context |
max_urls |
int 1–50 | Max URLs in response |
threshold |
"strict" | "balanced" | "lenient" | "disabled" |
Relevance threshold |
safesearch |
"off" | "moderate" | "strict" |
SafeSearch (web mode) |
country |
2-letter code | Country code |
city |
string | City name |
local |
boolean | Force local/POI recall |
compact |
boolean | Compact output |
timeout |
int 1000–120000 | Request timeout in ms |
Output is truncated to 50 KB / 2000 lines (whichever comes first). When truncated, the full output is saved to a temp file and the path is appended to the result.
Slash command
/bsearch Show current settings
/bsearch reload Re-read settings.json from disk
/bsearch clear-key Remove bsearch.apiKey from settings.json
Development
# Run with a local check-out
pi -e ./extensions/bsearch.ts
# Or install from a local path
pi install ./pi-bsearch
License
MIT