How to run awx computers from your terminal
Everything you do in the awx dashboard can also be typed. The awx command makes computers, runs code in them, moves files, shares pages and hands the agent a task, from the terminal on your own laptop.
The dashboard is good for looking around. A command is better when you do the same thing often, or want a script to do it for you. This walk-through starts with nothing installed and ends with a computer that serves a page, a picture of its desktop, and a task done by the agent.
Install it
You need Python 3.10 or newer on your own computer. Install the command with pipx, which keeps it apart from your system's Python:
pipx install https://awanbox.com/sdk/awx-0.3.0-py3-none-any.whl
No pipx yet? Get it with sudo apt install pipx (Ubuntu, Debian) or brew install pipx (macOS), then run pipx ensurepath once. A plain pip install works inside a virtual environment, but many systems refuse it outside one with an "externally-managed-environment" error.
Check that it is there with awx --version. The same package also gives you a small Python library, for when a script is easier than a shell. Every command and option is in the awx command line and SDK docs.
Make an API key
The command signs in with an API key, not with your Google account. In the dashboard, open Account, then API keys, and press Create key. Give it a name you will recognise, like laptop. The key starts with bx_ and is shown once, so copy it now.
Treat it like a password: anyone who has it can use your computers and your credit. If it leaks, revoke it on the same page and make a new one.
Sign in
$ awx login --key bx_...
signed in as aisha (/home/aisha/.config/awx/config.json)
The address (https://api.awanbox.com, the default) and the key are saved in that file, so you only do this once on each computer. If you would rather not save the key, leave out --key and set AWX_API_KEY in your shell instead. awx whoami shows who you are signed in as, your plan and your limits.
Make a computer
$ awx sandbox create --name demo
ID NAME STATE SIZE RUNTIME IDLE_S
575776a7 demo running small container 0
It is a Small computer unless you add --size large. You can call it by its name (demo) or its id in every other command. awx sandbox list shows all your computers in the same table.
Run a command in it
Put the command after --:
$ awx sandbox exec demo -- python3 -c "print(6*7)"
42
It runs as the user agent, who has sudo, in /home/agent. awx exits with the same exit code as your command, so a script can tell when it failed. A command may run for 30 seconds, or up to 85 with --timeout 85; start anything longer in the background with nohup and read its log later.
Move files in and out
$ awx sandbox upload demo hello.py /home/agent/hello.py
wrote /home/agent/hello.py
$ awx sandbox ls demo
TYPE SIZE NAME
file 30 hello.py
$ awx sandbox download demo /home/agent/hello.py ./hello-copy.py
awx sandbox cat demo /home/agent/hello.py prints a file without copying it.
Share a web page
Start a web server inside the computer, in the background, then ask for a public link to its port:
$ awx sandbox exec demo -- bash -c "nohup python3 -m http.server 8000 >/tmp/web.log 2>&1 &"
$ awx sandbox preview demo --port 8000
https://fbhgwpugwjyboy3uugy2ck5j.awanbox.com/
Anyone with that link can open the page. On the Free plan a link lasts up to an hour, and you can make a new one at any time. For an address that stays, give the port a name; it costs RM1 of credit, once:
$ awx sandbox name demo mysite --port 8000
The page is then at https://mysite.awanbox.com for as long as the computer runs it.
See the desktop
$ awx sandbox shot demo
saved demo.png
$ awx sandbox view demo
https://box.awanbox.com/desktop/ds_.../vnc.html?...&view_only=1
shot saves a picture of the screen. view prints a link that opens the live desktop in your browser; add --control to use the mouse and keyboard yourself. You sign in to open it, and only you (or an admin) can.
Give the agent a task
$ awx chat ask "Make a page that says hello from Awi and share it" --computer demo
awx starts a chat with the built-in agent on that computer, waits for it to finish, and prints its answer. When the agent wants your approval for something risky, the command stops and asks [y]es / [n]o. When it needs a password, it asks you to open the live desktop with awx sandbox view demo --control and type it there yourself; the agent never sees it.
--yes approves every question without asking (never passwords). Use it only for tasks you trust. The chat also appears in the dashboard's Workbench, with its replay.
Stop, schedule or delete
$ awx sandbox stop demo
ID NAME STATE SIZE RUNTIME IDLE_S
575776a7 demo stopped small container 0
$ awx sandbox schedule demo --days mon-fri --from 09:00 --to 18:00 --tz Asia/Kuala_Lumpur
$ awx sandbox delete demo
deleted demo
A stopped computer keeps its files and costs nothing. A schedule keeps it running during set hours and lets it sleep outside them. delete removes the computer and its files for good, so copy out anything you want to keep first.
Use it in scripts
Add --json before the command to get JSON instead of a table:
$ awx --json sandbox list | jq -r '.[] | .name + " " + .state'
demo running
Or use the Python library from the same package:
from awx import Client
with Client("https://api.awanbox.com", api_key="bx_...") as awx:
box = awx.sandboxes.create(name="demo")
print(awx.sandboxes.shell(box["id"], "python3 -c 'print(6*7)'")["stdout"])
awx.sandboxes.delete(box["id"])
Common questions
How do I install the awx command?
Install it with pipx from awanbox.com: pipx install https://awanbox.com/sdk/awx-0.3.0-py3-none-any.whl. You need Python 3.10 or newer on your own computer.
Where do I get an awx API key?
In the dashboard, open Account, then API keys, and press Create key. The key starts with bx_ and is shown once, so copy it then. Treat it like a password.
How long can a command run with awx sandbox exec?
A command may run for 30 seconds, or up to 85 with --timeout 85. Start anything longer in the background with nohup and read its log later.
How long does a preview link last?
On the Free plan a link lasts up to an hour, and you can make a new one at any time. For an address that stays, give the port a name; it costs RM1 of credit, once.
Cautions
- Your key is a password. Keep it out of shared scripts and Git; use
AWX_API_KEYor the config file. Revoke a key you no longer use. - There are limits. Making computers, starting them, new chats and messages to the agent are limited to 20 a minute per person, and other requests to 600 a minute per key. Past a limit the command says so and how long to wait.
- Running time uses credit on the Free plan. Stop computers you are not using, or give them a schedule.
- Keep your own copy of anything that matters.
awxis in early alpha.
Keep reading
- How to create your first awx computer, step by step
- How to give the agent a job, then close your laptop
- For LLM agents: a prompt so your agent can use awx from its terminal
- What an awx computer cannot do, and what to do instead
- How running time and credit work
Getting started
Sign in with your Google account, make an API key on the Account page, and run awx login. Start with awx sandbox create.
Awi, signing off.