Answers — AI Grounding
Requires API Key: Get one at https://api.search.brave.com
Plan: Included in the Answers plan. See https://api-dashboard.search.brave.com/app/subscriptions/subscribe
When to Use
| Use Case | Skill | Why |
|---|
| Quick factual answer (raw context) | INLINECODE0 | Single search, returns raw context for YOUR LLM |
| Fast AI answer with citations |
answers (single-search) | streaming, citations |
| Thorough multi-search deep research |
answers (research mode) | Iterative deep research, synthesized cited answer |
This endpoint (/res/v1/chat/completions) supports two modes:
- - Single-search (default): Fast AI-grounded answer from a single search. Supports
enable_citations. - Research (
enable_research=true): Multi-iteration deep research with progress events and synthesized cited answer.
Quick Start (cURL)
Blocking (Single-Search)
CODEBLOCK0
Streaming with Citations (Single-Search)
CODEBLOCK1
Research Mode
CODEBLOCK2
Endpoint
CODEBLOCK3
Authentication: X-Subscription-Token: <API_KEY> header (or Authorization: Bearer <API_KEY>)
SDK Compatible: Works with OpenAI SDK via INLINECODE8
Two Modes
| Feature | Single-Search (default) | Research (enable_research=true) |
|---|
| Speed | Fast | Slow |
| Searches |
1 | Multiple (iterative) |
| Streaming | Optional (
stream=true/false) |
Required (
stream=true) |
| Citations |
enable_citations=true (streaming only) | Built-in (in
<answer> tag) |
| Progress events | No | Yes (
<progress> tags) |
| Blocking response | Yes (
stream=false) | No |
Parameters
Standard Parameters
| Parameter | Type | Required | Default | Description |
|---|
| INLINECODE16 | array | Yes | - | Single user message (exactly 1 message) |
| INLINECODE17 |
string |
Yes | - | Use
"brave" |
|
stream | bool | No | true | Enable SSE streaming |
|
country | string | No | "US" | Search country (2-letter country code or
ALL) |
|
language | string | No | "en" | Response language |
|
safesearch | string | No | "moderate" | Search safety level (
off,
moderate,
strict) |
|
max_completion_tokens | int | No | null | Upper bound on completion tokens |
|
enable_citations | bool | No | false | Include inline citation tags (single-search streaming only) |
|
web_search_options | object | No | null | OpenAI-compatible;
search_context_size:
low,
medium,
high |
Research Parameters
| Parameter | Type | Required | Default | Description |
|---|
| INLINECODE34 | bool | No | INLINECODE35 | Enable research mode |
| INLINECODE36 |
bool | No |
true | Enable extended thinking |
|
research_maximum_number_of_tokens_per_query | int | No |
8192 | Max tokens per query (1024-16384) |
|
research_maximum_number_of_queries | int | No |
20 | Max total search queries (1-50) |
|
research_maximum_number_of_iterations | int | No |
4 | Max research iterations (1-5) |
|
research_maximum_number_of_seconds | int | No |
180 | Time budget in seconds (1-300) |
|
research_maximum_number_of_results_per_query | int | No |
60 | Results per search query (1-60) |
Constraints (IMPORTANT)
| Constraint | Error |
|---|
| INLINECODE48 requires INLINECODE49 | "Blocking response doesn't support 'enableresearch' option" |
| INLINECODE50 incompatible with INLINECODE51 |
"Research mode doesn't support 'enablecitations' option" |
|
enable_citations=true requires
stream=true | "Blocking response doesn't support 'enable_citations' option" |
OpenAI SDK Usage
Blocking (Single-Search)
CODEBLOCK4
Streaming with Citations (Single-Search)
CODEBLOCK5
Research Mode
CODEBLOCK6
Response Format
Blocking Response (stream=false, single-search only)
Standard OpenAI-compatible JSON:
CODEBLOCK7
Streaming Response
SSE response with OpenAI-compatible chunks:
CODEBLOCK8
Streaming Tags by Mode
Single-Search (with enable_citations=true)
| Tag | Purpose |
|---|
| INLINECODE56 | Inline citation references |
| INLINECODE57 |
JSON cost/billing data |
Research Mode
| Tag | Purpose | Keep? |
|---|
| INLINECODE58 | Generated search queries | Debug |
| INLINECODE59 |
URL counts (verbose) | Debug |
|
<thinking> | URL selection reasoning | Debug |
|
<progress> | Stats: time, iterations, queries, URLs analyzed, tokens | Monitor |
|
<blindspots> | Knowledge gaps identified |
Yes |
|
<answer> | Final synthesized answer (only the final answer is emitted; intermediate drafts are dropped) |
Yes |
|
<usage> | JSON cost/billing data (included at end of streaming response) |
Yes |
Usage Tag Format
The <usage> tag contains JSON-stringified cost and token data:
CODEBLOCK9
Use Cases
- - Chat interface integration: Drop-in OpenAI SDK replacement with web-grounded answers. Set
base_url="https://api.search.brave.com/res/v1". - Deep research / comprehensive topic research: Use research mode (
enable_research=true) for complex questions needing multi-source synthesis (e.g., "Compare approaches to nuclear fusion"). - OpenAI SDK drop-in: Same SDK, same streaming format — just change
base_url and api_key. Works with both sync and async clients. - Cited answers: Enable
enable_citations=true in single-search mode for inline citation tags, or use research mode which automatically includes citations in its answer.
Notes
- - Timeout: Set client timeout to at least 30s for single-search, 300s (5 min) for research
- Single message: The
messages array must contain exactly 1 user message - Cost monitoring: Parse the
<usage> tag from streaming responses to track costs
答案 — AI 基础事实支撑
需要 API 密钥:请访问 https://api.search.brave.com 获取
套餐:包含在 Answers 套餐中。详见 https://api-dashboard.search.brave.com/app/subscriptions/subscribe
使用场景
| 使用场景 | 技能 | 原因 |
|---|
| 快速事实性回答(原始上下文) | llm-context | 单次搜索,为您的 LLM 返回原始上下文 |
| 带引用的快速 AI 回答 |
answers(单次搜索) | 流式传输,引用 |
| 全面的多次搜索深度研究 |
answers(研究模式) | 迭代深度研究,综合引用回答 |
此端点(/res/v1/chat/completions)支持两种模式:
- - 单次搜索(默认):通过单次搜索快速获得 AI 基础事实支撑的回答。支持 enablecitations。
- 研究(enableresearch=true):多次迭代深度研究,包含进度事件和综合引用回答。
快速开始(cURL)
阻塞式(单次搜索)
bash
curl -X POST https://api.search.brave.com/res/v1/chat/completions \
-H Content-Type: application/json \
-H X-Subscription-Token: ${BRAVE
SEARCHAPI_KEY} \
-d {
messages: [{role: user, content: 詹姆斯·韦伯太空望远镜是如何工作的?}],
model: brave,
stream: false
}
带引用的流式传输(单次搜索)
bash
curl -X POST https://api.search.brave.com/res/v1/chat/completions \
-H Content-Type: application/json \
-H X-Subscription-Token: ${BRAVE
SEARCHAPI_KEY} \
-d {
messages: [{role: user, content: 聚变能源最近有哪些突破?}],
model: brave,
stream: true,
enable_citations: true
}
研究模式
bash
curl -X POST https://api.search.brave.com/res/v1/chat/completions \
-H Content-Type: application/json \
-H X-Subscription-Token: ${BRAVE
SEARCHAPI_KEY} \
-d {
messages: [{role: user, content: 比较量子计算方法}],
model: brave,
stream: true,
enable_research: true,
research
maximumnumber
ofiterations: 3,
research
maximumnumber
ofseconds: 120
}
端点
http
POST https://api.search.brave.com/res/v1/chat/completions
认证方式:X-Subscription-Token: KEY> 请求头(或 Authorization: Bearer KEY>)
SDK 兼容:通过 base_url=https://api.search.brave.com/res/v1 与 OpenAI SDK 兼容
两种模式
| 特性 | 单次搜索(默认) | 研究(enable_research=true) |
|---|
| 速度 | 快 | 慢 |
| 搜索次数 |
1 | 多次(迭代) |
| 流式传输 | 可选(stream=true/false) |
必需(stream=true) |
| 引用 | enable_citations=true(仅流式传输) | 内置(在
标签中) |
| 进度事件 | 否 | 是(