1. Get your API key
Go over the Dashboard’s Settings tab:
BROWSERBASE_API_KEY
and BROWSERBASE_PROJECT_ID
environment variables.
You will also need an API key for an LLM. The below example uses Anthropic by setting ANTHROPIC_API_KEY, but you can add OPENAI_API_KEY, GOOGLE_API_KEY or your own local LLM.
2. Install Portia with Browserbase
pip install portia-sdk-python[tools-browser-browserbase]
3. Create a simple agent
The below simple agent examples works with the free trial version of Browserbase to retrieve the headlines from a news website.4. Create an agent with authentication!
Whenever a browser tool encounters a page that requires authentication, it will raise a clarification request to the user. The user will need to provide the necessary credentials or authentication information into the website displayed via a Browserbase live link to proceed. The cookies for that authentication can then be reused for future agent plan runs until they expire (and the user will be asked to authenticate again). To use authentication within Portia and Browserbase, a paid version of Browserbase is required. The below diagram shows how the system works when authentication is required: