Brave API Search
Real-time web search, autosuggest, and AI-powered answers using the official Brave Search API. Three tools:
- -
brave_search — web results with titles, URLs, descriptions, optional AI summary - INLINECODE1 — query autosuggestions as users type with optional rich metadata
- INLINECODE2 — AI-grounded answers with inline citations powered by live web search
Setup
Set your Brave API keys in a local .env file (recommended):
CODEBLOCK0
Or export them in your shell session if needed.
Get your keys at: https://api-dashboard.search.brave.com
Both keys can be the same if your plan supports both Search and AI Answers endpoints.
Note: brave_search and brave_suggest use BRAVE_SEARCH_API_KEY. brave_answers requires BRAVE_ANSWERS_API_KEY.
Note: This skill explicitly requires BRAVE_SEARCH_API_KEY and BRAVE_ANSWERS_API_KEY. It does not use a generic BRAVE_API_KEY fallback.
When to Use This Skill
Use brave_search when:
- - Searching for current information, news, or recent events
- Looking up documentation or technical references
- Need ranked results with URLs to follow up on
- Want an AI summary of search results
Use brave_suggest when:
- - Power autocomplete in search interfaces
- Help users formulate better queries faster
- Need query completions as users type
- Want rich metadata (titles, descriptions, images) for suggestions
Use brave_answers when:
- - Need a synthesized answer with cited sources
- Researching topics that benefit from multiple sources
- Want AI-grounded responses with inline citations
- Deep research mode needed (multi-search)
Don't use this skill for:
- - Questions already answered from context or memory
- Tasks that don't require external information
Tools
brave_search
Web search returning ranked results with titles, URLs, and descriptions.
CODEBLOCK1
Parameters:
- -
query (required) — Search query, supports operators: site:, "exact phrase", INLINECODE18 - INLINECODE19 — Results to return (1-20, default: 10)
- INLINECODE20 — 2-letter country code (default:
us) - INLINECODE22 — Date filter:
pd (24h), pw (7 days), pm (31 days), py (1 year) - INLINECODE27 — Include up to 5 extra text excerpts per result (default: false)
- INLINECODE28 — Fetch Brave AI summarizer result (default: false)
Returns: Formatted list of results with title, URL, description, and optional AI summary.
brave_suggest
Query autosuggest API providing intelligent query autocompletion as users type.
CODEBLOCK2
Parameters:
- -
query (required) — Partial query to get suggestions for - INLINECODE30 — Number of suggestions (1-10, default: 5)
- INLINECODE31 — 2-letter country code (default:
US) - INLINECODE33 — Include enhanced metadata: titles, descriptions, images, entity detection (default: false, requires paid plan)
Returns: List of query suggestions, optionally with rich metadata.
Best Practices:
- - Implement debouncing (150-300ms) to avoid excessive API calls as users type
- Load suggestions asynchronously without blocking the UI
brave_answers
AI-powered answers grounded in live web search with inline citations.
CODEBLOCK3
Parameters:
- -
query (required) — Question or topic to research - INLINECODE35 — Include inline source citations (default: true)
- INLINECODE36 — Multi-search deep research mode (default: false)
- INLINECODE37 — Target country for search context (default:
us)
Returns: AI answer with cited sources extracted from the response, plus token usage.
Pricing & Limits
Brave pricing is credit-based and can change. Do not assume a fixed free request count.
Current public guidance (verify in Brave dashboard/docs before production use):
- - Monthly trial credits may be offered (e.g.
$5 in monthly credits) - Search and Answers consume credits differently
- Rich suggestions require a paid Autosuggest plan
- Answers may also include token-based costs
- QPS limits depend on your plan tier
Always check your live limits and usage in:
- - https://api-dashboard.search.brave.com
- https://brave.com/search/api/
Security & Packaging Notes
- - This skill only calls Brave official endpoints under
https://api.search.brave.com/res/v1. - It requires exactly two env vars:
BRAVE_SEARCH_API_KEY and BRAVE_ANSWERS_API_KEY (keep them in .env, not inline in commands/chats). - It does not request persistent/system privileges and does not modify system config.
- It is source-file based (three local Node scripts), with no external install/download step.
API vs Web Scraping
This skill uses the official Brave Search API — not web scraping. Benefits:
- - Reliable, structured JSON responses
- Rate limit headers and proper error messages
- Access to AI summarizer, AI answers, and autosuggest endpoints
- Terms of service compliant
Brave API 搜索
使用官方 Brave 搜索 API 进行实时网络搜索、自动建议和 AI 驱动的答案。三个工具:
- - bravesearch — 返回包含标题、URL、描述的网络结果,可选 AI 摘要
- bravesuggest — 用户输入时提供查询自动建议,可选丰富元数据
- brave_answers — 基于实时网络搜索的 AI 驱动答案,附带内联引用
设置
在本地 .env 文件中设置您的 Brave API 密钥(推荐):
bash
.env(请勿提交)
BRAVE
SEARCHAPI
KEY=yourkey_here
BRAVE
ANSWERSAPI
KEY=yourkey_here
或者根据需要,在您的 shell 会话中导出它们。
在此处获取您的密钥:https://api-dashboard.search.brave.com
如果您的套餐同时支持搜索和 AI 答案端点,两个密钥可以相同。
注意:bravesearch 和 bravesuggest 使用 BRAVESEARCHAPIKEY。braveanswers 需要 BRAVEANSWERSAPI_KEY。
注意:此技能明确需要 BRAVESEARCHAPIKEY 和 BRAVEANSWERSAPIKEY。它不使用通用的 BRAVEAPIKEY 作为后备。
何时使用此技能
使用 brave_search 当:
- - 搜索当前信息、新闻或近期事件
- 查找文档或技术参考资料
- 需要带有 URL 的排名结果以便跟进
- 想要搜索结果的 AI 摘要
使用 brave_suggest 当:
- - 在搜索界面中实现自动补全功能
- 帮助用户更快地制定更好的查询
- 用户输入时需要查询补全
- 想要建议的丰富元数据(标题、描述、图片)
使用 brave_answers 当:
- - 需要带有引用来源的综合答案
- 研究受益于多个来源的主题
- 想要带有内联引用的 AI 驱动响应
- 需要深度研究模式(多次搜索)
不要将此技能用于:
- - 已从上下文或记忆中回答的问题
- 不需要外部信息的任务
工具
brave_search
网络搜索,返回带有标题、URL 和描述的排名结果。
brave_search(query=latest Node.js release, count=5)
bravesearch(query=TypeScript generics, extrasnippets=true)
brave_search(query=current weather Copenhagen, freshness=pd)
brave_search(query=React Server Components, summary=true)
参数:
- - query(必需)— 搜索查询,支持运算符:site:、精确短语、-排除
- count — 返回的结果数(1-20,默认:10)
- country — 2 字母国家代码(默认:us)
- freshness — 日期筛选:pd(24 小时)、pw(7 天)、pm(31 天)、py(1 年)
- extra_snippets — 每个结果包含最多 5 个额外文本摘录(默认:false)
- summary — 获取 Brave AI 摘要结果(默认:false)
返回: 格式化的结果列表,包含标题、URL、描述和可选的 AI 摘要。
brave_suggest
查询自动建议 API,在用户输入时提供智能查询自动补全。
brave_suggest(query=hello)
brave_suggest(query=pyt, count=5, country=US)
brave_suggest(query=einstein, rich=true)
参数:
- - query(必需)— 获取建议的部分查询
- count — 建议数量(1-10,默认:5)
- country — 2 字母国家代码(默认:US)
- rich — 包含增强元数据:标题、描述、图片、实体检测(默认:false,需要付费套餐)
返回: 查询建议列表,可选附带丰富元数据。
最佳实践:
- - 实施防抖(150-300ms)以避免用户输入时过多的 API 调用
- 异步加载建议,不阻塞 UI
brave_answers
基于实时网络搜索的 AI 驱动答案,附带内联引用。
brave_answers(query=How does React Server Components work?)
braveanswers(query=Compare Postgres vs MySQL for OLAP, enableresearch=true)
braveanswers(query=Latest Python release notes, enablecitations=true)
参数:
- - query(必需)— 要研究的问题或主题
- enablecitations — 包含内联来源引用(默认:true)
- enableresearch — 多次搜索深度研究模式(默认:false)
- country — 搜索上下文的目标国家(默认:us)
返回: AI 答案,附带从响应中提取的引用来源,以及令牌使用量。
定价与限制
Brave 定价基于积分,可能会发生变化。不要假设固定的免费请求数量。
当前公开指南(在生产使用前请在 Brave 仪表板/文档中验证):
- - 可能提供月度试用积分(例如 每月 $5 积分)
- 搜索和答案消耗不同的积分
- 丰富建议需要付费的自动建议套餐
- 答案可能还包括基于令牌的成本
- QPS 限制取决于您的套餐层级
请始终在以下位置检查您的实时限制和使用情况:
- - https://api-dashboard.search.brave.com
- https://brave.com/search/api/
安全与打包说明
- - 此技能仅调用 https://api.search.brave.com/res/v1 下的 Brave 官方端点。
- 它需要恰好两个环境变量:BRAVESEARCHAPIKEY 和 BRAVEANSWERSAPIKEY(保存在 .env 中,不要内联在命令/聊天中)。
- 它不请求持久/系统权限,也不修改系统配置。
- 它基于源文件(三个本地 Node 脚本),无需外部安装/下载步骤。
API 与网页抓取
此技能使用官方 Brave 搜索 API — 而非网页抓取。优势:
- - 可靠的结构化 JSON 响应
- 速率限制标头和正确的错误消息
- 访问 AI 摘要器、AI 答案和自动建议端点
- 符合服务条款