Installation and setup
Get an API key from Browserbase and set it as an environment variable: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 addsrun, 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:provider on search.web to use your project’s default search provider:
Connect these docs to your agent of choice via MCP for real-time answers.

