1

Get your API Key

Go over the Dashboard’s Settings tab:

Then, copy your API Key directly from the input and set it in the BROWSERBASE_KEY environment variable.

2

Install the Browserbase SDK

  pip install browserbase
3

Load documents or images

Load documents

Python
from llama_index.readers.web import BrowserbaseWebReader

reader = BrowserbaseWebReader()
docs = reader.load_data(
    urls=[
        "https://example.com",
    ],
    # Text mode
    text_content=True,
)

The default value text_content=False will return HTML as a LlamaIndex Document. Setting text_content=True will return LlamaIndex Document with text only.

Load images

Python
from browserbase import Browserbase, GPT4VImage

browser = Browserbase()
screenshot = browser.screenshot("https://browserbase.com")

# Ready to use image object for Multi-Modal GPT4 use case
gpt4_img = GPT4VImage(screenshot)

By default, the screenshot() method takes a screenshot of the visible viewport.

To take a full-page screenshot, pass the full_page=True option.

The reference of the browserbase package is available on GitHub.