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

# Get Started with Browser-Use

> Learn how to use Browser-Use with Cerebras to enable AI agents to control web browsers for automated navigation, form filling, data extraction, and complex multi-step workflows.

Browser-Use is an open-source project that empowers AI agents to control web browsers, enabling tasks such as automated web navigation, form filling, data extraction, and complex multi-step workflows. By combining Browser-Use with Cerebras's ultra-fast inference, you can build responsive browser automation agents that execute tasks in real-time.

## Prerequisites

Before you begin, ensure you have:

* **Cerebras API Key** - Get a free API key [here](https://cloud.cerebras.ai/?utm_source=3pi_browser-use\&utm_campaign=partner_doc)
* **Python 3.11 or higher** - Browser-Use requires Python 3.11+ for optimal performance
* **Playwright** - Browser-Use uses Playwright for browser automation
* **Basic understanding of async Python** - Browser-Use uses asyncio for concurrent operations

> [!NOTE]
>
> Browser-Use works well with fast inference providers like Cerebras. Use `gpt-oss-120b` for current production browser-control workloads.

## Configure Browser-Use

**1. Install required dependencies**

First, install Browser-Use and its dependencies. Browser-Use will automatically install Playwright and other required packages:

```bash theme={null}
pip install browser-use python-dotenv langchain-openai playwright
```

After installation, install the Playwright browsers. This downloads the necessary browser binaries (Chromium, Firefox, WebKit) that Playwright will use for automation:

```bash theme={null}
playwright install
```

**2. Configure environment variables**

Create a `.env` file in your project directory to store your API credentials securely. This keeps your API key out of your source code:

```bash theme={null}
CEREBRAS_API_KEY=your-cerebras-api-key-here
```

The `python-dotenv` package (installed in Step 1) will load these variables automatically when you call `load_dotenv()`.

**3. Initialize the Browser-Use agent**

Browser-Use integrates seamlessly with any OpenAI-compatible API. Set up a Browser-Use agent with Cerebras to leverage ultra-fast inference for browser automation:

```python Python theme={null}
import os
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from browser_use import Agent

# Load environment variables
load_dotenv()

# Wrapper class for browser-use compatibility with LangChain
class CerebrasLLM:
    def __init__(self, model="gpt-oss-120b"):
        self.llm = ChatOpenAI(
            model=model,
            api_key=os.getenv("CEREBRAS_API_KEY"),
            base_url="https://api.cerebras.ai/v1",
            default_headers={"X-Cerebras-3rd-Party-Integration": "browser-use"}
        )
        self.model = model
        self.model_name = model
        self.provider = "cerebras"
    
    async def ainvoke(self, *args, **kwargs):
        return await self.llm.ainvoke(*args, **kwargs)

# Initialize Cerebras LLM
llm = CerebrasLLM()

# Create the Browser-Use agent
agent = Agent(
    task="Go to google.com and search for 'Cerebras AI'",
    llm=llm,
)
```

```javascript JavaScript theme={null}
import { ChatOpenAI } from "@langchain/openai";
import { Agent } from "browser-use";

// Initialize Cerebras client
const llm = new ChatOpenAI({
    modelName: "gpt-oss-120b",
    openAIApiKey: process.env.CEREBRAS_API_KEY,
    configuration: {
        baseURL: "https://api.cerebras.ai/v1",
        defaultHeaders: {
            "X-Cerebras-3rd-Party-Integration": "browser-use"
        }
    }
});

// Create the Browser-Use agent
const agent = new Agent({
    task: "Go to google.com and search for 'Cerebras AI'",
    llm: llm,
});
```

This creates an agent that will use Cerebras's gpt-oss-120b model to make decisions about browser actions. The agent can navigate websites, click elements, fill forms, and extract information based on your task description.

**4. Run your first browser automation task**

Now let's run a simple browser automation task. This example navigates to Wikipedia:

```python theme={null}
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from browser_use import Agent

load_dotenv()

# Wrapper class for browser-use compatibility with LangChain
class CerebrasLLM:
    def __init__(self, model="gpt-oss-120b"):
        self.llm = ChatOpenAI(
            model=model,
            api_key=os.getenv("CEREBRAS_API_KEY"),
            base_url="https://api.cerebras.ai/v1",
            default_headers={"X-Cerebras-3rd-Party-Integration": "browser-use"}
        )
        self.model = model
        self.model_name = model
        self.provider = "cerebras"
    
    async def ainvoke(self, *args, **kwargs):
        return await self.llm.ainvoke(*args, **kwargs)

# Initialize Cerebras LLM
llm = CerebrasLLM()

# Create agent with a task - run with: await agent.run()
# agent = Agent(task="Go to wikipedia.org", llm=llm)
```

The agent will open a browser window and navigate to Wikipedia. With Cerebras's fast inference, navigation decisions happen in milliseconds.

> [!NOTE]
>
> You may see some internal "items" errors in the browser-use logs - these are harmless and don't affect navigation functionality. This is a known issue in browser-use v0.9.5 that will be fixed in future versions.

**5. Extract structured data from websites**

You can navigate to different websites easily. Here's an example that navigates to the Cerebras website:

```python theme={null}
import os
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from browser_use import Agent

load_dotenv()

# Wrapper class for browser-use compatibility with LangChain
class CerebrasLLM:
    def __init__(self, model="gpt-oss-120b"):
        self.llm = ChatOpenAI(
            model=model,
            api_key=os.getenv("CEREBRAS_API_KEY"),
            base_url="https://api.cerebras.ai/v1",
            default_headers={"X-Cerebras-3rd-Party-Integration": "browser-use"}
        )
        self.model = model
        self.model_name = model
        self.provider = "cerebras"
    
    async def ainvoke(self, *args, **kwargs):
        return await self.llm.ainvoke(*args, **kwargs)

async def navigate_cerebras():
    llm = CerebrasLLM(model="gpt-oss-120b")
    
    agent = Agent(
        task="Go to cerebras.ai",
        llm=llm,
    )
    
    result = await agent.run()
    print("Navigation completed")

if __name__ == "__main__":
    asyncio.run(navigate_cerebras())
```

> [!NOTE]
>
> Cerebras's gpt-oss-120b model is excellent for structured data extraction tasks due to its strong reasoning capabilities and fast inference speed.

**6. Customize browser behavior**

You can navigate to multiple pages in sequence. This example shows navigation to GitHub:

```python theme={null}
import os
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from browser_use import Agent

load_dotenv()

# Wrapper class for browser-use compatibility with LangChain
class CerebrasLLM:
    def __init__(self, model="gpt-oss-120b"):
        self.llm = ChatOpenAI(
            model=model,
            api_key=os.getenv("CEREBRAS_API_KEY"),
            base_url="https://api.cerebras.ai/v1",
            default_headers={"X-Cerebras-3rd-Party-Integration": "browser-use"}
        )
        self.model = model
        self.model_name = model
        self.provider = "cerebras"
    
    async def ainvoke(self, *args, **kwargs):
        return await self.llm.ainvoke(*args, **kwargs)

async def navigate_github():
    llm = CerebrasLLM()
    
    agent = Agent(
        task="Go to github.com",
        llm=llm,
    )
    
    result = await agent.run()
    print("Navigation completed")

if __name__ == "__main__":
    asyncio.run(navigate_github())
```

The agent will automatically handle browser initialization. With Cerebras's ultra-fast inference, the agent can quickly navigate between pages.

**7. Build multi-step workflows**

You can chain multiple navigation tasks together. This example demonstrates navigating to multiple pages in sequence:

```python theme={null}
import os
import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from browser_use import Agent

load_dotenv()

# Wrapper class for browser-use compatibility with LangChain
class CerebrasLLM:
    def __init__(self, model="gpt-oss-120b"):
        self.llm = ChatOpenAI(
            model=model,
            api_key=os.getenv("CEREBRAS_API_KEY"),
            base_url="https://api.cerebras.ai/v1",
            default_headers={"X-Cerebras-3rd-Party-Integration": "browser-use"}
        )
        self.model = model
        self.model_name = model
        self.provider = "cerebras"
    
    async def ainvoke(self, *args, **kwargs):
        return await self.llm.ainvoke(*args, **kwargs)

async def multi_step_workflow():
    llm = CerebrasLLM()
    
    # Navigate to multiple pages
    pages = ["wikipedia.org", "cerebras.ai", "github.com", "python.org"]
    
    for page in pages:
        agent = Agent(
            task=f"Go to {page}",
            llm=llm,
        )
        await agent.run()
        print(f"Navigated to {page}")
    
    print("All navigations completed")

if __name__ == "__main__":
    asyncio.run(multi_step_workflow())
```

Cerebras's fast inference enables multi-page navigation to complete quickly, making it practical to build efficient browser automation workflows.

## Why Use Cerebras with Browser-Use?

Cerebras's ultra-fast inference provides several key advantages for browser automation:

* **Real-time responsiveness** - Sub-second inference enables agents to react instantly to page changes and dynamic content
* **Complex reasoning** - Models like gpt-oss-120b can handle sophisticated multi-step workflows and make intelligent decisions
* **Cost-effective** - Fast inference means lower costs for long-running automation tasks and reduced API usage
* **Reliable execution** - Low latency reduces timeouts and improves task completion rates, especially for time-sensitive operations
* **Better user experience** - Near-instantaneous responses make browser automation feel natural and responsive

## Available Models

Browser-Use works with all Cerebras models for browser automation:

| Model | Parameters | Best For |
| - | - | - |
| **gpt-oss-120b** | 120B | Production text, coding, and tool-use workloads |
| **gemma-4-31b** | 31B | Preview multimodal workloads with text and image input |

Change the `model` parameter in your `CerebrasLLM` initialization to switch between models.

## Next Steps

* Explore the [Browser-Use documentation](https://docs.browser-use.com/introduction/?utm_source=3pi_browser-use\&utm_campaign=partner_doc) for advanced features like custom actions and browser contexts
* Try different [Cerebras models](https://inference-docs.cerebras.ai/models) to optimize for speed vs. reasoning capability
* Build multi-agent workflows that combine browser automation with other tools
* Check out [Browser-Use examples](https://github.com/browser-use/browser-use/tree/main/examples?utm_source=3pi_browser-use\&utm_campaign=partner_doc) for inspiration and real-world use cases
* Learn about [LangChain integration](https://inference-docs.cerebras.ai/integrations/langchain.md) for more advanced agent orchestration
* [Cerebras model catalog](https://inference-docs.cerebras.ai/models/overview)

## Troubleshooting

> [accordion] Agent is not finding elements on the page
>
> If the agent struggles to locate page elements:
>
> 1. **Be more specific** - Provide detailed descriptions of elements in your task (e.g., "the blue submit button in the top right")
> 2. **Wait for page load** - Some dynamic sites need time to render; add explicit wait instructions in your task
> 3. **Simplify selectors** - Use clear, unique identifiers when possible (e.g., "the search box with placeholder 'Enter query'")
> 4. **Check for dynamic content** - Some elements may load via JavaScript; ensure the page is fully loaded before interaction

> [accordion] ImportError: cannot import name 'Agent' from 'browser\_use'
>
> This usually means Browser-Use wasn't installed correctly:
>
> ```bash theme={null}
> pip uninstall browser-use
> pip install browser-use --upgrade
> playwright install
> ```
>
> Make sure you're using Python 3.11 or higher. You can check your Python version with:
>
> ```bash theme={null}
> python --version
> ```
>
> If you're using an older version, consider using pyenv or conda to install Python 3.11+.

> [accordion] How do I handle authentication and cookies?
>
> Browser-Use can handle authenticated sessions. The agent automatically manages browser contexts and can persist sessions across runs. For sites that require authentication, you can:
>
> 1. Let the agent handle the login flow as part of its task
> 2. Use browser profiles to persist login state
> 3. Pass cookies or session tokens programmatically
>
> Example of including login in the task:
>
> ```python theme={null}
> import os
> from langchain_openai import ChatOpenAI
> from browser_use import Agent
>
> # Wrapper class for browser-use compatibility
> class CerebrasLLM:
>     def __init__(self, model="gpt-oss-120b"):
>         self.llm = ChatOpenAI(
>             model=model,
>             api_key=os.getenv("CEREBRAS_API_KEY"),
>             base_url="https://api.cerebras.ai/v1",
>             default_headers={"X-Cerebras-3rd-Party-Integration": "browser-use"}
>         )
>         self.model = model
>         self.model_name = model
>         self.provider = "cerebras"
>
>     async def ainvoke(self, *args, **kwargs):
>         return await self.llm.ainvoke(*args, **kwargs)
>
> llm = CerebrasLLM()
>
> agent = Agent(
>     task="Go to example.com, log in with username 'user@example.com' and password from environment, then navigate to dashboard",
>     llm=llm,
> )
> ```

> [accordion] Can I use Browser-Use with streaming responses?
>
> Yes! Browser-Use works with Cerebras's streaming API for real-time feedback:
>
> ```python theme={null}
> import os
> from langchain_openai import ChatOpenAI
>
> # Wrapper class for browser-use compatibility with LangChain
> class CerebrasLLM:
>     def __init__(self, model="gpt-oss-120b", streaming=False):
>         self.llm = ChatOpenAI(
>             model=model,
>             api_key=os.getenv("CEREBRAS_API_KEY"),
>             base_url="https://api.cerebras.ai/v1",
>             streaming=streaming,
>             default_headers={"X-Cerebras-3rd-Party-Integration": "browser-use"}
>         )
>         self.model = model
>         self.model_name = model
>         self.provider = "cerebras"
>
>     async def ainvoke(self, *args, **kwargs):
>         return await self.llm.ainvoke(*args, **kwargs)
>
> llm = CerebrasLLM(streaming=True)
> ```
>
> Streaming is particularly useful for long-running tasks where you want to see the agent's reasoning in real-time. Learn more about [streaming with Cerebras](https://inference-docs.cerebras.ai/api-reference/chat-completions.md#streaming).

> [accordion] What's the difference between headless and headed mode?
>
> **Headless mode** (`headless=True`, default):
>
> * Browser runs in the background without a visible window
> * Faster execution and lower resource usage
> * Ideal for production environments and automated pipelines
>
> **Headed mode** (`headless=False`):
>
> * Browser window is visible on your screen
> * Useful for debugging and development
> * Allows you to see exactly what the agent is doing
>
> For development, start with headed mode to understand the agent's behavior, then switch to headless mode for production deployments.

## Additional Resources

* [Browser-Use GitHub Repository](https://github.com/browser-use/browser-use?utm_source=3pi_browser-use\&utm_campaign=partner_doc) - Source code, examples, and community discussions
* [Browser-Use Documentation](https://docs.browser-use.com/?utm_source=3pi_browser-use\&utm_campaign=partner_doc) - Comprehensive guides and API reference
* [Cerebras Model Documentation](https://inference-docs.cerebras.ai/models) - Learn about available models and their capabilities
* [Chat Completions API Reference](https://inference-docs.cerebras.ai/api-reference/chat-completions.md) - Detailed API documentation
* [LangChain Integration Guide](https://inference-docs.cerebras.ai/integrations/langchain.md) - Build more complex agent workflows
* [Playwright Documentation](https://playwright.dev/python/?utm_source=3pi_browser-use\&utm_campaign=partner_doc) - Learn about browser automation capabilities
