curl --request POST \
--url https://api.aisa.one/apis/v1/brave/llm/context \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"q": "<string>",
"country": "US",
"search_lang": "en",
"count": 20,
"spellcheck": true,
"maximum_number_of_urls": 20,
"maximum_number_of_tokens": 8192,
"maximum_number_of_snippets": 50,
"maximum_number_of_tokens_per_url": 4096,
"maximum_number_of_snippets_per_url": 50,
"goggles": "<string>",
"freshness": "",
"enable_local": true,
"enable_source_metadata": false
}
'import requests
url = "https://api.aisa.one/apis/v1/brave/llm/context"
payload = {
"q": "<string>",
"country": "US",
"search_lang": "en",
"count": 20,
"spellcheck": True,
"maximum_number_of_urls": 20,
"maximum_number_of_tokens": 8192,
"maximum_number_of_snippets": 50,
"maximum_number_of_tokens_per_url": 4096,
"maximum_number_of_snippets_per_url": 50,
"goggles": "<string>",
"freshness": "",
"enable_local": True,
"enable_source_metadata": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
q: '<string>',
country: 'US',
search_lang: 'en',
count: 20,
spellcheck: true,
maximum_number_of_urls: 20,
maximum_number_of_tokens: 8192,
maximum_number_of_snippets: 50,
maximum_number_of_tokens_per_url: 4096,
maximum_number_of_snippets_per_url: 50,
goggles: '<string>',
freshness: '',
enable_local: true,
enable_source_metadata: false
})
};
fetch('https://api.aisa.one/apis/v1/brave/llm/context', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/brave/llm/context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'q' => '<string>',
'country' => 'US',
'search_lang' => 'en',
'count' => 20,
'spellcheck' => true,
'maximum_number_of_urls' => 20,
'maximum_number_of_tokens' => 8192,
'maximum_number_of_snippets' => 50,
'maximum_number_of_tokens_per_url' => 4096,
'maximum_number_of_snippets_per_url' => 50,
'goggles' => '<string>',
'freshness' => '',
'enable_local' => true,
'enable_source_metadata' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/brave/llm/context"
payload := strings.NewReader("{\n \"q\": \"<string>\",\n \"country\": \"US\",\n \"search_lang\": \"en\",\n \"count\": 20,\n \"spellcheck\": true,\n \"maximum_number_of_urls\": 20,\n \"maximum_number_of_tokens\": 8192,\n \"maximum_number_of_snippets\": 50,\n \"maximum_number_of_tokens_per_url\": 4096,\n \"maximum_number_of_snippets_per_url\": 50,\n \"goggles\": \"<string>\",\n \"freshness\": \"\",\n \"enable_local\": true,\n \"enable_source_metadata\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/brave/llm/context")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"q\": \"<string>\",\n \"country\": \"US\",\n \"search_lang\": \"en\",\n \"count\": 20,\n \"spellcheck\": true,\n \"maximum_number_of_urls\": 20,\n \"maximum_number_of_tokens\": 8192,\n \"maximum_number_of_snippets\": 50,\n \"maximum_number_of_tokens_per_url\": 4096,\n \"maximum_number_of_snippets_per_url\": 50,\n \"goggles\": \"<string>\",\n \"freshness\": \"\",\n \"enable_local\": true,\n \"enable_source_metadata\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/brave/llm/context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"q\": \"<string>\",\n \"country\": \"US\",\n \"search_lang\": \"en\",\n \"count\": 20,\n \"spellcheck\": true,\n \"maximum_number_of_urls\": 20,\n \"maximum_number_of_tokens\": 8192,\n \"maximum_number_of_snippets\": 50,\n \"maximum_number_of_tokens_per_url\": 4096,\n \"maximum_number_of_snippets_per_url\": 50,\n \"goggles\": \"<string>\",\n \"freshness\": \"\",\n \"enable_local\": true,\n \"enable_source_metadata\": false\n}"
response = http.request(request)
puts response.read_body{
"grounding": {
"generic": [],
"map": []
},
"sources": {}
}LLM Context
curl --request POST \
--url https://api.aisa.one/apis/v1/brave/llm/context \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"q": "<string>",
"country": "US",
"search_lang": "en",
"count": 20,
"spellcheck": true,
"maximum_number_of_urls": 20,
"maximum_number_of_tokens": 8192,
"maximum_number_of_snippets": 50,
"maximum_number_of_tokens_per_url": 4096,
"maximum_number_of_snippets_per_url": 50,
"goggles": "<string>",
"freshness": "",
"enable_local": true,
"enable_source_metadata": false
}
'import requests
url = "https://api.aisa.one/apis/v1/brave/llm/context"
payload = {
"q": "<string>",
"country": "US",
"search_lang": "en",
"count": 20,
"spellcheck": True,
"maximum_number_of_urls": 20,
"maximum_number_of_tokens": 8192,
"maximum_number_of_snippets": 50,
"maximum_number_of_tokens_per_url": 4096,
"maximum_number_of_snippets_per_url": 50,
"goggles": "<string>",
"freshness": "",
"enable_local": True,
"enable_source_metadata": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
q: '<string>',
country: 'US',
search_lang: 'en',
count: 20,
spellcheck: true,
maximum_number_of_urls: 20,
maximum_number_of_tokens: 8192,
maximum_number_of_snippets: 50,
maximum_number_of_tokens_per_url: 4096,
maximum_number_of_snippets_per_url: 50,
goggles: '<string>',
freshness: '',
enable_local: true,
enable_source_metadata: false
})
};
fetch('https://api.aisa.one/apis/v1/brave/llm/context', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/brave/llm/context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'q' => '<string>',
'country' => 'US',
'search_lang' => 'en',
'count' => 20,
'spellcheck' => true,
'maximum_number_of_urls' => 20,
'maximum_number_of_tokens' => 8192,
'maximum_number_of_snippets' => 50,
'maximum_number_of_tokens_per_url' => 4096,
'maximum_number_of_snippets_per_url' => 50,
'goggles' => '<string>',
'freshness' => '',
'enable_local' => true,
'enable_source_metadata' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/brave/llm/context"
payload := strings.NewReader("{\n \"q\": \"<string>\",\n \"country\": \"US\",\n \"search_lang\": \"en\",\n \"count\": 20,\n \"spellcheck\": true,\n \"maximum_number_of_urls\": 20,\n \"maximum_number_of_tokens\": 8192,\n \"maximum_number_of_snippets\": 50,\n \"maximum_number_of_tokens_per_url\": 4096,\n \"maximum_number_of_snippets_per_url\": 50,\n \"goggles\": \"<string>\",\n \"freshness\": \"\",\n \"enable_local\": true,\n \"enable_source_metadata\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/brave/llm/context")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"q\": \"<string>\",\n \"country\": \"US\",\n \"search_lang\": \"en\",\n \"count\": 20,\n \"spellcheck\": true,\n \"maximum_number_of_urls\": 20,\n \"maximum_number_of_tokens\": 8192,\n \"maximum_number_of_snippets\": 50,\n \"maximum_number_of_tokens_per_url\": 4096,\n \"maximum_number_of_snippets_per_url\": 50,\n \"goggles\": \"<string>\",\n \"freshness\": \"\",\n \"enable_local\": true,\n \"enable_source_metadata\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/brave/llm/context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"q\": \"<string>\",\n \"country\": \"US\",\n \"search_lang\": \"en\",\n \"count\": 20,\n \"spellcheck\": true,\n \"maximum_number_of_urls\": 20,\n \"maximum_number_of_tokens\": 8192,\n \"maximum_number_of_snippets\": 50,\n \"maximum_number_of_tokens_per_url\": 4096,\n \"maximum_number_of_snippets_per_url\": 50,\n \"goggles\": \"<string>\",\n \"freshness\": \"\",\n \"enable_local\": true,\n \"enable_source_metadata\": false\n}"
response = http.request(request)
puts response.read_body{
"grounding": {
"generic": [],
"map": []
},
"sources": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
The default supported media type is application/json.
application/json, */* "application/json"
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.
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 "no-cache"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.
The generic name of the client city
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 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 <= 90The 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 <= 180The client’s postal code
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.
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
The user’s search query term. Query can not be empty. Maximum of 600 characters and 75 words in the query.
1 - 600The 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 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 The maximum number of search results considered to select the LLM context data. The default is 20 and the maximum is 50.
1 <= x <= 50Filters 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 Whether to enable spellcheck on the query.
Maximum number of different URLs to include in LLM context.
1 <= x <= 50Approximate maximum number of tokens to include in context. The default is 8192 and maximum is 32768.
1024 <= x <= 32768Maximum number of different snippets (or chunks of text) to include in LLM context. The default is 50 and maximum is 256.
1 <= x <= 256The mode to use to determine the threshold for including content in context.
disabled, strict, lenient, balanced Maximum number of tokens to include per URL. The default is 4096 and maximum is 8192.
512 <= x <= 8192Maximum number of snippets to include per URL. The default is 50 and maximum is 100.
1 <= x <= 100Goggles 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.
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"
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 enrichment (site_name, favicon, thumbnail, description, fetched_content_timestamp) in the sources attribute of the response.