Z-AI / CLI
The zai CLI
Chat, model arena, key management, live logs and spend — straight from your terminal.
Install
Requires Node 18 or newer. Published as @zyoralabs/zai-cli on npm.
bash
npm install -g @zyoralabs/zai-cliOr run once without installing:
bash
npx @zyoralabs/zai-cli@latest whoamiSign in
bash
zai login
# paste your zk_live_... key when prompted
zai whoami
# Z-AI · auth=api_key
# Org: My Workspace
# Key: production-keyThe key is stored at ~/.zai/config.json (mode 0600). You can also override per-process via env: ZAI_API_KEY, ZAI_BASE_URL, ZAI_DEFAULT_MODEL.
Chat
bash
# One-shot
zai chat "explain Rust ownership in 3 bullets"
# Pick a model
zai chat -m anthropic/claude-4.5-sonnet "draft a release note for v0.3.0"
# Non-streaming (full response at once)
zai chat --no-stream "give me a JSON object with name and age"
# Read from stdin
cat README.md | zai chat "summarise this file"Model arena — compare two models on the same prompt
bash
zai arena \
-a openai/gpt-5.4-mini \
-b anthropic/claude-4.5-haiku \
"Write a haiku about TypeScript generics"
# Stored runs:
zai arena ls
zai arena show <run-id>Every arena run is saved to your org with both completions, latency and cost — so you can revisit decisions later.
Models, keys, logs, spend
bash
# List every model available to your key
zai models
# API keys for your org
zai keys list
# Tail recent gateway calls (follow live with -f)
zai logs -l 20
zai logs -f
# Spend summary
zai cost # last 24h
zai cost -h 168 # last 7 days
zai cost --json | jq .Config
Inspect and modify ~/.zai/config.json without editing it by hand.
bash
zai config show
zai config set defaultModel anthropic/claude-4.5-sonnet
zai config set baseUrl https://api.zyoralabs.com/v1
zai logout # clear local credentialsCommand reference
| Command | What it does |
|---|---|
| zai login | Paste an API key and store it locally |
| zai logout | Remove local credentials |
| zai whoami | Show org, key, spend and base URL |
| zai models | List models available to your key |
| zai chat [prompt] | Stream a single-turn chat (Enter to send) |
| zai arena -a M -b N | Run the same prompt through two models |
| zai arena ls / show | Browse saved arena runs |
| zai keys list | Show API keys in your org |
| zai logs [-l N] [-f] | Recent calls, tail with -f |
| zai cost [-h N] | Tokens / requests / cost for the last N hours |
| zai config show | Print current config |
| zai config set K V | Update a config value |