# Using awx (awanbox.com) from your terminal

You can use **awx**: cloud computers for AI agents. Each computer is a Linux desktop of its own (Ubuntu 24.04, Xfce, Chrome, Python 3, Node.js, git) with a disk that stays. You control it from this terminal with the `awx` command. A person owns the account and pays for what runs; work for them, carefully.

## Set up
1. Check the command: `awx --version` (0.3.0 or newer). If it is missing, install it with `pipx install https://awanbox.com/sdk/awx-0.3.0-py3-none-any.whl` (Python 3.10 or newer). Without pipx, use a virtual environment: `pip install <same address>` inside one that is active, or `python3 -m venv ~/.awx && ~/.awx/bin/pip install <same address>`, then run `~/.awx/bin/awx`. A plain `pip install` outside a virtual environment is often refused ("externally-managed-environment").
2. Sign in with the person's API key (it starts with `bx_`). Use the `AWX_API_KEY` environment variable if it is set (it wins over a saved login), or a login the person already made (`awx login --key ...`). If `awx whoami` succeeds, a key is in effect; never print the variable to check it. If there is no key, stop and ask the person to make one at https://box.awanbox.com, Account, API keys, and to set `AWX_API_KEY` themselves.
3. Never print, log or commit the key, and never copy it into a computer, a file or a URL.
4. `awx whoami` shows the account: `tier_label` is the plan, `credit` the credit (in Malaysian ringgit), `max_running` how many computers may run at once (null means no limit). Admin accounts have no running limit and are not charged (`credit.exempt` is true).
5. Before making a computer, run `awx --json sandbox list` to see which exist and which are `running`. Use the one the person names; make a new one only when asked or when none fits.

## Commands
A computer can be called by its name or its id. Put `--json` before a command to get JSON; prefer it when you need to read the result.

```
awx --json sandbox list                                 # your computers and their state
awx sandbox create --name NAME [--size small|large]     # a new computer (Small unless you ask for Large)
awx sandbox start NAME | stop NAME                      # a stopped computer keeps its files
awx sandbox exec NAME [--timeout 85] -- COMMAND ARGS    # run as user "agent" (has sudo) in /home/agent
awx sandbox upload NAME LOCAL_FILE /home/agent/FILE
awx sandbox download NAME /home/agent/FILE [LOCAL_FILE]
awx sandbox ls NAME [PATH]  |  awx sandbox cat NAME PATH
awx sandbox preview NAME --port PORT                    # a public https link to a web server in the computer
awx sandbox name NAME LABEL --port PORT                 # a permanent address LABEL.awanbox.com (costs credit)
awx sandbox shot NAME [FILE.png]                        # a screenshot of the desktop (1280 x 800)
awx sandbox click NAME X Y | type NAME "TEXT" | key NAME "ctrl+l"   # mouse and keyboard on the desktop
awx sandbox view NAME [--control]                       # a link for the PERSON to watch or take over the desktop
awx sandbox delete NAME                                 # removes the computer and its files for good
awx chat ask "TASK" --computer NAME                     # hand a task to awx's built-in agent and wait for its answer
```
`awx --help` and `awx sandbox --help` list every command and option.

## How to work
- `exec` exits with the command's own exit code. A command may run for 30 seconds, or up to 85 with `--timeout 85`. Start anything longer in the background and send all its output to a file (`bash -c 'nohup CMD > /tmp/job.log 2>&1 &'`); without the redirection `exec` waits for it until the timeout. Check it later with `exec NAME -- tail /tmp/job.log`.
- To share a web app, start its server inside the computer listening on `0.0.0.0` (not only `127.0.0.1`), in the background, then run `awx sandbox preview`. It gives a random address such as `https://<random>.awanbox.com/`; `awx sandbox name` gives a fixed `LABEL.awanbox.com`. Deleting the computer ends its links. A link made before the server is up shows "Nothing is listening on port N" until it is. On the Free plan a link lasts up to one hour (make a new one when it expires); the paid plan allows longer with `--ttl`. Check the link with `curl` before you give it to the person.
- Use the desktop (`shot`, `click`, `type`, `key`) only when a command cannot do the job, for example a page that needs a browser. `shot` captures the desktop as it is; to show a page, open it in Chrome inside the computer first (`awx sandbox exec NAME -- bash -c 'DISPLAY=:0 nohup chrome http://localhost:8000 >/dev/null 2>&1 &'`; `chrome` starts Google Chrome with the options a container needs, and its yellow "--no-sandbox" banner is expected), wait a few seconds, then take the screenshot. Take a screenshot before and after you act. If Chrome asks you to accept Google's terms when it starts, accept them yourself: Chrome on an awx computer is there for you to use. This covers only Chrome's own start-up terms, not accounts, sign-ups or purchases on websites.
- The computer is a container. There is no systemd (`systemctl`, `service`, snap), no Docker inside it, no VPN, no mounting, no GPU, and cron is not running. Keep long-running programs alive with supervisor: a file in `/etc/supervisor/conf.d/`, then `sudo supervisorctl update`.
- Files stay on the computer's disk between sessions. Download anything the person must keep.

## Costs and limits
- On the Free plan a running computer uses credit by the minute: Small RM0.03 an hour, Large RM0.10 an hour. Stop a computer when the work is done, unless the person wants it running.
- Making a computer costs nothing, and an account can have two. Credit (in Malaysian ringgit, RM) is used only while a computer runs. Reuse a computer when you can.
- Up to three computers can run at once (admins: no limit).
- Rate limits: 600 requests a minute per key, and 20 new computers, starts, chats or agent messages a minute. On the error code `rate_limited`, wait the number of seconds in `Retry-After`, then try again.

## Ask the person first
- Before deleting a computer or files (`delete` does not ask for confirmation and cannot be undone), making a permanent name (it costs credit), making more than one computer, or anything public or hard to undo.
- Never type passwords, codes or card numbers yourself. Give the person the link from `awx sandbox view NAME --control`, let them type it on the desktop, and wait until they say they are done.

## Errors
Errors are JSON: `{"error": {"code": "...", "message": "..."}}`. Common codes: `unauthorized` (the key is missing, wrong or revoked), `not_found`, `conflict` (for example a name that is taken), `quota_exceeded`, `forbidden` (not on this plan), `rate_limited`. Read the message and act on it; do not retry the same call blindly.

## Other ways in
- MCP: `https://mcp.awanbox.com/mcp` with the header `Authorization: Bearer <key>`.
- HTTP API: `https://api.awanbox.com/v2/...` with the same header; it is what the command uses.
- Docs: https://awanbox.com/docs/sdk/
