Suggest

作者 brave62793e0c49ed无许可证183 个星标收录于 2026年10月8日更新于 2026年10月8日仓库2周前更新

USE FOR query autocomplete/suggestions. Fast (<100ms). Returns suggested queries as user types. Supports rich suggestions with entity info. Typo-resilient.

AI 生成的概览

封装 Brave Suggest API,在用户输入时返回查询自动补全建议。

功能
说明 Brave Suggest 接口、其认证请求头、查询参数与响应字段。它展示如何请求基础或丰富建议,包括实体标题、描述和图片数据。它还列出使用场景,例如边输入边搜索界面、检索前的查询细化、实体识别以及容错输入。
适用场景
适用于构建自动补全或边输入边搜索功能,或在网页搜索、检索步骤之前扩展不完整或有歧义的查询。也适合需要实体预览或容错建议的场景。
运行要求
需要 Brave Search API 密钥并通过 X-Subscription-Token 请求头发送,需要访问 api.search.brave.com 的网络权限,以及包含 Suggest 方案的订阅;丰富建议需要付费 Search 方案。该技能不附带脚本。

Suggest / Autocomplete

Requires API Key: Get one at https://api.search.brave.com

Plan: Included in the Suggest plan. See https://api-dashboard.search.brave.com/app/subscriptions/subscribe

Quick Start (cURL)

Basic Suggestions

bash
curl -s "https://api.search.brave.com/res/v1/suggest/search?q=how+to+" \  -H "Accept: application/json" \  -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}"

With All Parameters

bash
curl -s "https://api.search.brave.com/res/v1/suggest/search" \  -H "Accept: application/json" \  -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}" \  -G \  --data-urlencode "q=albert" \  --data-urlencode "country=US" \  --data-urlencode "lang=en" \  --data-urlencode "count=10" \  --data-urlencode "rich=true"

Endpoint

http
GET https://api.search.brave.com/res/v1/suggest/search

Authentication: X-Subscription-Token: <API_KEY> header

Optional Headers:

  • Accept-Encoding: gzip — Enable response compression

Parameters

ParameterTypeRequiredDefaultDescription
qstringYes—Suggest search query (1-400 chars, max 50 words)
langstringNoenLanguage preference (2+ char language code, e.g. fr, de, zh-hans)
countrystringNoUSSearch country (2-letter country code or ALL)
countintNo5Number of suggestions (1-20). Actual results may be fewer
richboolNofalseEnhance with entity info (title, description, image). Paid Search plan required

Response Fields

FieldTypeDescription
typestringAlways "suggest"
query.originalstringThe original suggest search query
resultsarrayList of suggestions (may be empty)
results[].querystringSuggested query completion
results[].is_entitybool?Whether the suggested enriched query is an entity (rich only)
results[].titlestring?The suggested query enriched title (rich only)
results[].descriptionstring?The suggested query enriched description (rich only)
results[].imgstring?The suggested query enriched image URL (rich only)

Fields with null values are excluded from the response. Non-rich results contain only the query field.

Rich Response Example (rich=true)

json
{  "type": "suggest",  "query": { "original": "albert" },  "results": [    {      "query": "albert einstein",      "is_entity": true,      "title": "Albert Einstein",      "description": "German-born theoretical physicist",      "img": "https://imgs.search.brave.com/..."    },    { "query": "albert einstein quotes", "is_entity": false }  ]}

Use Cases

  • Search-as-you-type UI: Real-time autocomplete dropdown. Debounce 150-300ms.
  • Query refinement for RAG: Expand partial/ambiguous queries before calling web-search or llm-context.
  • Entity detection: Use rich=true to detect entities with title, description, and image for preview cards.
  • Typo-tolerant input: Get clean suggestions from misspelled input without separate spellcheck.

Notes

  • Latency: Designed for <100ms response times
  • Country/lang: Hints for suggestion relevance, not strict filters
  • Typo handling: Suggestions handle common typos without separate spellcheck

来源与署名

来源:brave/brave-search-skills位于skills/suggest提交62793e0

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架