Skip to main content
GET
LLM Context

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求头

accept
enum<string>
默认值:application/json

The default supported media type is application/json.

可用选项:
application/json,
*/*
示例:

"application/json"

api-version
string | null

The API version to use. This is denoted by the format YYYY-MM-DD. Default is the latest that is available. Read more about API versioning.

cache-control
enum<string> | null

Brave Search will return cached content by default. To prevent caching set the Cache-Control header to no-cache. This is currently done as best effort.

可用选项:
no-cache
Allowed value: "no-cache"
user-agent
string | null

The user agent originating the request. Brave search can utilize the user agent to provide a different experience depending on the device as described by the string. The user agent should follow the commonly used browser agent strings on each platform. For more information on curating user agents, see RFC 9110.

x-loc-city
string | null

The generic name of the client city

x-loc-country
enum<string> | null

The two letter country code for the client’s country. For a list of country codes, see ISO 3166-1 alpha-2

可用选项:
AD,
AE,
AF,
AG,
AI,
AL,
AM,
AO,
AQ,
AR,
AS,
AT,
AU,
AW,
AX,
AZ,
BA,
BB,
BD,
BE,
BF,
BG,
BH,
BI,
BJ,
BL,
BM,
BN,
BO,
BQ,
BR,
BS,
BT,
BV,
BW,
BY,
BZ,
CA,
CC,
CD,
CF,
CG,
CH,
CI,
CK,
CL,
CM,
CN,
CO,
CR,
CU,
CV,
CW,
CX,
CY,
CZ,
DE,
DJ,
DK,
DM,
DO,
DZ,
EC,
EE,
EG,
EH,
ER,
ES,
ET,
FI,
FJ,
FK,
FM,
FO,
FR,
GA,
GB,
GD,
GE,
GF,
GG,
GH,
GI,
GL,
GM,
GN,
GP,
GQ,
GR,
GS,
GT,
GU,
GW,
GY,
HK,
HM,
HN,
HR,
HT,
HU,
ID,
IE,
IL,
IM,
IN,
IO,
IQ,
IR,
IS,
IT,
JE,
JM,
JO,
JP,
KE,
KG,
KH,
KI,
KM,
KN,
KP,
KR,
KW,
KY,
KZ,
LA,
LB,
LC,
LI,
LK,
LR,
LS,
LT,
LU,
LV,
LY,
MA,
MC,
MD,
ME,
MF,
MG,
MH,
MK,
ML,
MM,
MN,
MO,
MP,
MQ,
MR,
MS,
MT,
MU,
MV,
MW,
MX,
MY,
MZ,
NA,
NC,
NE,
NF,
NG,
NI,
NL,
NO,
NP,
NR,
NU,
NZ,
OM,
PA,
PE,
PF,
PG,
PH,
PK,
PL,
PM,
PN,
PR,
PS,
PT,
PW,
PY,
QA,
RE,
RO,
RS,
RU,
RW,
SA,
SB,
SC,
SD,
SE,
SG,
SH,
SI,
SJ,
SK,
SL,
SM,
SN,
SO,
SR,
SS,
ST,
SV,
SX,
SY,
SZ,
TC,
TD,
TF,
TG,
TH,
TJ,
TK,
TL,
TM,
TN,
TO,
TR,
TT,
TV,
TW,
TZ,
UA,
UG,
UM,
US,
UY,
UZ,
VA,
VC,
VE,
VG,
VI,
VN,
VU,
WF,
WS,
YE,
YT,
ZA,
ZM,
ZW
x-loc-lat
number | null

The latitude of the client’s geographical location in degrees, to provide relevant local results. The latitude must be greater than or equal to -90.0 degrees and less than or equal to +90.0 degrees.

必填范围: -90 <= x <= 90
x-loc-long
number | null

The longitude of the client’s geographical location in degrees, to provide relevant local results. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0 degrees.

必填范围: -180 <= x <= 180
x-loc-postal-code
string | null

The client’s postal code

x-loc-state
string | null

A code which could be up to three characters, that represent the client’s state/region. The region is the first-level subdivision (the broadest or least specific) of the ISO 3166-2 code.

x-loc-state-name
string | null

The name of the client’s state/region. The region is the first-level subdivision (the broadest or least specific) of the ISO 3166-2 code.

查询参数

context_threshold_mode
enum<string> | null

The mode to use to determine the threshold for including content in context.

可用选项:
disabled,
strict,
lenient,
balanced
count
integer
默认值:20

The maximum number of search results considered to select the LLM context data. The default is 20 and the maximum is 50.

必填范围: 1 <= x <= 50
country
enum<string>
默认值:US

The search query country, where the results come from. The country string is limited to 2 character country codes of supported countries.

可用选项:
AR,
AU,
AT,
BE,
BR,
CA,
CL,
DK,
FI,
FR,
DE,
GR,
HK,
IN,
ID,
IT,
JP,
KR,
MY,
MX,
NL,
NZ,
NO,
CN,
PL,
PT,
PH,
RU,
SA,
ZA,
ES,
SE,
CH,
TW,
TR,
GB,
US,
ALL
enable_local
boolean | null

Whether to enable local recall. Not setting this value means auto-detect: local recall is used if a location is provided (X-Loc-Lat with X-Loc-Long, or X-Loc-City).

enable_source_metadata
boolean
默认值:false

Enable source metadata enrichment (site_name, favicon, thumbnail, description, fetched_content_timestamp) in the sources attribute of the response.

freshness
string
默认值:""

Filters search results by page age. The age of a page is determined by the most relevant date reported by the content, such as its published or last modified date. The following values are supported:

  • pd - Pages aged 24 hours or less.
  • pw - Pages aged 7 days or less.
  • pm - Pages aged 31 days or less.
  • py - Pages aged 365 days or less.
  • YYYY-MM-DDtoYYYY-MM-DD - A custom date range is also supported by specifying start and end dates e.g. 2022-04-01to2022-07-30.
示例:

""

"pm"

"2022-04-01to2022-07-30"

goggles

Goggles act as a custom re-ranking on top of Brave’s search index. The parameter supports both a url where the Goggle is hosted or the definition of the Goggle. For more details, see the Goggles documentation. The parameter can be a single Goggle or a list of up to 3 Goggles.

maximum_number_of_snippets
integer
默认值:50

Maximum number of different snippets (or chunks of text) to include in LLM context. The default is 50 and maximum is 256.

必填范围: 1 <= x <= 256
maximum_number_of_snippets_per_url
integer
默认值:50

Maximum number of snippets to include per URL. The default is 50 and maximum is 100.

必填范围: 1 <= x <= 100
maximum_number_of_tokens
integer
默认值:8192

Approximate maximum number of tokens to include in context. The default is 8192 and maximum is 32768.

必填范围: 1024 <= x <= 32768
maximum_number_of_tokens_per_url
integer
默认值:4096

Maximum number of tokens to include per URL. The default is 4096 and maximum is 8192.

必填范围: 512 <= x <= 8192
maximum_number_of_urls
integer
默认值:20

Maximum number of different URLs to include in LLM context.

必填范围: 1 <= x <= 50
q
string
必填

The user’s search query term. Query can not be empty. Maximum of 600 characters and 75 words in the query.

Required string length: 1 - 600
safesearch
enum<string> | null

Filters results for adult content. The following values are supported:

  • off - No filtering is done.
  • moderate - Drops adult content from the results used for context.
  • strict - Drops all adult content from the results used for context.

When not set, no filtering is applied — except for local recall, which stays strict.

可用选项:
off,
moderate,
strict
search_lang
enum<string>
默认值:en

The search language preference. The 2 or more character language code for which the search results are provided.

可用选项:
ar,
eu,
bn,
bg,
ca,
zh-hans,
zh-hant,
hr,
cs,
da,
nl,
en,
en-gb,
et,
fi,
fr,
gl,
de,
el,
gu,
he,
hi,
hu,
is,
it,
ja,
jp,
kn,
ko,
lv,
lt,
ms,
ml,
mr,
nb,
pl,
pt-br,
pt-pt,
pa,
ro,
ru,
sr,
sk,
sl,
es,
sv,
ta,
te,
th,
tr,
uk,
vi
spellcheck
boolean
默认值:true

Whether to enable spellcheck on the query.

响应

Successful Response

Response model for the LLM Context API (/v1/llm/context).

grounding
LLMContext · object

Container for all LLM context content by type.

sources
Sources · object

Metadata for all referenced URLs, keyed by URL.