> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add web browsing capabilities to Browser Use

> Integrate Browserbase with Browser Use

<Steps titleSize="h3">
  <Step title="Get your API key">
    Visit the [Dashboard's Overview tab](https://www.browserbase.com/overview):

    <Frame>
      <img src="https://mintcdn.com/browserbase/giE_cpy18f2mWHqr/images/quickstart/api_key.png?fit=max&auto=format&n=giE_cpy18f2mWHqr&q=85&s=4ac94a8f69cec20bd17b2a8788169062" width="3410" height="1864" data-path="images/quickstart/api_key.png" />
    </Frame>

    Then copy and set the `BROWSERBASE_API_KEY` environment variable in your `.env` file.
  </Step>

  <Step title="Install and create a virtual environment with UV">
    [UV](https://docs.astral.sh/uv/getting-started/installation/) is a modern package manager for Python.

    ```bash theme={null}
    uv venv
    ```
  </Step>

  <Step title="Install Browserbase and Browser Use">
    ```bash theme={null}
    source .venv/bin/activate # follow the `uv venv` output
    uv pip install browserbase browser-use python-dotenv
    ```
  </Step>

  <Step title="Create the automation script">
    Browser Use provides a simple `Browser` class that accepts a CDP URL from Browserbase. Create a `main.py` file:

    ```python main.py theme={null}
    import asyncio
    import os
    from dotenv import load_dotenv

    from browserbase import Browserbase
    from browser_use import Agent, Browser, BrowserProfile, ChatAnthropic

    load_dotenv()


    async def main():
        bb = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"])
        session = bb.sessions.create()

        print(f"Session ID: {session.id}")
        print(f"Debug URL: https://www.browserbase.com/sessions/{session.id}")

        browser = Browser(
            browser_profile=BrowserProfile(cdp_url=session.connect_url)
        )

        llm = ChatAnthropic(model="claude-sonnet-4-6")

        agent = Agent(
            task=(
                "Go to https://www.macrumors.com/contact.php and fill in the form. "
                "Make sure to use the selectors and submit the form"
            ),
            llm=llm,
            browser=browser,
        )

        result = await agent.run()
        print(f"Result: {result}")

        await browser.stop()


    if __name__ == "__main__":
        asyncio.run(main())
    ```
  </Step>

  <Step title="Run your script">
    Run your script:

    ```bash theme={null}
    uv run main.py
    ```

    You should see your Browserbase session start in [Browserbase](https://www.browserbase.com/sessions). The debug URL prints to the console for real-time session monitoring.

    <Note>
      **Important environment variables**

      Make sure you have these environment variables in your `.env` file:

      * `BROWSERBASE_API_KEY`
      * `ANTHROPIC_API_KEY` (or another LLM provider key)

      **Notes**

      * The `BrowserProfile(cdp_url=...)` connects to your Browserbase session via CDP
      * Browser Use handles browser lifecycle, Playwright management, and cleanup automatically
      * You can configure the LLM by passing a `llm` parameter to `Agent` (e.g. `ChatAnthropic`, `ChatOpenAI`)
      * Reach out at [support@browserbase.com](mailto:support@browserbase.com) for additional support
    </Note>
  </Step>
</Steps>

<CardGroup cols={1}>
  <Card title="Browserbase and Browser Use sample code" icon="book" iconType="sharp-solid" href="https://github.com/browserbase/integrations/tree/master/examples/integrations/browser-use">
    Configure Browserbase to add additional web-browsing capabilities to your
    Browser Use.
  </Card>
</CardGroup>
