Service APIs
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/contextAuthentication: 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
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
q | string | required | 1-600 chars, max 75 words | The search query |
country | string | US | 2-char code | Country for search results |
search_lang | string | en | 2+ char code | Language preference for results |
count | int | 20 | 1-50 | Maximum number of search results to consider |
freshness | string | "" | — | Filter results by their freshness (see Freshness below) |
spellcheck | bool | true | true, false | Spellcheck the query before searching |
Context Size Parameters
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
maximum_number_of_urls | int | 20 | 1-50 | Maximum URLs in the response |
maximum_number_of_tokens | int | 8192 | 1024-32768 | Approximate maximum tokens in context |
maximum_number_of_tokens_per_url | int | 4096 | 512-8192 | Maximum tokens per individual URL |
Filtering & Local Parameters
| Parameter | Type | Default | Options | Description |
|---|---|---|---|---|
context_threshold_mode | string | lenient | strict, balanced, lenient, disabled | Relevance threshold for including content |
safesearch | string | null | off, moderate, strict | Adult content filtering. Not set means no filtering, except with local recall which stays strict |
enable_local | bool | null | true, false, null | Enable 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 |
goggles | string/list | null | — | Goggle URL or inline definition for custom re-ranking; up to 3 |
enable_source_metadata | bool | false | true, false | Add site_name, favicon, thumbnail, description and fetched_content_timestamp to each sources[url] entry |
operators | bool | true | true, false | Apply search operators such as site: |
operators_fallback | bool | true | true, false | Fall 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 Type | maximum_number_of_tokens | Example |
|---|---|---|
| Simple factual | 2048 | “What year was Python created?” |
| Standard queries | 8192 (default) | “Best practices for React hooks” |
| Complex research | 16384 | “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:
| Mode | Behavior |
|---|---|
strict | Higher threshold — fewer but more relevant results |
balanced | Good balance between coverage and relevance |
lenient | Lower threshold — more results, may include less relevant content |
disabled | No 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.
| Value | Description |
|---|---|
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 | Custom date range, e.g. 2022-04-01to2022-07-30 |
Local Recall
The enable_local parameter controls whether location-aware recall is used:
| Value | Behavior |
|---|---|
null (not set) | Auto-detect — default, local recall is enabled when X-Loc-Lat and X-Loc-Long, or X-Loc-City, are provided |
true | Force local — always use local recall, even without location headers |
false | Force 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.
| Header | Type | Description |
|---|---|---|
X-Loc-Lat | float | Latitude (-90.0 to 90.0) |
X-Loc-Long | float | Longitude (-180.0 to 180.0) |
X-Loc-City | string | City name |
X-Loc-State | string | State/region code (ISO 3166-2) |
X-Loc-State-Name | string | State/region name |
X-Loc-Country | string | 2-letter country code |
X-Loc-Postal-Code | string | Postal 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
| Field | Type | Description |
|---|---|---|
grounding | object | Container for all grounding content by type |
grounding.generic | array | Array of URL objects with extracted content (main grounding data) |
grounding.generic[].url | string | Source URL |
grounding.generic[].title | string | Page title |
grounding.generic[].snippets | array | Extracted text chunks from the page relevant to the query |
grounding.poi | object | Point of interest data. Omitted unless local recall finds one |
grounding.map | array | Map/place results. Always present; [] unless local recall is active |
sources | object | Metadata for all referenced URLs, keyed by URL |
sources[url].title | string | Page title |
sources[url].hostname | string | Source hostname |
sources[url].age | array | The 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].snippet | string | The most query-relevant passage of the page, when available |
sources[url].site_name | string | Site name (e.g. Wikipedia). Requires enable_source_metadata |
sources[url].favicon | string | URL of the site’s favicon. Requires enable_source_metadata |
sources[url].thumbnail | object | Page thumbnail: src is a proxied URL ready to serve, original the upstream URL. Requires enable_source_metadata |
sources[url].description | string | The page’s own description, independent of the query. Requires enable_source_metadata |
sources[url].fetched_content_timestamp | int | Unix 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.
LLM Context
Raw extracted content for your own LLM pipeline. Best for AI agents, RAG, and applications where you control the model.
Answers
Finished, cited answers from an OpenAI-compatible endpoint, when you don’t need to run your own model.
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_tokensonly - 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=strictwhen precision matters more than recall
Error Handling
- Set a 30-second timeout for requests
- Check the HTTP status first: a
500also returns an emptygrounding.generic, so only an empty array on a200means no relevant content was found - A
422means 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
5xxresponses with exponential backoff
Performance
- Use the smallest
maximum_number_of_tokensthat 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-06no longer selects it maximum_number_of_snippetsandmaximum_number_of_snippets_per_urlhave since been removed; size context with the token budgets. Requests that still send them are accepted and the values ignored- Add
safesearchparameter for adult content filtering - Add
enable_source_metadatato enrichsourceswithsite_name,favicon,thumbnail,descriptionandfetched_content_timestamp - Add a fourth
sources[url].ageposition: an ISO 8601 timestamp, the only rendering that keeps the time of day - Add
operatorsandoperators_fallbackparameters
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