Skip to main content
POST
LLM Context

Authorizations

Authorization
string
header
required

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

Headers

accept
enum<string>
default:application/json

The default supported media type is application/json.

Available options:
application/json,
*/*
Example:

"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.

Available options:
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

Available options:
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.

Required range: -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.

Required range: -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.

Body

application/json
q
string
required

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
country
enum<string>
default:US

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

Available options:
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
search_lang
enum<string>
default:en

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

Available options:
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
count
integer
default:20

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

Required range: 1 <= x <= 50
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.

Available options:
off,
moderate,
strict
spellcheck
boolean
default:true

Whether to enable spellcheck on the query.

maximum_number_of_urls
integer
default:20

Maximum number of different URLs to include in LLM context.

Required range: 1 <= x <= 50
maximum_number_of_tokens
integer
default:8192

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

Required range: 1024 <= x <= 32768
maximum_number_of_snippets
integer
default:50

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

Required range: 1 <= x <= 256
context_threshold_mode
enum<string> | null

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

Available options:
disabled,
strict,
lenient,
balanced
maximum_number_of_tokens_per_url
integer
default:4096

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

Required range: 512 <= x <= 8192
maximum_number_of_snippets_per_url
integer
default:50

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

Required range: 1 <= x <= 100
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.

freshness
string
default:""

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.
Examples:

""

"pm"

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

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
default:false

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

Response

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.