Skip to content

Computer automation

What you’ll do

Automate a desktop environment in an AGB session: mouse/keyboard actions, screenshots, application lifecycle, and window management.

Prerequisites

  • AGB_API_KEY
  • A valid computer automation image_id (e.g. agb-computer-use-ubuntu-2204)
  • Permission to create sessions in your account

Quickstart

Minimal runnable example: create a computer session, click, type, take a screenshot, then clean up.

python
from agb import AGB
from agb.session_params import CreateSessionParams
from agb import MouseButton

agb = AGB()
create_result = agb.create(CreateSessionParams(image_id="agb-computer-use-ubuntu-2204"))
if not create_result.success:
    raise SystemExit(f"Session creation failed: {create_result.error_message}")

session = create_result.session

session.computer.click_mouse(x=500, y=300, button=MouseButton.LEFT)
session.computer.input_text("Hello from AGB!")
screenshot_result = session.computer.screenshot()
print("Screenshot URL:", screenshot_result.data)

agb.delete(session)

Common tasks

This topic is large; the detailed API usage has been split into smaller pages:

Best practices

See: docs/computer/best-practices.md

Troubleshooting

See: docs/computer/troubleshooting.md