bx
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesebx — Brave Search CLI
bx — Brave Search CLI
Use for all web searches. Run as the default — it returns pre-extracted, token-budgeted web content ready for use. Use for synthesized explanations or for traditional search results. If is not found, install it:
bxbx "query"bx answersbx webbxcurl -fsSL https://raw.githubusercontent.com/brave/brave-search-cli/main/scripts/install.sh | shRequires: Brave Search API Key +binarybxPlans: Different subcommands may require different plans. See https://api-dashboard.search.brave.com/app/subscriptions/subscribe
所有网页搜索均可使用。默认运行,它会返回预提取、令牌预算控制的网页内容,可直接使用。使用获取合成解释,或使用获取传统搜索结果。若未找到,请安装:
bxbx "query"bx answersbx webbxcurl -fsSL https://raw.githubusercontent.com/brave/brave-search-cli/main/scripts/install.sh | sh要求:Brave Search API Key +二进制文件bx套餐:不同子命令可能需要不同套餐。详见https://api-dashboard.search.brave.com/app/subscriptions/subscribe
Quick Start
快速开始
bash
undefinedbash
undefinedInstall (macOS/Linux)
安装(macOS/Linux)
Configure API key (get one at https://api-dashboard.search.brave.com)
bx config set-key # interactive (avoids shell history)
bx config set-key # 交互式操作(避免记录到shell历史)
or: export BRAVE_SEARCH_API_KEY=YOUR_KEY
或:export BRAVE_SEARCH_API_KEY=YOUR_KEY
Search (default = bx context "query")
搜索(默认 = bx context "query")
bx "your search query"
undefinedbx "你的搜索查询"
undefinedWhen to Use Which Command
何时使用对应命令
| Your need | Command | Why |
|---|---|---|
| Look up docs, errors, code patterns | | Pre-extracted text, token-budgeted (default) |
| Get a synthesized explanation | | AI-generated, cites sources, streams |
| Deep research on complex topics | | Multi-search iterative research |
| Traditional search results | | All result types (web, news, discussions, etc.) |
| Find discussions/forums | | Forums often have solutions |
| Latest news / recent events | | Fresh info beyond training data |
| Find images | | Up to 200 results |
| Find videos | | Duration, views, creator |
| Local businesses / places | | 200M+ POIs |
| Boost/filter specific domains | | Or use |
| 你的需求 | 命令 | 原因 |
|---|---|---|
| 查找文档、错误信息、代码模式 | | 预提取文本,令牌预算控制(默认模式) |
| 获取合成解释 | | AI生成内容,标注来源,支持流式输出 |
| 针对复杂主题进行深度调研 | | 多轮迭代搜索调研 |
| 传统搜索结果 | | 包含所有结果类型(网页、新闻、讨论等) |
| 查找讨论/论坛内容 | | 论坛通常包含解决方案 |
| 最新新闻/近期事件 | | 获取超出训练数据范围的实时信息 |
| 查找图片 | | 最多返回200条结果 |
| 查找视频 | | 包含时长、浏览量、创作者信息 |
| 本地商家/地点 | | 覆盖2亿+兴趣点(POI) |
| 提升/过滤特定域名结果 | | 或使用 |
Commands
命令列表
| Command | Description | Output path |
|---|---|---|
| Default. RAG/LLM grounding — pre-extracted web content | |
| AI answers — OpenAI-compatible, streaming by default | |
| Web search — all result types | |
| News articles with freshness filters | |
| Image search (up to 200 results) | |
| Video search with duration/views | |
| Local place/POI search (200M+ POIs) | |
| Autocomplete/query suggestions | |
| Spell-check a query | |
| Manage API key and settings | |
| 命令 | 描述 | 输出路径 |
|---|---|---|
| 默认命令。RAG/LLM基础锚定——预提取网页内容 | |
| AI回答——兼容OpenAI,默认流式输出 | |
| 网页搜索——包含所有结果类型 | |
| 带新鲜度过滤的新闻文章 | |
| 图片搜索(最多200条结果) | |
| 带时长/浏览量的视频搜索 | |
| 本地地点/兴趣点搜索(2亿+兴趣点) | |
| 自动补全/查询建议 | |
| 查询语句拼写检查 | |
| 管理API密钥和设置 | |
Response Shapes
响应格式
bx "query"json
{
"grounding": {
"generic": [
{ "url": "...", "title": "...", "snippets": ["extracted content...", "..."] }
]
},
"sources": {
"https://example.com": { "title": "...", "hostname": "...", "age": ["...", "2025-01-15", "392 days ago"] }
}
}bx answers "query" --no-streamjson
{"choices": [{"message": {"content": "Full answer text..."}}]}bx answers "query"json
{"choices": [{"delta": {"content": "chunk"}}]}bx web "query"json
{
"web": { "results": [{"title": "...", "url": "...", "description": "..."}] },
"news": { "results": [...] },
"videos": { "results": [...] },
"discussions": { "results": [...] }
}bx "query"json
{
"grounding": {
"generic": [
{ "url": "...", "title": "...", "snippets": ["extracted content...", "..."] }
]
},
"sources": {
"https://example.com": { "title": "...", "hostname": "...", "age": ["...", "2025-01-15", "392 days ago"] }
}
}bx answers "query" --no-streamjson
{"choices": [{"message": {"content": "Full answer text..."}}]}bx answers "query"json
{"choices": [{"delta": {"content": "chunk"}}]}bx web "query"json
{
"web": { "results": [{"title": "...", "url": "...", "description": "..."}] },
"news": { "results": [...] },
"videos": { "results": [...] },
"discussions": { "results": [...] }
}Token Budget Control
令牌预算控制
Control output size for context (the default command):
| Flag | Short alias | Default | Description |
|---|---|---|---|
| | 8192 | Approximate total tokens (1024-32768) |
| | 4096 | Max tokens per URL (512-8192) |
| | 20 | Max URLs in response (1-50) |
| | 50 | Max snippets across all URLs |
| | — | Max snippets per URL |
| | balanced | Relevance: |
bash
bx "topic" --max-tokens 4096 --max-tokens-per-url 1024 --max-urls 5 --threshold strict控制context(默认命令)的输出大小:
| 标志 | 短别名 | 默认值 | 描述 |
|---|---|---|---|
| | 8192 | 总令牌数近似值(范围1024-32768) |
| | 4096 | 单URL最大令牌数(范围512-8192) |
| | 20 | 响应中包含的最大URL数量(范围1-50) |
| | 50 | 所有URL的最大片段数量 |
| | — | 单URL最大片段数量 |
| | balanced | 相关性模式: |
bash
bx "topic" --max-tokens 4096 --max-tokens-per-url 1024 --max-urls 5 --threshold strictGoggles — Custom Ranking
Goggles — 自定义排序
Goggles let you control which sources appear in results. Boost official docs, suppress SEO spam, or build focused search scopes. No other search tool offers this. Supported on , , and .
contextwebnewsGoggles允许你控制结果中显示的来源。可提升官方文档权重、抑制SEO垃圾内容,或构建聚焦的搜索范围。没有其他搜索工具提供此功能。支持、和命令。
contextwebnewsDomain Shortcuts
域名快捷方式
bash
undefinedbash
undefinedAllowlist — only results from these domains
白名单——仅返回这些域名的结果
bx "rust axum" --include-site docs.rs --include-site github.com
bx "rust axum" --include-site docs.rs --include-site github.com
Blocklist — exclude specific domains
黑名单——排除特定域名
bx "python tutorial" --exclude-site example.com
`--include-site`, `--exclude-site`, and `--goggles` are mutually exclusive.bx "python tutorial" --exclude-site example.com
`--include-site`、`--exclude-site`和`--goggles`互斥。Inline Rules
内联规则
bash
undefinedbash
undefinedBoost official docs, demote blog posts
提升官方文档权重,降低博客文章权重
bx "axum middleware tower"
--goggles '$boost=5,site=docs.rs $boost=3,site=github.com /docs/$boost=5 /blog/$downrank=3' --max-tokens 4096
--goggles '$boost=5,site=docs.rs $boost=3,site=github.com /docs/$boost=5 /blog/$downrank=3' --max-tokens 4096
bx "axum middleware tower"
--goggles '$boost=5,site=docs.rs $boost=3,site=github.com /docs/$boost=5 /blog/$downrank=3' --max-tokens 4096
--goggles '$boost=5,site=docs.rs $boost=3,site=github.com /docs/$boost=5 /blog/$downrank=3' --max-tokens 4096
Allowlist mode — only include matched sites
白名单模式——仅包含匹配的站点
bx "Python asyncio patterns"
--goggles '$discard $boost,site=docs.python.org $boost,site=peps.python.org'
--goggles '$discard $boost,site=docs.python.org $boost,site=peps.python.org'
undefinedbx "Python asyncio patterns"
--goggles '$discard $boost,site=docs.python.org $boost,site=peps.python.org'
--goggles '$discard $boost,site=docs.python.org $boost,site=peps.python.org'
undefinedDSL Quick Reference
DSL速查
| Rule | Effect | Example |
|---|---|---|
| Promote domain (N=1-10) | |
| Demote domain (N=1-10) | |
| Remove domain entirely | |
| Boost matching URL paths | |
Generic | Allowlist mode — discard unmatched | |
Separate rules with newlines. Full DSL: goggles-quickstart.
| 规则 | 效果 | 示例 |
|---|---|---|
| 提升域名权重(N=1-10) | |
| 降低域名权重(N=1-10) | |
| 完全移除该域名结果 | |
| 提升匹配URL路径的权重 | |
通用 | 白名单模式——丢弃未匹配结果 | |
规则之间用换行分隔。完整DSL文档:goggles-quickstart。
Piping Rules via Stdin
通过标准输入传递规则
bash
echo '$boost=5,site=docs.rs
$boost=5,site=crates.io
$boost=3,site=github.com' | bx "axum middleware" --goggles @- --max-tokens 4096Use to reuse a goggle across queries.
@/path/to/filebash
echo '$boost=5,site=docs.rs
$boost=5,site=crates.io
$boost=3,site=github.com' | bx "axum middleware" --goggles @- --max-tokens 4096使用可在多个查询中复用同一Goggle规则。
@/path/to/fileAgent Workflow Examples
Agent工作流示例
Debugging an error:
bash
bx "Python TypeError cannot unpack non-iterable NoneType" --max-tokens 4096Corrective RAG loop:
bash
undefined调试错误:
bash
bx "Python TypeError cannot unpack non-iterable NoneType" --max-tokens 4096修正型RAG循环:
bash
undefined1. Broad search
1. 宽泛搜索
bx "axum middleware authentication" --max-tokens 4096
bx "axum middleware authentication" --max-tokens 4096
2. Too general? Narrow with strict threshold
2. 结果太泛?用严格阈值缩小范围
bx "axum middleware tower layer authentication example" --threshold strict --max-tokens 4096
bx "axum middleware tower layer authentication example" --threshold strict --max-tokens 4096
3. Still need synthesis? Ask for an answer
3. 仍需要合成内容?请求AI回答
bx answers "how to implement JWT auth middleware in axum" --enable-research
**Checking for breaking changes before upgrading:**
```bash
bx "Next.js 15 breaking changes migration guide" --max-tokens 8192
bx news "Next.js 15 release" --freshness pmNon-streaming answers for programmatic use:
bash
bx answers "compare SQLx and Diesel for Rust" --no-streamAnswers via stdin (OpenAI-compatible JSON body):
bash
echo '{"messages":[{"role":"user","content":"what are the OWASP top 10 vulnerabilities for web APIs"}]}' | bx answers -bx answers "how to implement JWT auth middleware in axum" --enable-research
**升级前检查破坏性变更:**
```bash
bx "Next.js 15 breaking changes migration guide" --max-tokens 8192
bx news "Next.js 15 release" --freshness pm用于程序化调用的非流式回答:
bash
bx answers "compare SQLx and Diesel for Rust" --no-stream通过标准输入传递请求(兼容OpenAI的JSON格式):
bash
echo '{"messages":[{"role":"user","content":"what are the OWASP top 10 vulnerabilities for web APIs"}]}' | bx answers -Exit Codes
退出码
| Code | Meaning | Agent action |
|---|---|---|
| 0 | Success | Process results |
| 1 | Client error (bad request) | Fix query/parameters |
| 2 | Usage error (bad flags) | Fix CLI arguments |
| 3 | Auth/permission error (401/403) | Check API key: |
| 4 | Rate limited (429) | Retry after delay |
| 5 | Server/network error | Retry with backoff |
| 代码 | 含义 | Agent操作建议 |
|---|---|---|
| 0 | 成功 | 处理结果 |
| 1 | 客户端错误(请求无效) | 修正查询/参数 |
| 2 | 使用错误(标志无效) | 修正CLI参数 |
| 3 | 认证/权限错误(401/403) | 检查API密钥: |
| 4 | 速率限制(429) | 延迟后重试 |
| 5 | 服务器/网络错误 | 退避重试 |
Use Cases
使用场景
- AI agents / coding assistants: One-call web search with token-budgeted, RAG-ready content — replaces search + scrape + extract
- Fact-checking: Verify claims against current web content with
bx "query" --threshold strict - Documentation lookup: Search official docs with or Goggles domain boosting
--include-site - Research: Deep multi-source research with
bx answers "topic" --enable-research - Debugging: Search for error messages and stack traces directly
- News monitoring: Track topics with
bx news "query" --freshness pd - Local search: Find businesses and places with
bx places "query" --location "city"
- AI Agent/编码助手:一键式网页搜索,提供令牌预算控制、适用于RAG的内容——替代搜索+抓取+提取流程
- 事实核查:使用根据当前网页内容验证声明
bx "query" --threshold strict - 文档检索:使用或Goggles域名提升功能搜索官方文档
--include-site - 调研:使用进行多来源深度调研
bx answers "topic" --enable-research - 调试:直接搜索错误信息和堆栈跟踪
- 新闻监控:使用跟踪话题
bx news "query" --freshness pd - 本地搜索:使用查找商家和地点
bx places "query" --location "city"
Notes
注意事项
- All output is JSON to stdout; errors go to stderr
- Global flags: ,
--api-key KEY(default 30),--timeout SECS(repeatable, adds arbitrary API parameters)--extra KEY=VALUE - Location awareness: and
contextsupportweb,--lat,--long,--city,--state,--state-name,--loc-country,--postal-code--timezone - Research mode: can take up to 5 minutes; set client timeout accordingly
bx answers --enable-research - Help: for all commands;
bx --helpfor per-command flagsbx <command> --help
- 所有输出均为JSON格式,输出至标准输出;错误信息输出至标准错误
- 全局标志:、
--api-key KEY(默认30秒)、--timeout SECS(可重复使用,添加任意API参数)--extra KEY=VALUE - 位置感知:和
context命令支持web、--lat、--long、--city、--state、--state-name、--loc-country、--postal-code参数--timezone - 调研模式:可能需要长达5分钟;请相应设置客户端超时时间
bx answers --enable-research - 帮助:查看所有命令;
bx --help查看命令专属标志bx <command> --help