Skip to main content

Live Browser View

@sandbox(on_browser_created=lambda data: print(f'👁️  {data.live_url}'))
async def task(browser: Browser):
    agent = Agent(task="your task", browser=browser, llm=ChatBrowserUse())
    await agent.run()

All Events

from browser_use.sandbox import BrowserCreatedData, LogData, ResultData, ErrorData

@sandbox(
    on_browser_created=lambda data: print(f'Live: {data.live_url}'),
    on_log=lambda log: print(f'{log.level}: {log.message}'),
    on_result=lambda result: print('Done!'),
    on_error=lambda error: print(f'Error: {error.error}'),
)
async def task(browser: Browser):
    # Your code
All callbacks can be sync or async.