CLI Reference
pikeway balance
See your balance, the budget left on the current key, and how much you can actually spend.
Synopsis
bash
pikeway balance [--json] [--key pk-...]
Description
Reads GET /v1/wallet/balance for the account behind your key. Needs a key.
- balance: your account's USD balance.
- key budget: shown only when the key has a spend limit; how much of that limit is left.
- spendable: what the next calls can use, the smaller of the balance and the key budget. Calls fail with
402once a call costs more than this.
Options
None besides the global --json and --key.
Examples
bash
pikeway balance # balance of another key's account pikeway balance -k pk-... # warn in a script when running low [ "$(pikeway balance --json | jq '.spendable.value < 1')" = true ] && echo "top up soon"
Output
Key with a spend limit
balance $12.4831 key budget $3.75 left of $5 spendable $3.75
Key without a limit
balance $12.4831 spendable $12.4831
--json
json
{
"balance": { "value": 12.4831, "currency": "USD" },
"earnings": { "value": 0, "currency": "USD" },
"keyBudget": { "limit": 5, "used": 1.25, "remaining": 3.75, "currency": "USD" },
"spendable": { "value": 3.75, "currency": "USD" }
}keyBudgetobjectPresent only when the key has a spend limit.
earningsobjectWhat you have earned as an API provider (not shown in text mode).
Errors and exit codes
| Exit | Message | When |
|---|---|---|
| 3 | no API key: run `pikeway keys add --label main --key pk-...`, set PIKEWAY_API_KEY, or pass --key | No --key, no PIKEWAY_API_KEY and no saved active key. Checked before any request is sent. |
| 3 | invalid or revoked API key — add a key with `pikeway keys add --label main --key pk-...` (or use --x402) | The gateway answered 401 (unknown, revoked or expired key). A 403 also exits with 3. |
| 1 | cannot reach <gateway>: ECONNREFUSED | The gateway could not be reached (DNS, network, wrong PIKEWAY_API_BASE_URL). The code after the colon comes from Node. |