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.
Use this file to discover all available pages before exploring further.
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.
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
Browser-Use works best with fast inference providers like Cerebras. The ultra-low latency of Cerebras models (gpt-oss-120b, llama3.1-8b) enables near-instantaneous browser control decisions, making your automation agents significantly more responsive.
After installation, install the Playwright browsers. This downloads the necessary browser binaries (Chromium, Firefox, WebKit) that Playwright will use for automation:
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:
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:
import osimport asynciofrom dotenv import load_dotenvfrom langchain_openai import ChatOpenAIfrom browser_use import Agent# Load environment variablesload_dotenv()# Wrapper class for browser-use compatibility with LangChainclass 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 LLMllm = CerebrasLLM()# Create the Browser-Use agentagent = 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:
import osfrom dotenv import load_dotenvfrom langchain_openai import ChatOpenAIfrom browser_use import Agentload_dotenv()# Wrapper class for browser-use compatibility with LangChainclass 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 LLMllm = 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.
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:
Make sure you’re using Python 3.11 or higher. You can check your Python version with:
python --version
If you’re using an older version, consider using pyenv or conda to install Python 3.11+.
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:
Let the agent handle the login flow as part of its task
Use browser profiles to persist login state
Pass cookies or session tokens programmatically
Example of including login in the task:
import osfrom langchain_openai import ChatOpenAIfrom browser_use import Agent# Wrapper class for browser-use compatibilityclass 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,)
Can I use Browser-Use with streaming responses?
Yes! Browser-Use works with Cerebras’s streaming API for real-time feedback:
import osfrom langchain_openai import ChatOpenAI# Wrapper class for browser-use compatibility with LangChainclass 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.
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.