Browser Use Cloud API
Browser-Use is a Python library that allows you to create browser automation scripts using AI. You can use multiple models such as GPT-4o, DeepSeek, Gemini-2.0, Claude and more. Local models such as Qwen 2.5 are also supported. The library essentially uses a Playwright browser instance to execute tasks on a (remote) browser. You can perform tasks such as:
- Navigate to Google and search for TestingBot
- Go to Reddit and open an article
- Open a new tab and go to CNN
By using the TestingBot remote browser grid, you can run multiple AI agents in parallel without worrying about setting up and managing the browsers yourself.
Additionally, TestingBot records each session with a video, logs and generated metadata are saved as well.
You can run browsers from various geographical locations and use different browser versions, on multiple operating systems.
To install browser use, please follow these steps:
- Install the Browser-Use library:
pip install browser-use - Install the Playwright library:
pip install playwright
Connecting to a remote browser
Please see the example below on how to connect your Browser-Use agent to a remote browser in the TestingBot cloud.
The wss URL points to the TestingBot cloud, where you can specify the browser and platform you want to use. You can also specify the name of the session.
Make sure to replace key and secret with your TestingBot API key and secret.
import json import httpx import os import asyncio import logging from browser_use.browser import BrowserSession from browser_use.agent.service import Agent from browser_use.llm import ChatOpenAI capabilities = { "tb:options": { "name": "Browser Use Example", "key": os.environ["TESTINGBOT_KEY"], "secret": os.environ["TESTINGBOT_SECRET"], }, "browserName": "chrome", "browserVersion": "latest", "platform": "WIN10" } async def create_testingbot_session(): try: async with httpx.AsyncClient(timeout=600.0) as client: response = await client.post( "https://cloud.testingbot.com/session", json={ "capabilities": capabilities }, ) response.raise_for_status() session_data = response.json() logging.info( "TestingBot session created successfully: %s", json.dumps(session_data, indent=2) ) return session_data except Exception as e: logging.error("Failed to create TestingBot session: %s", e) async def main(): session_data = await create_testingbot_session() cdp_url = session_data["cdp_url"] browser_session = BrowserSession(cdp_url=cdp_url) agent = Agent( task="Go to the TestingBot homepage and click the pricing menu item", llm=ChatOpenAI(model="gpt-4o"), browser_session=browser_session, ) try: await agent.run() finally: await browser_session.close() if __name__ == "__main__": asyncio.run(main()) When you run this example, the Browser-Use agent will connect to a remote browser in the TestingBot cloud, and execute the task specified in the task variable.