Sand AISand AI MAGI-2MAGI-2 現已登上 SandBase:支援原生音訊的 1080p 影片立即試用

Brave LLM Context

API 文件
https://api.sandbase.ai/v1/api/brave/llm-context

LLM Context from Brave. Returns the official Brave API response unchanged.

價格
$0.005美元/次呼叫
方法
POST
回應
JSON
參數
1 個必填 · 15 個選填

Playground

輸入
The user’s search query term. Query can not be empty. Maximum of 600 characters and 75 words in the query.
The mode to use to determine the threshold for including content in context.
150
The maximum number of search results considered to select the LLM context data. The default is 20 and the maximum is 50. 範圍:1 到 50。
The search query country, where the results come from. The country string is limited to 2 character country codes of supported countries.
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.
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. p
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.
1256
Maximum number of different snippets (or chunks of text) to include in LLM context. The default is 50 and maximum is 256 . 範圍:1 到 256。
1100
Maximum number of snippets to include per URL. The default is 50 and maximum is 100 . 範圍:1 到 100。
Approximate maximum number of tokens to include in context. The default is 8192 and maximum is 32768 . 範圍:1024 到 32768。
Maximum number of tokens to include per URL. The default is 4096 and maximum is 8192 . 範圍:512 到 8192。
150
Maximum number of different URLs to include in LLM context. 範圍:1 到 50。
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, wh
The search language preference. The 2 or more character language code for which the search results are provided.
Whether to enable spellcheck on the query.
輸出就緒

您的輸出會顯示在這裡

完成輸入後,點擊執行。

API README

Brave LLM Context API

Returns page content snippets from web search results, shaped for use as context in an LLM prompt. It needs one search query in q. The response lists source pages with their text chunks and a metadata map keyed by URL.

Use cases

  • Feed fresh web snippets about a topic into a chatbot prompt so it can answer a question with cited pages.
  • Build a research assistant that collects text chunks and source URLs for a query like best coffee in seattle.
  • Check the age of each source page and drop old pages before you pass text to a model.
  • Cap context size with maximum_number_of_tokens and maximum_number_of_urls to fit a model's prompt limit.

Request

curl -X POST "https://api.sandbase.ai/v1/api/brave/llm-context" \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "best coffee in seattle"}'

The result is returned in outputs[0].data.

Parameters

NameTypeRequiredDescription
qstringYesThe user’s search query term. Query can not be empty. Maximum of 600 characters and 75 words in the query.
context_threshold_modestringNoThe mode to use to determine the threshold for including content in context.
countintegerNoThe maximum number of search results considered to select the LLM context data. The default is 20 and the maximum is 50.
countrystringNoThe search query country, where the results come from. The country string is limited to 2 character country codes of supported countries.
enable_localbooleanNoWhether 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_metadatabooleanNoEnable source metadata enrichment (site_name, favicon, thumbnail, description, fetched_content_timestamp) in the sources attribute of the response.
freshnessstringNoFilters 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 h
gogglesstringNoGoggles 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 param
maximum_number_of_snippetsintegerNoMaximum number of different snippets (or chunks of text) to include in LLM context. The default is 50 and maximum is 256 .
maximum_number_of_snippets_per_urlintegerNoMaximum number of snippets to include per URL. The default is 50 and maximum is 100 .
maximum_number_of_tokensintegerNoApproximate maximum number of tokens to include in context. The default is 8192 and maximum is 32768 .
maximum_number_of_tokens_per_urlintegerNoMaximum number of tokens to include per URL. The default is 4096 and maximum is 8192 .
maximum_number_of_urlsintegerNoMaximum number of different URLs to include in LLM context.
safesearchstringNoFilters 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
search_langstringNoThe search language preference. The 2 or more character language code for which the search results are provided.
spellcheckbooleanNoWhether to enable spellcheck on the query.

Example response

Real response for the request above, trimmed: lists keep their first item and long strings are cut.

{
  "grounding": {
    "generic": [
      {
        "snippets": [
          "# The Best Seattle Coffee Shops\n## Cardoon\nAs for coffee you can’t go wrong with…"
        ],
        "title": "The Best Coffee Shops in the Seattle Area",
        "url": "https://seattle.eater.com/maps/seattles-best-coffee-shops"
      }
    ],
    "map": []
  },
  "sources": {
    "https://alyeatsfood.com/2022/07/31/must-try-seattle-coffee-shops/": {
      "age": [
        "Sunday, July 31, 2022"
      ],
      "hostname": "alyeatsfood.com",
      "snippet": "Seattle has some of the best coffee out there and chances are you may have tried…",
      "title": "Must Try Seattle Coffee Shops"
    },
    "https://anchorheadcoffee.com/": {
      "age": [
        "Friday, November 14, 2025"
      ],
      "hostname": "anchorheadcoffee.com",
      "snippet": "Anchorhead Coffee is a Seattle-based specialty coffee roaster with cafes in Down…",
      "title": "Anchorhead Coffee"
    },
    "https://explorewashingtonstate.com/10-cafes-to-grab-a-coffee-in-seattle/": {
      "age": [
        "Sunday, November 01, 2026"
      ],
      "hostname": "explorewashingtonstate.com",
      "snippet": "Seattle is stereotypically associated with its rainy weather, tech companies suc…",
      "title": "Best Coffee in Seattle (2026)"
    },
    "https://feastio.com/coffee-shops-seattle/": {
      "age": [
        "Friday, August 14, 2026"
      ],
      "hostname": "feastio.com",
      "snippet": "Explore the best Seattle coffee shops from iconic venues to hidden gems.",
      "title": "Exploring Seattle's Best Third-Wave Coffee Shops"
    },
    "https://seattle.eater.com/maps/seattles-best-coffee-shops": {
      "age": [
        "Wednesday, March 11, 2026"
      ],
      "hostname": "seattle.eater.com",
      "snippet": "Vietnamese brews topped with salted cream, old-school espresso, and innovative i…",
      "title": "The Best Coffee Shops in the Seattle Area"
    },
    "https://seattleunexplored.com/the-2018-best-seattle-coffee-shop-awards-part-1/": {
      "age": [
        "Saturday, December 12, 2020"
      ],
      "hostname": "seattleunexplored.com",
      "snippet": "With two young’uns, we’ve had to trade in our frequency of night life in Seattle…",
      "title": "The Seattle Coffee Shop Awards - Part 1 - Seattle Unexplored"
    },
    "https://seattleunexplored.com/the-seattle-coffee-shop-awards-part-4/": {
      "age": [
        "Saturday, December 12, 2020"
      ],
      "hostname": "seattleunexplored.com",
      "snippet": "See our other installments of Seattle Coffee Shop Awards: Everything You Always …",
      "title": "The Seattle Coffee Shop Awards - Part 4 - Seattle Unexplored"
    },
    "https://sevencoffeeroasters.com/pages/seven-market-cafe": {
      "age": [],
      "hostname": "sevencoffeeroasters.com",
      "snippet": "One of the best-reviewed coffee shops in Seattle on Google Maps.",
      "title": "Seven Market"
    },
    "https://wheatlesswanderlust.com/best-coffee-shops-in-seattle/": {
      "age": [
        "Tuesday, September 15, 2026"
      ],
      "hostname": "wheatlesswanderlust.com",
      "snippet": "Three coffee snobs go on a quest to uncover the best coffee in Seattle. Read to …",
      "title": "The Best Coffee In Seattle: A Guide For Coffee Lovers"
    },
    "https://www.cntraveler.com/gallery/best-coffee-shops-in-seattle-united-states": {
      "age": [
        "Friday, September 04, 2026"
      ],
      "hostname": "www.cntraveler.com",
      "snippet": "Our top recommendations for the best coffee in Seattle with pictures, reviews, a…",
      "title": "10 Best Coffee Shops in Seattle"
    },
    "https://www.doubleskinnymacchiato.com/2020/03/seattle-specialty-coffee-shops-guide-map.html": {
      "age": [
        "Monday, March 02, 2020"
      ],
      "hostname": "www.doubleskinnymacchiato.com",
      "snippet": "The first Starbucks opened in Pike Place Market in 1971, and whatever you feel a…",
      "title": "Double Skinny Macchiato"
    },
    "https://www.emeraldpalate.com/best-coffee-shops-in-seattle/": {
      "age": [
        "Thursday, July 30, 2026"
      ],
      "hostname": "www.emeraldpalate.com",
      "snippet": "A local shares the best coffee shops in Seattle, WA. Find creative coffee drinks…",
      "title": "26 Best Coffee Shops in Seattle, WA for a Caffeine Fix"
    }
  }
}

Response fields

FieldMeaning
grounding.generic[].titleTitle of a page whose text was selected as context.
grounding.generic[].urlURL of the page. It matches a key in the sources object.
grounding.generic[].snippets[]Text chunks taken from the page. Pass these to your LLM as context.
grounding.mapList of map-style results. It is empty in this response.
sources.<url>.titlePage title for the source, keyed by the full page URL.
sources.<url>.hostnameDomain name of the source page.
sources.<url>.snippetShort description of the page.
sources.<url>.ageList of three items: a readable date, an ISO date such as 2026-11-01, and a relative age such as 2 days ago. The list is empty when no date is known.

Notes

  • Only q is required. Use count, maximum_number_of_urls, maximum_number_of_snippets and maximum_number_of_tokens to control how much context comes back.
  • Match grounding.generic[].url to the keys of sources to get the hostname and age of each page.
  • sources can hold more pages than grounding.generic, so not every source has snippets.
  • Set enable_source_metadata to true to add fields such as site_name, favicon and thumbnail to sources. For plain result lists, try Brave Web Search.

Pricing

$0.005 per successful call. Failed calls are not charged. It is included in the daily free quota of each organization.

探索更多

相關 APIs

所有 APIs
API價格回應
Brave每次呼叫 $0.005JSON
Brave每次呼叫 $0.01JSON
Brave每次呼叫 $0.005JSON
Brave每次呼叫 $0.005JSON
Brave每次呼叫 $0.005JSON
Brave每次呼叫 $0.005JSON

問題

常見問題

我要如何使用 Brave LLM Context API?

使用 POST 請求將您的 SandBase API 金鑰放在 Authorization 標頭(Bearer)中,並以 JSON 主體傳入參數,即可呼叫 https://api.sandbase.ai/v1/api/brave/llm-context。您也可以直接在本頁的 Playground 試用,不必撰寫程式碼。

Brave LLM Context API 的費用是多少?

每次 $0.005,並從您的 SandBase 餘額中扣款。您只會為實際發出的呼叫付費;沒有訂閱方案。

Brave LLM Context API 接受哪些參數?

必要:q (string)。 選填:context_threshold_mode(disabled, strict, lenient, balanced 之一), count (integer), country(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), enable_source_metadata (boolean) 和 freshness (string),以及另外 9 個。 本頁的 Parameters 表格與 Playground 會列出每個欄位。

Brave LLM Context API 會回傳什麼?

在同一個 HTTP 請求中回傳的 JSON 回應(同步)。 本頁的 README 包含範例回應。

我需要 Brave 開發者帳號或 API 金鑰嗎?

不需要。Brave LLM Context 是透過 SandBase 運作,因此一組 SandBase API 金鑰即可使用此端點以及目錄中的其他所有 API 和模型。您不需要另外申請 Brave API 存取權。