Skip to main content
Browserbase runs cloud browsers for agents, with session recordings and a live view for debugging. The same API key covers Search and Fetch, which find and read pages without starting a browser session. This page covers using Browserbase with Deep Agents: a Stagehand-driven cloud browser, plus Search and Fetch as agent tools.

Installation and setup

Get an API key from Browserbase and set it as an environment variable:
Install the Browserbase Python SDK:

Deep Agents

A deep agent can use Browserbase in two ways: a cloud browser that it drives through Stagehand tools, and Search and Fetch tools for pages that do not need a browser. For when to give an agent a browser, see Browser use.

Browser tools with Stagehand

The Stagehand integration adds run, snapshot, and screenshot through native Python middleware. Pass a configured Stagehand client to StagehandMiddleware, then include it in your agent’s middleware list. No MCP server or custom browser system prompt is needed. Your application owns the browser and can keep it open across runs to reuse tabs and logins. For installation, a complete agent, and cleanup, see Use with a deep agent. For session isolation, see Choose a browser scope.

Search and fetch tools

Expose Search and Fetch as agent tools. Those APIs find and read pages without starting a browser session. Fetch does not execute JavaScript. Install the agent packages and set the model-provider credential before running this example:
The example uses OpenAI’s GPT-5.5 snapshot. Omit provider on search.web to use your project’s default search provider:
For a complete example that combines Search, Fetch, and Stagehand, see Browserbase’s Deep Agents guide.