Browser Use
A Browser Use agent, on your own OpenAI key, drives a Boxline session's browser. Nothing is launched on your computer.
How it works
Browser(cdp_url=session.connect_url, keep_alive=True) and Agent(task=..., llm=ChatOpenAI(...), browser=browser). Newer OpenAI models take only their default temperature: pass temperature=None, frequency_penalty=None. At the end, await browser.stop() (it disconnects without closing the browser), then stop the session; stopping it first leaves Browser Use trying to reconnect.
| Needs | any plan; your own OpenAI key; Python 3.11 or newer. |
|---|---|
| Site | books.toscrape.com or quotes.toscrape.com, demo sites made for scraping practice. |
| Environment | BOXLINE_API_KEY, OPENAI_API_KEY (your OpenAI key: Browser Use calls OpenAI itself), BU_MODEL (the OpenAI model; default gpt-6-luna), TASK (your own task). |
| Packages | boxline-sdk, browser-use==0.13.10 |
The code
"""Browser Use with Boxline: a Browser Use agent (on your own OpenAI key) drives a Boxline session's browser,connected by its CDP address (`Browser(cdp_url=...)`). Nothing is launched on this computer. pip install -r requirements.txt && python main.py (BOXLINE_API_KEY and OPENAI_API_KEY; BU_MODEL, TASK)Writes output/result.json: the answer, the pages visited and the number of steps."""import asyncioimport jsonimport osfrom pathlib import Pathfrom browser_use import Agent, Browser, ChatOpenAIfrom boxline import AsyncBoxlineout = Path(os.environ.get("OUTPUT_DIR", "output"))task = os.environ.get("TASK", "Open https://books.toscrape.com, go to the Poetry category, and tell me the title and price of the cheapest book in it.")async def main() -> None: async with AsyncBoxline() as bx: # keep_alive on both sides: the session stays up while Browser Use connects, until it is stopped below. session = await bx.sessions.create(timeout=600, keep_alive=True, user_metadata={"example": "integrations/browser-use"}) print(f"Session: {session.id}", flush=True) browser = Browser(cdp_url=session.connect_url, keep_alive=True) # a signed address: treat it like a password try: # Newer OpenAI models take only their default temperature: leave Browser Use's sampling settings unset. llm = ChatOpenAI(model=os.environ.get("BU_MODEL", "gpt-6-luna"), temperature=None, frequency_penalty=None) agent = Agent(task=task, llm=llm, browser=browser) history = await agent.run(max_steps=25) answer = history.final_result() or "" print(f"\n{answer}") out.mkdir(parents=True, exist_ok=True) result = {"task": task, "answer": answer, "done": history.is_done(), "successful": history.is_successful(), "steps": history.number_of_steps(), "urls": [u for u in history.urls() if u]} (out / "result.json").write_text(json.dumps(result, indent=2, ensure_ascii=False)) finally: await browser.stop() # disconnects Browser Use (the browser itself keeps running)... await session.stop() # ...until the session is stopped: that saves it and ends its billingasyncio.run(main())Install and run
The packages are pinned at the versions the example’s check ran with. It writes to output/ and stops its session when it finishes.
# Python 3.11 or newerexport BOXLINE_API_KEY=… # your Boxline API keyexport OPENAI_API_KEY=… # your own OpenAI keypip install boxline-sdk browser-use==0.13.10python main.pyWhat its check proves
It checks that the agent finished, opened books.toscrape.com, and named the cheapest Poetry book and its price, checked against the site's own page. To run it from a clone of the examples (git clone https://github.com/Boxline-dev/examples.git), go to examples/integrations/browser-use, run the commands above, then check the result from the same folder: npx tsx check.ts output.
Source: github.com/Boxline-dev/examples/integrations/browser-use on GitHub. See all integrations.
These docs describe a beta API. Endpoints, fields and SDK methods may change before general availability; breaking changes will be listed in the changelog.