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

# Browser Use

export const CLICommandTabs = ({command, withOptions = true}) => {
  if (!Array.isArray(command)) {
    command = [command];
  }
  function mapAliases(aliases) {
    return aliases.map((alias, index) => <>
        {alias}
        {index === 0 ? "" : " # Alias"}
        {"\n\n"}
      </>);
  }
  return <CodeGroup>
      <CodeBlock language="general" filename="General">
        {mapAliases(command.map(cmd => `${cmd}${withOptions ? " [options]" : ""}`))}
      </CodeBlock>

      <CodeBlock icon="python" language="uv" filename="uv">
        {mapAliases(command.map(cmd => `uv run ${cmd}${withOptions ? " [options]" : ""}`))}
      </CodeBlock>

      <CodeBlock icon="python" language="poetry" filename="poetry">
        {mapAliases(command.map(cmd => `poetry run ${cmd}${withOptions ? " [options]" : ""}`))}
      </CodeBlock>

      <CodeBlock icon="https://d3gk2c5xim1je2.cloudfront.net/devicon/typescript.svg" language="npm" filename="npm">
        {mapAliases(command.map(cmd => `npm run ${cmd}${withOptions ? " -- [options]" : ""}`))}
      </CodeBlock>

      <CodeBlock icon="https://d3gk2c5xim1je2.cloudfront.net/devicon/typescript.svg" language="yarn" filename="yarn">
        {mapAliases(command.map(cmd => `yarn ${cmd}${withOptions ? " [options]" : ""}`))}
      </CodeBlock>
    </CodeGroup>;
};

## Overview

[Browser Use](https://browser-use.com/) is a Python library for AI-powered browser automation.

This guide walks you through deploying and running a Browser Use based project on Intuned. You'll build a sample automation that purchases a product from an e-commerce site—without writing step-by-step Playwright code. The same patterns apply to any automation you build with the framework.

<Note>
  This guide assumes you have a basic understanding of Intuned projects. If
  you're new to Intuned, start with the [getting started
  guide](/main/00-getting-started/introduction).
</Note>

<Note>Browser Use is Python-only and doesn't support TypeScript.</Note>

## When to use AI automation

Intuned supports AI-powered browser automation frameworks like Browser Use, Stagehand, and others. Use AI automation when:

* **Pages are dynamic** — Elements change position, structure, or content unpredictably
* **You don't know the exact page structure** — Automating sites you haven't mapped in detail
* **You want natural language control** — Describe what to do instead of writing precise selectors
* **Traditional Playwright code is too brittle for your case** — AI agents adapt to minor UI changes automatically

Browser Use is one option for AI automation on Intuned. The setup patterns in this guide apply to other AI frameworks as well.

For a deeper dive into choosing between deterministic, AI-driven, and hybrid approaches, check out [Flexible Automations](/main/02-features/flexible-automation).

## Guide

Let's build a `purchase-item` API with AI agents. The template handles all the Browser Use setup for you.

You can develop with Browser Use in two ways:

* **Hosted projects (online IDE)** — Zero setup. Write, test, and deploy directly from your browser.
* **Connected projects (local CLI)** — Use your favorite IDE with full version control.

<Tabs>
  <Tab title="Hosted project">
    <Steps>
      <Step title="Create a project">
        1. Go to [Intuned dashboard](https://app.intuned.io)
        2. Select **+ New Project** > **Templates** > **Browser Use Template**
        3. Name it and select **Create Project**

        <Frame>
          <img src="https://mintcdn.com/intuned-dev/bhb38akfgMoZ2D8J/assets/integrations/browser-use-create-project.png?fit=max&auto=format&n=bhb38akfgMoZ2D8J&q=85&s=23f094c3731b7c67a1fbcb068aeebb05" alt="Create Browser Use project from template" width="2880" height="2048" data-path="assets/integrations/browser-use-create-project.png" />
        </Frame>
      </Step>

      <Step title="Explore the project">
        The template includes a `purchase-item` API that uses AI agents to purchase products from an e-commerce site.

        **Project structure:**

        ```
        my-browser-use-agent/
        ├── api/
        │   └── purchase-item.py           # Main automation API
        ├── hooks/
        │   └── setup_context.py           # Browser Use initialization
        ├── pyproject.toml                 # Dependencies
        └── intuned.json                   # Project configuration
        ```

        **The automation code:**

        ```python theme={null}
        from playwright.async_api import Page
        from typing import TypedDict
        from browser_use import Agent, ChatOpenAI, Browser, Tools
        from intuned_runtime import attempt_store


        class Params(TypedDict):
            username: str
            password: str
            product_name: str
            first_name: str
            last_name: str
            zip_code: str


        async def automation(page: Page, params: Params | None = None, **_kwargs):
            if params is None:
                raise Exception("params cannot be null")
            browser: Browser = attempt_store.get("browser")

            username = params.get("username")
            password = params.get("password")
            product_name = params.get("product_name")
            first_name = params.get("first_name")
            last_name = params.get("last_name")
            zip_code = params.get("zip_code")

            tools = Tools()

            agent = Agent(
                browser=browser,
                task=f"""1. Go to https://www.saucedemo.com/
        2. Login with username '{username}' and password '{password}'
        3. Find the product '{product_name}' and add it to cart
        4. Go to cart
        5. Proceed to checkout
        6. Fill in the checkout information: First Name: '{first_name}', Last Name: '{last_name}', Zip Code: '{zip_code}'
        7. Complete the purchase""",
                llm=ChatOpenAI(model="gpt-5-nano", temperature=0),
                flash_mode=True,
                tools=tools,
            )

            # Agent will run the task on current browser page
            # Since Browser-use uses CDP directly, the actions done by the agent won't be visible in the Playwright trace
            result = await agent.run()
            print(result)

            # Use the correct AgentHistoryList methods
            return {
                "success": result.is_successful(),
                "is_done": result.is_done(),
                "final_message": result.final_result() or "No result",
                "total_actions": result.number_of_steps(),
                "action_history": result.extracted_content(),
            }
        ```

        <Info>
          **What this does:** Uses an AI agent to autonomously purchase a product from an e-commerce site. Takes login credentials, product name, and checkout details, then navigates through the entire purchase flow using `flash_mode` for optimized performance. Returns detailed execution results. Agent actions won't appear in Playwright traces.
        </Info>
      </Step>

      <Step title="Run your automation">
        Run the AI agent to test your setup.

        1. In the IDE, select **purchase-item** from the API dropdown
        2. Enter the purchase parameters in the params panel
        3. Select **Run**

        <Frame>
          <img src="https://mintcdn.com/intuned-dev/bhb38akfgMoZ2D8J/assets/integrations/browser-use-run-ide.png?fit=max&auto=format&n=bhb38akfgMoZ2D8J&q=85&s=c5797cd0f1fc66632fa300584d04f742" alt="Running Browser Use in IDE" width="2880" height="2048" data-path="assets/integrations/browser-use-run-ide.png" />
        </Frame>
      </Step>

      <Step title="Deploy and test">
        Deploy your automation to Intuned's infrastructure.

        1. In the Online IDE, select **Deploy** in the top-right corner
        2. After deployment completes, go to the project's **Runs** page
        3. Select **Start Run**, then choose `purchase-item` API
        4. Enter purchase parameters and select **Start Run**

        <Frame>
          <img src="https://mintcdn.com/intuned-dev/bhb38akfgMoZ2D8J/assets/integrations/browser-use-run-playground.png?fit=max&auto=format&n=bhb38akfgMoZ2D8J&q=85&s=5e28019c8d765b30710acfa8d10577ec" alt="Running Browser Use agent in Dashboard" width="2880" height="2048" data-path="assets/integrations/browser-use-run-playground.png" />
        </Frame>

        5. After the run completes, view the purchase results

        <Frame>
          <img src="https://mintcdn.com/intuned-dev/bhb38akfgMoZ2D8J/assets/integrations/browser-use-run-result.png?fit=max&auto=format&n=bhb38akfgMoZ2D8J&q=85&s=ea2e58f6fac324cd7c7f3f77564a0b9e" alt="View Browser Use run results" width="2880" height="2048" data-path="assets/integrations/browser-use-run-result.png" />
        </Frame>

        <Tip>
          Learn more about [Runs and how to trigger them programmatically](/main/02-features/runs-single-executions).
        </Tip>
      </Step>
    </Steps>
  </Tab>

  <Tab title="Connected project">
    <Steps>
      <Step title="Create a project">
        Run the following command and select **Python**, then choose the **Browser Use** template:

        ```bash theme={null}
        npx create-intuned-project@latest
        ```

        Then navigate to your project:

        ```bash theme={null}
        cd my-browser-use-agent
        ```
      </Step>

      <Step title="Explore the project">
        The template includes a `purchase-item` API that uses AI agents to purchase products from an e-commerce site.

        **Project structure:**

        ```
        my-browser-use-agent/
        ├── api/
        │   └── purchase-item.py           # Main automation API
        ├── hooks/
        │   └── setup_context.py           # Browser Use initialization
        ├── pyproject.toml                 # Dependencies
        └── intuned.json                   # Project configuration
        ```

        **The automation code:**

        ```python theme={null}
        from playwright.async_api import Page
        from typing import TypedDict
        from browser_use import Agent, ChatOpenAI, Browser, Tools
        from intuned_runtime import attempt_store


        class Params(TypedDict):
            username: str
            password: str
            product_name: str
            first_name: str
            last_name: str
            zip_code: str


        async def automation(page: Page, params: Params | None = None, **_kwargs):
            if params is None:
                raise Exception("params cannot be null")
            browser: Browser = attempt_store.get("browser")

            username = params.get("username")
            password = params.get("password")
            product_name = params.get("product_name")
            first_name = params.get("first_name")
            last_name = params.get("last_name")
            zip_code = params.get("zip_code")

            tools = Tools()

            agent = Agent(
                browser=browser,
                task=f"""1. Go to https://www.saucedemo.com/
        2. Login with username '{username}' and password '{password}'
        3. Find the product '{product_name}' and add it to cart
        4. Go to cart
        5. Proceed to checkout
        6. Fill in the checkout information: First Name: '{first_name}', Last Name: '{last_name}', Zip Code: '{zip_code}'
        7. Complete the purchase""",
                llm=ChatOpenAI(model="gpt-5-nano", temperature=0),
                flash_mode=True,
                tools=tools,
            )

            # Agent will run the task on current browser page
            # Since Browser-use uses CDP directly, the actions done by the agent won't be visible in the Playwright trace
            result = await agent.run()
            print(result)

            # Use the correct AgentHistoryList methods
            return {
                "success": result.is_successful(),
                "is_done": result.is_done(),
                "final_message": result.final_result() or "No result",
                "total_actions": result.number_of_steps(),
                "action_history": result.extracted_content(),
            }
        ```

        <Info>
          **What this does:** Uses an AI agent to autonomously purchase a product from an e-commerce site. Takes login credentials, product name, and checkout details, then navigates through the entire purchase flow using `flash_mode` for optimized performance. Returns detailed execution results. Agent actions won't appear in Playwright traces.
        </Info>
      </Step>

      <Step title="Run locally">
        Test your automation locally:

        <CLICommandTabs command={`intuned dev run api purchase-item '{"username": "standard_user", "password": "secret_sauce", "product_name": "Sauce Labs Backpack", "first_name": "John", "last_name": "Doe", "zip_code": "0000"}'`} withOptions={false} />

        The agent logs in, finds the product, and completes the purchase.
      </Step>

      <Step title="Deploy and test">
        Deploy your automation using the CLI:

        <CLICommandTabs command="intuned dev deploy" withOptions={false} />

        After deployment, test in the Dashboard:

        1. Go to the project's **Runs** page
        2. Select **Start Run**, then choose `purchase-item` API
        3. Enter purchase parameters and select **Start Run**

        <Frame>
          <img src="https://mintcdn.com/intuned-dev/bhb38akfgMoZ2D8J/assets/integrations/browser-use-run-playground.png?fit=max&auto=format&n=bhb38akfgMoZ2D8J&q=85&s=5e28019c8d765b30710acfa8d10577ec" alt="Running Browser Use agent in Dashboard" width="2880" height="2048" data-path="assets/integrations/browser-use-run-playground.png" />
        </Frame>

        4. After the run completes, view the purchase results

        <Frame>
          <img src="https://mintcdn.com/intuned-dev/bhb38akfgMoZ2D8J/assets/integrations/browser-use-run-result.png?fit=max&auto=format&n=bhb38akfgMoZ2D8J&q=85&s=ea2e58f6fac324cd7c7f3f77564a0b9e" alt="View Browser Use run results" width="2880" height="2048" data-path="assets/integrations/browser-use-run-result.png" />
        </Frame>

        <Tip>
          Learn more about [Runs and how to trigger them programmatically](/main/02-features/runs-single-executions).
        </Tip>
      </Step>
    </Steps>
  </Tab>
</Tabs>

## How it works

* The `setup_context` [hook](/main/01-learn/recipes/setup-hooks) runs before your API executes. It creates a Browser instance using Intuned's CDP URL and stores it in [`attemptStore`](/main/05-references/runtime-sdk-python/attempt-store)
* Your API retrieves the Browser instance from `attemptStore` and uses it to create AI agents
* Parameters passed to your API control the agent's behavior. Change these to adjust your automation flow.

<Tip>
  Want to combine Playwright with Browser Use? Use Playwright for deterministic
  steps and Browser Use for AI decision-making. Set `flash_mode=True` to
  optimize costs. Learn more in [Flexible
  Automations](/main/02-features/flexible-automation) and [Structuring Projects
  with AI
  Agents](/main/03-how-to/solve/structure-intuned-projects#ai-agent-automation).
</Tip>

## Related resources

<CardGroup cols={2}>
  <Card title="Browser Use Documentation" icon="book" href="https://docs.browser-use.com">
    Official Browser Use documentation and API reference
  </Card>

  <Card title="Browser Use GitHub" icon="github" href="https://github.com/browser-use/browser-use">
    View the source code and contribute to Browser Use
  </Card>

  <Card title="Intuned Cookbook" icon="code" href="https://github.com/Intuned/cookbook/tree/main/python-examples/browser-use">
    Complete Browser Use example in the Intuned Cookbook
  </Card>

  <Card title="attemptStore Reference" icon="database" href="/main/05-references/runtime-sdk-python/attempt-store">
    Learn more about sharing data between hooks and APIs
  </Card>
</CardGroup>
