$npx -y skills add brave/brave-search-skills --skill llm-contextUSE FOR RAG/LLM grounding. Returns pre-extracted web content (text, tables, code) optimized for LLMs. GET + POST. Adjust max_tokens/count based on complexity. Supports Goggles, local/POI. For AI answers use answers. Recommended for anyone building AI/agentic applications.
| 1 | # LLM Context |
| 2 | |
| 3 | > **Requires API Key**: Get one at https://api.search.brave.com |
| 4 | > |
| 5 | > **Plan**: Included in the **Search** plan. See https://api-dashboard.search.brave.com/app/subscriptions/subscribe |
| 6 | |
| 7 | Brave LLM Context API delivers pre-extracted, relevance-ranked web content optimized for grounding LLM responses in real-time search results. Unlike traditional web search APIs that return links and snippets, LLM Context extracts the actual page content—text chunks, tables, code blocks, and structured data—so your LLM or AI agent can reason over it directly. |
| 8 | |
| 9 | ## LLM Context vs AI Grounding |
| 10 | |
| 11 | | Feature | LLM Context (this) | AI Grounding (`answers`) | |
| 12 | |--|--|--| |
| 13 | | Output | Raw extracted content for YOUR LLM | End-to-end AI answers with citations | |
| 14 | | Interface | REST API (GET/POST) | OpenAI-compatible `/chat/completions` | |
| 15 | | Searches | Single search per request | Multi-search (iterative research) | |
| 16 | | Speed | Fast (<1s) | Slower | |
| 17 | | Plan | Search | Answers | |
| 18 | | Endpoint | `/res/v1/llm/context` | `/res/v1/chat/completions` | |
| 19 | | Best for | AI agents, RAG pipelines, tool calls | Chat interfaces, research mode | |
| 20 | |
| 21 | ## Endpoint |
| 22 | |
| 23 | ```http |
| 24 | GET https://api.search.brave.com/res/v1/llm/context |
| 25 | POST https://api.search.brave.com/res/v1/llm/context |
| 26 | ``` |
| 27 | |
| 28 | **Authentication**: `X-Subscription-Token: <API_KEY>` header |
| 29 | |
| 30 | **Optional Headers**: |
| 31 | - `Accept-Encoding: gzip` — Enable gzip compression |
| 32 | |
| 33 | ## Quick Start |
| 34 | |
| 35 | ### GET Request |
| 36 | ```bash |
| 37 | curl -s "https://api.search.brave.com/res/v1/llm/context?q=tallest+mountains+in+the+world" \ |
| 38 | -H "Accept: application/json" \ |
| 39 | -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}" |
| 40 | ``` |
| 41 | |
| 42 | ### POST Request (JSON body) |
| 43 | ```bash |
| 44 | curl -s --compressed -X POST "https://api.search.brave.com/res/v1/llm/context" \ |
| 45 | -H "Accept: application/json" \ |
| 46 | -H "Accept-Encoding: gzip" \ |
| 47 | -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}" \ |
| 48 | -H "Content-Type: application/json" \ |
| 49 | -d '{"q": "tallest mountains in the world"}' |
| 50 | ``` |
| 51 | |
| 52 | ### With Goggles (Inline) |
| 53 | ```bash |
| 54 | curl -s "https://api.search.brave.com/res/v1/llm/context" \ |
| 55 | -H "Accept: application/json" \ |
| 56 | -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}" \ |
| 57 | -G \ |
| 58 | --data-urlencode "q=rust programming" \ |
| 59 | --data-urlencode 'goggles=$discard |
| 60 | $site=docs.rs |
| 61 | $site=rust-lang.org' |
| 62 | ``` |
| 63 | |
| 64 | ## Parameters |
| 65 | |
| 66 | ### Query Parameters |
| 67 | |
| 68 | | Parameter | Type | Required | Default | Description | |
| 69 | |--|--|--|--|--| |
| 70 | | `q` | string | **Yes** | - | Search query (1-400 chars, max 50 words) | |
| 71 | | `country` | string | No | `US` | Search country (2-letter country code or `ALL`) | |
| 72 | | `search_lang` | string | No | `en` | Language preference (2+ char language code) | |
| 73 | | `count` | int | No | `20` | Max search results to consider (1-50) | |
| 74 | |
| 75 | ### Context Size Parameters |
| 76 | |
| 77 | | Parameter | Type | Required | Default | Description | |
| 78 | |--|--|--|--|--| |
| 79 | | `maximum_number_of_urls` | int | No | `20` | Max URLs in response (1-50) | |
| 80 | | `maximum_number_of_tokens` | int | No | `8192` | Approximate max tokens in context (1024-32768) | |
| 81 | | `maximum_number_of_snippets` | int | No | `50` | Max snippets across all URLs (1-100) | |
| 82 | | `maximum_number_of_tokens_per_url` | int | No | `4096` | Max tokens per individual URL (512-8192) | |
| 83 | | `maximum_number_of_snippets_per_url` | int | No | `50` | Max snippets per individual URL (1-100) | |
| 84 | |
| 85 | ### Filtering & Local Parameters |
| 86 | |
| 87 | | Parameter | Type | Required | Default | Description | |
| 88 | |--|--|--|--|--| |
| 89 | | `context_threshold_mode` | string | No | `balanced` | Relevance threshold for including content (`strict`/`balanced`/`lenient`) | |
| 90 | | `enable_local` | bool | No | `null` | Local recall control (`true`/`false`/`null`, see below) | |
| 91 | | `goggles` | string/list | No | `null` | Goggle URL or inline definition for custom re-ranking | |
| 92 | |
| 93 | ## Context Size Guidelines |
| 94 | |
| 95 | | Task Type | count | max_tokens | Example | |
| 96 | |--|--|--|--| |
| 97 | | Simple factual | 5 | 2048 | "What year was Python created?" | |
| 98 | | Standard queries | 20 | 8192 | "Best practices for React hooks" | |
| 99 | | Complex research | 50 | 16384 | "Compare AI frameworks for production" | |
| 100 | |
| 101 | Larger context windows provide more information but increase latency and cost (of your inference). Start with defaults and adjust. |
| 102 | |
| 103 | ## Threshold Modes |
| 104 | |
| 105 | | Mode | Behavior | |
| 106 | |--|--| |
| 107 | | `strict` | Higher threshold — fewer but more relevant results | |
| 108 | | `balanced` | Default — good balance between coverage and relevance | |
| 109 | | `lenient` | Lower threshold — more results, may include less relevant content | |
| 110 | |
| 111 | ## Local Recall |
| 112 | |
| 113 | The `enable_local` parameter controls location-aware recall: |
| 114 | |
| 115 | | Value | Behavior | |
| 116 | |--|--| |
| 117 | | `null` (not set) | **Auto-detect** — local recall enabled when any location header is provided | |
| 118 | | `true` | **Force local** — always use local recall, even without location headers | |
| 119 | | `false` | **For |