This guide is dedicated to running your own browser-use agent while connecting to an Anchor browser. To use the embedded browser use capability, refer to AI task completion
{ "data": { "id": "<string>", "cdp_url": "<string>", "live_view_url": "https://live.anchorbrowser.io?sessionId=<session_id>" // Use the live view URL to view the browser session in real-time }}
2
Initialize browser-use with Anchor browser
Copy
Ask AI
from browser_use import Agent, Controllerfrom browser_use.browser import BrowserProfile, BrowserSessionfrom browser_use.llm import ChatOpenAI# Configure your LLM (example with OpenAI)llm = ChatOpenAI( model='gpt-4o', api_key=os.getenv('OPENAI_API_KEY'),)# Create CDP connection URLcdp_url = f'wss://connect.anchorbrowser.io?sessionId={session_id}'# Initialize browser session with Anchorprofile = BrowserProfile(keep_alive=True)browser_session = BrowserSession( headless=False, cdp_url=cdp_url, browser_profile=profile)# Create controller and agentcontroller = Controller()agent = Agent( task="Your task description here", llm=llm, enable_memory=False, use_vision=False, controller=controller, browser_session=browser_session,)# Run the agentresult = await agent.run(max_steps=40)
3
Optional - Live view the browser
Use the live_view_url returned on the first step to view the browser session in real-time, or to embed it as a UI component