CLI Reference

CLI overview

Discover, inspect and run pay-per-call endpoints from your terminal or an agent's shell tool. One file, no dependencies, Node 18+.

Install

The CLI is not on the npm registry yet; install it from this site:

bash
npm install -g https://<your-pikeway-site>/sdk/pikeway-cli.tgz
pikeway --version

Or let your agent do it: tell it set up https://<your-pikeway-site>/SKILL.md. It installs the CLI, saves the skill and checks your key with pikeway setup.

Quick start

bash
pikeway discover -q "token price on solana"          # free, no key
pikeway inspect -p birdeye -e /defi/price            # input schema + price
pikeway keys add --label main --key pk-...           # from /console/keys
pikeway run -p birdeye -e /defi/price -i '{"address":"So11111111111111111111111111111111111111112"}'
pikeway runs list && pikeway balance

discover and inspect are free and work without a key. Everything that spends money or reads your account needs one.

Configuration

API key resolution

Each command that needs a key picks the first one it finds:

  • --key pk-… / -k pk-… on the command line
  • the PIKEWAY_API_KEY environment variable
  • the active key saved with pikeway keys add / activate
While PIKEWAY_API_KEY is set it wins over the saved active key, so pikeway keys activate appears to have no effect. Unset it to use your saved keys.

Config file

Saved keys live in $XDG_CONFIG_HOME/pikeway/config.json (default ~/.config/pikeway/config.json). The directory is created with mode 700 and the file is written with mode 600. Keys are stored in plain text, so treat the file like a password.

~/.config/pikeway/config.json
{
  "keys": [
    { "label": "main", "key": "pk-AbCdEf0123456789xYz9" },
    { "label": "ci", "key": "pk-9fQr7s6t5u4v3w2xT2mw" }
  ],
  "active": "main"
}

Environment variables

PIKEWAY_API_KEYpk-…
Key to use instead of the saved active key (a --key flag still wins).
PIKEWAY_API_BASE_URLURL
Gateway to talk to. Defaults to the hosted gateway built into the CLI (https://gw.pikeway.ai); pikeway --help prints the one in use. For this deployment: https://gw.pikeway.ai.
XDG_CONFIG_HOMEpath
Where the pikeway config directory is created. Default ~/.config.
NO_COLORany
Disable colors. Colors are also off when stdout is not a TTY.
Point the CLI at this deployment
export PIKEWAY_API_BASE_URL=https://gw.pikeway.ai
pikeway --help | head -1

Global flags

-j, --jsonboolean
Print the raw JSON response instead of the human-readable text.
-k, --keypk-…
Use this key for the command (overrides PIKEWAY_API_KEY and the saved key).
-h, --help · helpboolean
Print usage, the CLI version and the gateway in use. Running pikeway with no command does the same.
-v, --versionboolean
Print the CLI version and exit.

Flag syntax

  • Values can be written as --flag value or --flag=value. Short aliases take the next argument: -l 3.
  • Short aliases are single letters and cannot be combined: write -j -l 3, not -jl 3.
  • Boolean flags (--json, --async, --wait, --no-skill) never take the next argument; --async=false turns one off.
  • Unknown flags are not rejected. A misspelled value flag such as --limt 3 is ignored and swallows the next argument, so double-check spelling in scripts.
  • Everything after -- is treated as positional words.

JSON output

With -j / --json every command prints exactly the API response body, pretty-printed, on stdout. The extra hint lines (next:, more:, status lines on stderr) are not printed. keys commands, which never contact the gateway, print a small object describing the local change.

bash
pikeway discover -q "token price on solana" --json | jq -r '.results[0].endpoint'
pikeway run -p birdeye -e /defi/price -i '{"address":"So111..."}' -j | jq '.output.data.value'
pikeway balance --json | jq '.spendable.value'

Errors are printed to stdout as one line of JSON, with the same exit code as in text mode. details is the gateway's error body when there is one, otherwise null:

json
{"error":"missing --provider","details":null}
{"error":"unknown endpoint /price on birdeye","details":{"code":404,"message":"unknown endpoint /price on birdeye","available":["GET /defi/history_price","GET /defi/price"]}}
JSON errors are only produced when the literal argument --json or -j is present. --json=true gives JSON results but plain-text errors.

In text mode, errors go to stderr as error: <message>.

Exit codes

ExitMessageWhen
0—Success.
1cannot reach <gateway>: … · <gateway message>The request failed (network error, 4xx/5xx other than 401/403), or pikeway run finished with a status other than COMPLETED.
2missing --provider · unknown command "x"Bad usage: a required flag is missing, --input is not valid JSON, an unknown command or subcommand, or a local keys conflict.
3no API key: … · invalid or revoked API keyAuth: no key could be found, or the gateway answered 401/403.

A 402 (insufficient balance or key spend limit) exits with 1 and the message ends with — top up your balance, or pay per call with --x402. See Errors for the gateway messages.

Agents should prefer --json: every command then prints exactly the API response, and errors come back as JSON with the same exit codes.

Commands