How to Add Web Search to an LLM App With the Brave Search API

November 7, 2026

The Brave Search API returns ranked web results as JSON for about $5 per 1,000 queries on the base tier, and a free tier covers 2,000 queries a month. You call one endpoint with a query and a count, get titles, URLs, and descriptions, then feed those into your model as context.

The work is in the parameters and the post-processing, not the request. Brave Search gives you raw material; grounding quality depends on what you build around it.

What do you get back from one query?

A typical response contains:

  • web.results — title, url, description, plus page_age on many results
  • extra_snippets — up to 5 alternate passages per result on paid tiers
  • news, videos, discussions — separate verticals, requestable via result_filter
  • faq and infobox — on some queries

The description field is a short summary, typically 150–250 characters. extra_snippets is the underrated one: without it your model sees one sentence per result and misses the answer buried in paragraph four.

How do you authenticate and make the first call?

Sign up at the Brave Search API dashboard, get a key, then:

curl -s "https://api.search.brave.com/res/v1/web/search?q=postgres+incremental+materialization&count=10" \
  -H "Accept: application/json" \
  -H "X-Subscription-Token: $BRAVE_KEY"

In Python:

import httpx
r = httpx.get(
    "https://api.search.brave.com/res/v1/web/search",
    params={"q": query, "count": 10, "extra_snippets": True, "freshness": "py"},
    headers={"X-Subscription-Token": KEY, "Accept": "application/json"},
    timeout=10,
).json()

freshness=py restricts to the past year — the single most useful parameter for anything technical.

Which parameters change result quality?

Parameter Effect Practical value
count 1–20 results 10 is the sweet spot for grounding
freshness pd, pw, pm, py ranges Use py for tech, omit for reference
result_filter Limit to web, news, faq Cuts latency and noise
extra_snippets Up to 5 passages Paid tiers; worth it
search_lang Language bias Set for non-English apps

count=20 sounds better than 10 and usually is not. More results means more low-quality context competing for a 4,000-token window. Ten results with snippets fills it.

How should you structure the grounding prompt?

Three rules that hold up in production.

Number the sources. Give the model [1] url — snippet lines and ask it to cite by number. Outputs get auditable without a second model call.

Cap total context. Ten results × 3 snippets × 250 characters is about 7,500 characters, roughly 2,000 tokens. Tight, predictable, and it leaves room for the actual question.

Instruct fallback. Add one line: “If the sources do not answer the question, say so.” Without it, models confabulate from partial snippets at a rate that makes grounding pointless.

A prompt skeleton that works:

Answer the question using only the numbered sources.
Cite with [n]. If the sources are insufficient, say "Not in sources."

Sources:
[1] {url} — {snippet}
...

Question: {q}

What does it cost at scale?

  • Free — 1 query/second, 2,000/month, base web results only.
  • Base — around $5 per 1,000 queries, 20 queries/second.
  • Pro — around $9 per 1,000, adds extra_snippets and more verticals.

An app doing 10,000 grounded queries a month lands near $90 on Pro. Caching identical queries for 24 hours typically cuts that 30–50% for consumer apps where questions repeat.

Where does Brave Search underperform?

Index coverage is smaller than Google’s. Recent news and very niche technical topics can return thin results where Google would have five good pages. Test your actual query distribution, not ten generic queries.

It also has no built-in answer generation. You get results; you build the answer. That is the point, but it means quality depends on your prompt work.

Good fit: RAG apps needing a compliant, non-Google search backend, agent tools that call search, and anyone wanting transparent pricing per query.

Poor fit: apps needing deep long-tail coverage, teams without engineering capacity to build grounding, and high-volume use where caching is not possible.

Quick Summary

  • Brave Search API returns JSON web results at roughly $5 per 1,000 queries; 2,000 free per month.
  • extra_snippets on paid tiers gives up to 5 passages per result — worth the upgrade.
  • freshness=py and count=10 cover most technical grounding needs.
  • Number your sources and instruct an explicit “not in sources” fallback.
  • Index coverage is narrower than Google’s; test your real query distribution first.