Service APIs

Advanced Web search, with pre-extracted content that's optimized for AI agents, LLM grounding, and RAG pipelines.
View skill file Skill file for LLM Context: Web search for AI agents and chatbots

How it works

LLM Context runs a single Web search, then ranks and returns the most relevant chunks of page content in a compact format for your model to reason over.

Traditional Web Search returns titles and short snippets for a results page. LLM Context returns extracted page chunks and source metadata in a shape and length that satisfies the needs of an LLM without need for further scraping.

LLM Context answers a query; it does not fetch a URL you name. To read more of one specific Web Search result, use its extra_snippets.

Use Cases

Use the LLM Context API for any Web search where an agent or model is the intended recipient, rather than a human. These include extracting text, markdown, and structured data like JSON or data tables; extracting code to answer technical questions; and extracting forum discussions (e.g. from Reddit) and captions (e.g. from YouTube).

LLM Context is perfect for:

  • AI Agents: Give your agent a Web search tool that returns ready-to-use content in a single call
  • RAG Pipelines: Ground LLM responses in fresh, relevant Web content
  • AI assistants & chatbots: Provide factual answers backed by real sources
  • Question answering: Retrieve focused context for specific queries
  • Fact checking: Verify claims against current Web content
  • Content research: Gather source material on any topic with one API call

Key Features

Pre-Extracted Content

Get actual page content (text, tables, code) ready for LLM consumption—no scraping needed

Token Budget Control

Fine-tune the amount of context with configurable token and URL limits

Relevance Filtering

Adjustable threshold modes ensure only relevant content reaches your LLM

Goggles Support

Control which sources ground your LLM using Brave’s unique Goggles re-ranking system

Local & POI Results

Location-aware queries with point-of-interest and map data

Fast Single-Search

Optimized for speed with a single search per request

API Reference

LLM Context API Documentation

View the complete API reference, including parameters and response schemas

Endpoint

GET https://api.search.brave.com/res/v1/llm/context
POST https://api.search.brave.com/res/v1/llm/context

Authentication: Include your API key in the X-Subscription-Token header.

Quick Start

GET Request

curl -X GET "https://api.search.brave.com/res/v1/llm/context?q=tallest+mountains+in+the+world" \
  -H "X-Subscription-Token: <YOUR_API_KEY>"

POST Request

POST accepts the same query parameters as a JSON request body with Content-Type: application/json. This is useful for complex queries or when parameters exceed URL length limits.

curl -s --compressed -X POST "https://api.search.brave.com/res/v1/llm/context" \
  -H "accept: application/json" \
  -H "Accept-Encoding: gzip" \
  -H "X-Subscription-Token: <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"q": "tallest mountains in the world"}'

Parameters

Query Parameters

ParameterTypeDefaultRangeDescription
qstringrequired1-600 chars, max 75 wordsThe search query
countrystringUS2-char codeCountry for search results
search_langstringen2+ char codeLanguage preference for results
countint201-50Maximum number of search results to consider
freshnessstring""—Filter results by their freshness (see Freshness below)
spellcheckbooltruetrue, falseSpellcheck the query before searching

Context Size Parameters

ParameterTypeDefaultRangeDescription
maximum_number_of_urlsint201-50Maximum URLs in the response
maximum_number_of_tokensint81921024-32768Approximate maximum tokens in context
maximum_number_of_tokens_per_urlint4096512-8192Maximum tokens per individual URL

Filtering & Local Parameters

ParameterTypeDefaultOptionsDescription
context_threshold_modestringlenientstrict, balanced, lenient, disabledRelevance threshold for including content
safesearchstringnulloff, moderate, strictAdult content filtering. Not set means no filtering, except with local recall which stays strict
enable_localboolnulltrue, false, nullEnable local recall for location-aware queries. When not set (null), enabled if X-Loc-Lat with X-Loc-Long, or X-Loc-City, is provided
gogglesstring/listnull—Goggle URL or inline definition for custom re-ranking; up to 3
enable_source_metadataboolfalsetrue, falseAdd site_name, favicon, thumbnail, description and fetched_content_timestamp to each sources[url] entry
operatorsbooltruetrue, falseApply search operators such as site:
operators_fallbackbooltruetrue, falseFall back to the original results when search operators return no results

Context Size Guidelines

The defaults are tuned for the best context: leave count, maximum_number_of_urls and maximum_number_of_tokens_per_url unset. To fit your LLM’s context window, set only maximum_number_of_tokens, the token budget the context fills:

Task Typemaximum_number_of_tokensExample
Simple factual2048“What year was Python created?”
Standard queries8192 (default)“Best practices for React hooks”
Complex research16384“Compare AI frameworks for production”

Larger budgets provide more information but increase the cost (of your inference).

Threshold Modes

The context_threshold_mode parameter controls how aggressively the API filters content for relevance:

ModeBehavior
strictHigher threshold — fewer but more relevant results
balancedGood balance between coverage and relevance
lenientLower threshold — more results, may include less relevant content
disabledNo threshold filtering — return all extracted content

When you leave it unset, the API uses lenient.

Freshness

The freshness parameter filters results used for context by their freshness. The freshness of a page is determined by the most relevant date reported by the content, such as its published or last modified date.

ValueDescription
pdPages aged 24 hours or less
pwPages aged 7 days or less
pmPages aged 31 days or less
pyPages aged 365 days or less
YYYY-MM-DDtoYYYY-MM-DDCustom date range, e.g. 2022-04-01to2022-07-30

Local Recall

The enable_local parameter controls whether location-aware recall is used:

ValueBehavior
null (not set)Auto-detect — default, local recall is enabled when X-Loc-Lat and X-Loc-Long, or X-Loc-City, are provided
trueForce local — always use local recall, even without location headers
falseForce standard — always use standard web ranking, even when location headers are present

For most use cases, you can omit enable_local entirely and let the API auto-detect it from your location headers. Set it explicitly only when you need to override the default behavior.

Location-Aware Queries

For local queries (restaurants, businesses, directions), provide location context via headers. Local recall is enabled automatically when you send coordinates (X-Loc-Lat and X-Loc-Long) or X-Loc-City, or you can set enable_local=true explicitly.

HeaderTypeDescription
X-Loc-LatfloatLatitude (-90.0 to 90.0)
X-Loc-LongfloatLongitude (-180.0 to 180.0)
X-Loc-CitystringCity name
X-Loc-StatestringState/region code (ISO 3166-2)
X-Loc-State-NamestringState/region name
X-Loc-Countrystring2-letter country code
X-Loc-Postal-CodestringPostal code

Not all headers are required. Coordinates (X-Loc-Lat and X-Loc-Long) alone are enough. Without coordinates, send X-Loc-City plus any other place-name headers you have; state, country or postal code without a city do not turn on local recall by themselves.

Example using coordinates:

curl -X GET "https://api.search.brave.com/res/v1/llm/context" \
  -H "X-Subscription-Token: <YOUR_API_KEY>" \
  -H "X-Loc-Lat: 37.7749" \
  -H "X-Loc-Long: -122.4194" \
  -G \
  --data-urlencode "q=best coffee shops near me"

Example using place name:

curl -X GET "https://api.search.brave.com/res/v1/llm/context" \
  -H "X-Subscription-Token: <YOUR_API_KEY>" \
  -H "X-Loc-City: San Francisco" \
  -H "X-Loc-State: CA" \
  -H "X-Loc-Country: US" \
  -G \
  --data-urlencode "q=best coffee shops near me"

Example with explicit enable_local=true (no location headers needed):

curl -X GET "https://api.search.brave.com/res/v1/llm/context" \
  -H "X-Subscription-Token: <YOUR_API_KEY>" \
  -G \
  --data-urlencode "q=best coffee shops in san francisco" \
  --data-urlencode "enable_local=true"

When local recall is active, grounding may include a poi object and map entries in addition to the standard generic array.

Goggles (Custom Source Ranking)

Goggles let you tailor which sources ground your LLM to better match your use case. You can restrict results to trusted domains, exclude user-generated content, or boost authoritative sources.

Goggles can be provided as a URL pointing to a hosted goggle file, or as an inline definition passed directly in the goggles parameter. Pass a list to apply up to 3 Goggles. For example, to restrict results to specific documentation sites, use an inline goggle with site rules.

For detailed syntax and examples, see the Goggles documentation.

Response Format

The response contains extracted web content organized into grounding data (by content type) and sources metadata.

Standard Response

{
  "grounding": {
    "generic": [
      {
        "url": "https://example.com/page",
        "title": "Page Title",
        "snippets": [
          "Relevant text chunk extracted from the page...",
          "Another relevant passage from the same page..."
        ]
      }
    ],
    "map": []
  },
  "sources": {
    "https://example.com/page": {
      "title": "Page Title",
      "hostname": "example.com",
      "age": ["Monday, January 15, 2024", "2024-01-15", "380 days ago", "2024-01-15T13:45:02Z"]
    }
  }
}

Local recall response

When local recall is active, the response may include POI and map data:

{
  "grounding": {
    "generic": [...],
    "poi": {
      "name": "Business Name",
      "url": "https://business.com",
      "title": "Title of business.com website",
      "snippets": ["Business details and information..."]
    },
    "map": [
      {
        "name": "Place Name",
        "url": "https://place.com",
        "title": "Title of place.com website",
        "snippets": ["Place information and details..."]
      }
    ]
  },
  "sources": {
    "https://business.com": {
      "title": "Business Name",
      "hostname": "business.com",
      "age": []
    }
  }
}

Response Fields

FieldTypeDescription
groundingobjectContainer for all grounding content by type
grounding.genericarrayArray of URL objects with extracted content (main grounding data)
grounding.generic[].urlstringSource URL
grounding.generic[].titlestringPage title
grounding.generic[].snippetsarrayExtracted text chunks from the page relevant to the query
grounding.poiobjectPoint of interest data. Omitted unless local recall finds one
grounding.maparrayMap/place results. Always present; [] unless local recall is active
sourcesobjectMetadata for all referenced URLs, keyed by URL
sources[url].titlestringPage title
sources[url].hostnamestringSource hostname
sources[url].agearrayThe page’s date in four fixed positions: full date, YYYY-MM-DD, relative age, ISO 8601 timestamp. Empty or omitted when the page has no known date
sources[url].snippetstringThe most query-relevant passage of the page, when available
sources[url].site_namestringSite name (e.g. Wikipedia). Requires enable_source_metadata
sources[url].faviconstringURL of the site’s favicon. Requires enable_source_metadata
sources[url].thumbnailobjectPage thumbnail: src is a proxied URL ready to serve, original the upstream URL. Requires enable_source_metadata
sources[url].descriptionstringThe page’s own description, independent of the query. Requires enable_source_metadata
sources[url].fetched_content_timestampintUnix seconds of the index’s last fetch of the page. Requires enable_source_metadata

Snippets may contain plain text or JSON-serialized structured data (tables, schemas, code blocks). LLMs handle this mixed format well, but you should be prepared for both when post-processing.

LLM Context vs Answers

Use LLM Context when your own model reasons over pre-extracted web content; use Answers when you want a finished, cited answer.

When to use LLM Context:

  • Giving your AI agent a web search tool it can call autonomously
  • Building RAG pipelines with your own LLM
  • Need full control over how context is processed and presented
  • Want raw extracted content without AI-generated summaries
  • Optimizing for speed with single-search retrieval
  • Need fine-grained control over token budgets and source filtering

When to use Answers:

  • Want end-to-end AI answers with citations
  • Need OpenAI SDK compatibility
  • Building conversational AI agents or chatbots with built-in search
  • Require research mode for thorough, multi-search answers

Learn more about Answers.

Best Practices

Token Budget Tuning

  • Keep the defaults for most queries; size the context with maximum_number_of_tokens only
  • Reduce it for simple factual lookups to save cost (of your inference)
  • Increase it for complex research tasks that benefit from more context

Source Quality

  • Use Goggles to restrict context to trusted, authoritative sources
  • Set context_threshold_mode=strict when precision matters more than recall

Error Handling

  • Set a 30-second timeout for requests
  • Check the HTTP status first: a 500 also returns an empty grounding.generic, so only an empty array on a 200 means no relevant content was found
  • A 422 means a parameter failed validation; fix the request rather than retrying
  • On 429, back off and retry; see Rate limiting for the rate limit headers
  • Retry 5xx responses with exponential backoff

Performance

  • Use the smallest maximum_number_of_tokens that meets your needs
  • For local queries, provide as many location headers as possible for better results

Changelog

This changelog outlines all significant changes to the Brave LLM Context API, newest first.

2026-07-31

  • Extract context with a new content pipeline by default. The previous pipeline has since been retired, so pinning Api-Version: 2026-02-06 no longer selects it
  • maximum_number_of_snippets and maximum_number_of_snippets_per_url have since been removed; size context with the token budgets. Requests that still send them are accepted and the values ignored
  • Add safesearch parameter for adult content filtering
  • Add enable_source_metadata to enrich sources with site_name, favicon, thumbnail, description and fetched_content_timestamp
  • Add a fourth sources[url].age position: an ISO 8601 timestamp, the only rendering that keeps the time of day
  • Add operators and operators_fallback parameters

2026-02-06

  • Launch Brave LLM Context API at /v1/llm/context
  • Support for both GET and POST methods
  • Single-search context retrieval with configurable token budgets
  • Support for Goggles, local/POI queries, and relevance threshold modes