Skip to main content

What is search()?

An agent that doesn’t know where to start has to launch a browser, load a search engine, wait for the page, and read a result list before it can do anything useful. browserbase.search() collapses that into a single API call: you send a query, you get back ranked results with URLs, titles, and metadata.
search() is a Browserbase cloud feature. The query runs on Browserbase infrastructure and needs a Browserbase API key, so local browsers have no equivalent.

Why use search()?

Whole-web index

Search spans the whole web, so your agent can discover sources on any topic instead of being limited to domains you hardcoded.

Structured, ranked output

Results come back as structured objects, ranked for relevance and ready for the agent to act on, with no result page to parse.

Live, low-latency results

Every query hits the live web rather than a cached index, and it returns without the cost of booting a browser and rendering a search page.

Token-optimized

Each result carries the URL, title, and metadata rather than full page excerpts. The agent decides which pages are worth fetching, and the context window stays lean.

Setup

search() ships with the Stagehand SDK. The only requirement is a Browserbase API key:

Response

A search returns the query it ran, a request ID you can quote in support requests, and the ranked results. id, title, and url are always present; the rest are filled in when the source exposes them.
Field names follow each language’s conventions: requestId and publishedDate in TypeScript, request_id and published_date in Python, and RequestID and PublishedDate on the Go structs.

API reference

Parameters

string
required
Your Browserbase API key. Search is billed to the project that owns the key.
string
required
The search query, 1–200 characters.
number
How many results to return, between 1 and 25. Defaults to 10.
string
Browserbase API origin override. Defaults to https://api.browserbase.com.

Returns

string
The query that was executed.
string
Identifier for this search request.
SearchResult[]
Results ordered by relevance.
Stagehand rejects invalid input before the request leaves your process: an empty query, a query over 200 characters, or a numResults outside 1–25 raises locally rather than costing you a round trip.

Search, then read

search() deliberately returns pointers rather than page bodies. Pair it with fetch() to pull the content of the one or two pages that matter, and reach for a full browser session only when the page needs interaction.

Use cases

General agents and chatbots

Retrieve up-to-date information to produce more accurate answers.

Coding agents

Find the best library, or the documentation page for a given technical requirement.

Research agents

Conduct in-depth web research across the whole web.

Voice agents

Find relevant sources fast enough for low-latency voice interactions.

Limits

Exceeding the rate limit returns a 429. Back off and retry rather than looping.

Next steps

Web Fetch

Turn any URL you discovered into agent-ready markdown or JSON.

Browserbase Search

Endpoint details, pricing, and the underlying REST API.