1. Install AgentKit
Install AgentKit, Browserbase, and Playwright core:- npm
- pnpm
- yarn
Don’t have an existing project? Create a new one with your preferred package manager before continuing.
2. Set up an AgentKit network with an agent
Create an agent and its associated network, for example a Reddit search agent:Node.js
3. Create a Browserbase tool
Configure the Browserbase SDK and create a tool that can search Reddit:Node.js
Configure your
BROWSERBASE_API_KEY in the .env file. You can find your API key in the Browserbase dashboard.step.run() function. This ensures the tool only runs once across multiple runs.
See the multi-step tools page for more on step.run().
4. Put it all together
Here’s the full example:Node.js
Expected output
The browser tool logs the search URL and a JSON array of extracted titles and content. The final line printsexecution.output, which depends on the query and model response; inspect the returned sources to verify the result.
Cleanup
The browser tool closes its connection infinally. Stop any local development server with Ctrl+C, and confirm that sessions ended in the Sessions dashboard if you interrupted a run.
Next steps
AgentKit docs
Full AgentKit SDK reference and examples
Stagehand
Autonomous browser automation SDK