CLI automation and output
Run the AI Glot CLI safely in scripts and CI using JSON or NDJSON, environment credentials, profiles, exit codes and bounded retries.
The CLI prints readable tables to a terminal and JSON when output is piped, so the same command works interactively and in automation.
aiglot batches list # table on a terminal
aiglot batches list | jq '.data[0].id' # JSON when piped
aiglot batches list --output ndjson # one object per line
aiglot account --json # explicit JSONFailures go to standard error. Standard output therefore remains safe to pipe into another program.
CI authentication
Create a dedicated, minimum-scope API key and store it in the CI provider’s secret manager:
export AIGLOT_API_KEY="aig_live_…"
aiglot account --jsonThe CLI checks credentials in this order: AIGLOT_API_KEY, OS keychain, then its protected config file.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | API or server error |
| 2 | Invalid command or arguments |
| 3 | Authentication or permission failure |
| 4 | Resource not found |
| 5 | Rate limited |
| 6 | Resource state conflict |
Scripts should branch on the exit code or structured error.code, not error-message text.
Retries
The CLI retries 429 and temporary server failures with bounded backoff. Use --no-retry when the caller owns retry policy. Destructive commands never wait forever for an interactive prompt: non-interactive use must pass --force.
Profiles
Use named profiles to keep credentials for different workspaces or environments separate:
aiglot --profile client-a auth login --key "$CLIENT_A_KEY"
aiglot --profile client-a account
export AIGLOT_PROFILE=client-aEnvironment variables
| Variable | Purpose |
|---|---|
AIGLOT_API_KEY | API key; overrides stored credentials |
AIGLOT_API_URL | REST base URL |
AIGLOT_MCP_URL | MCP base URL |
AIGLOT_AUTH_URL | OAuth authorization-server URL |
AIGLOT_PROFILE | Named credential profile |
AIGLOT_NO_TUI | Force machine-readable output |
AIGLOT_NO_KEYCHAIN | Skip the operating-system keychain |
NO_COLOR | Disable colour and force JSON output |