Skip to content

Browser agent

Use a template with a screen: desktop or corvo-computer. Sandbox.create() with no template already creates a desktop in the beta.

from e2b import Sandbox
sandbox = Sandbox.create("desktop", timeout=60 * 60)
print(sandbox.sandbox_id)

In the Dashboard, open the machine and click Open desktop. Or from the CLI:

Janela do terminal
rookbox desktop <id>

You see Chromium and what the agent does in it, live. You can also take over the mouse and keyboard.

Install what the agent needs and run it like any other command:

sandbox.commands.run("pip install playwright && playwright install chromium", timeout=300)
sandbox.files.write("/home/user/agent.py", open("agent.py").read())
sandbox.commands.run("python3 /home/user/agent.py", background=True)

If the site asks for a login or CAPTCHA, sign in yourself through the desktop. The agent continues with the open session. To keep that session while you wait, suspend the machine.

  • The desktop is yours: everything logged in on it stays on the machine. Remove it with kill() when you are done.
  • The machine’s internet is open. See Security.