CLI Overview
pb is the command-line interface for PhoneBase — a cloud phone automation platform. It gives you full control over Android cloud devices from your terminal: manage device lifecycle, interact with screens, install apps, transfer files, and run automation skills.
GitHub: https://github.com/phonebase-cloud/phonebase-cli
All output is structured JSON by default when called by AI agents or scripts. In interactive terminals, output is displayed as human-friendly tables and messages.
Global Flags
| Flag | Description |
|---|---|
-s, --device <id> | Target device ID (applies to all commands) |
-j, --json <body> | Pass a JSON body directly to the API |
-f, --file <path> | Read JSON body from a file (- for stdin) |
-V, --version | Print CLI version |
-h, --help | Print help information |
TIP
The -s flag is global -- it works with any command to specify which device to operate on. If omitted, the currently connected device is used.
Environment Variables
| Variable | Description | Example |
|---|---|---|
PHONEBASE_API_KEY | API key for authentication | pb_sk_xxxxxxxxxxxx |
PHONEBASE_API_URL | API gateway URL | https://api.phonebase.cloud |
PHONEBASE_LANG | CLI language (en / zh) | en |
PHONEBASE_OUTPUT | Output format (json / text) | json |
INFO
Environment variables take precedence over config file values.
Temporary (current session only):
# Prepend to a single command
PHONEBASE_OUTPUT=json pb devices
# Or export for the entire session
export PHONEBASE_API_KEY=pb_sk_xxxxxxxxxxxxPermanent (persist across sessions):
echo 'export PHONEBASE_API_KEY=pb_sk_xxxxxxxxxxxx' >> ~/.zshrc
source ~/.zshrcecho 'export PHONEBASE_API_KEY=pb_sk_xxxxxxxxxxxx' >> ~/.bashrc
source ~/.bashrcOutput Format
pb automatically detects who is calling — human or AI — and adjusts the output format accordingly.
| Who | Format | Force |
|---|---|---|
| Human | Friendly tables and colored messages | PHONEBASE_OUTPUT=text |
| AI | Structured JSON | PHONEBASE_OUTPUT=json |
For example, pb devices outputs differently depending on the caller:
Human sees:
CODE STATUS ONLINE CONNECTED STARTED_AT
IDY291LX6WW6RCW running yes yes 2025-01-15T08:30:00Z
IDY2A0ZNVOR00ZK stopped no - -AI sees:
{
"code": 200,
"data": {
"devices": [
{
"device_code": "IDY291LX6WW6RCW",
"plex_status": "running",
"is_online": true,
"connected": true,
"started_at": "2025-01-15T08:30:00Z"
}
]
},
"msg": "OK"
}