claude-cost-cli
name: claude-cost-cli
by cyberash-dev · published 2026-03-22
$ claw add gh:cyberash-dev/cyberash-dev-claude-cost-cli---
name: claude-cost-cli
description: Query Claude API usage and cost reports from the command line. Secure macOS Keychain storage for Admin API key. Table/JSON output.
metadata: {"clawdbot":{"emoji":"📊","os":["macos"],"requires":{"bins":["claude-cost","node"]},"install":[{"id":"npm","kind":"shell","command":"npm install -g claude-cost-cli","bins":["claude-cost"],"label":"Install claude-cost-cli via npm"}],"source":"https://github.com/cyberash-dev/claude-cost-cli"}}
---
# claude-cost-cli
A CLI for querying Anthropic Admin API usage and cost data. Requires an Admin API key (`sk-ant-admin...`) from Claude Console → Settings → Admin Keys. Credentials are stored in macOS Keychain.
Installation
Requires Node.js >= 18 and macOS. The package is fully open source under the MIT license: https://github.com/cyberash-dev/claude-cost-cli
npm install -g claude-cost-cliThe npm package is published with provenance attestation, linking each release to its source commit via GitHub Actions. You can verify the published contents before installing:
npm pack claude-cost-cli --dry-runInstall from source (if you prefer to audit the code before running):
git clone https://github.com/cyberash-dev/claude-cost-cli.git
cd claude-cost-cli
npm install && npm run build && npm linkAfter installation the `claude-cost` command is available globally.
Quick Start
claude-cost config set-key # Interactive prompt: enter Admin API key (masked)
claude-cost usage # Token usage for the last 7 days
claude-cost cost # Cost breakdown for the last 7 days
claude-cost cost --sum # Total spend for the last 7 daysAPI Key Management
Store API key (interactive masked prompt, validates `sk-ant-admin` prefix):
claude-cost config set-keyShow stored key (masked):
claude-cost config showRemove key from Keychain:
claude-cost config remove-keyUsage Reports
claude-cost usage # Last 7 days, daily, grouped by model
claude-cost usage --period 30d # Last 30 days
claude-cost usage --from 2026-01-01 --to 2026-01-31 # Custom date range
claude-cost usage --model claude-sonnet-4 # Filter by model
claude-cost usage --api-keys apikey_01Rj,apikey_02Xz # Filter by API key IDs
claude-cost usage --group-by model,api_key_id # Group by multiple dimensions
claude-cost usage --bucket 1h # Hourly granularity (1d, 1h, 1m)JSON output (for scripting):
claude-cost usage --json
claude-cost usage --period 30d --jsonOutput columns: Date, Model, Input Tokens, Cached Tokens, Output Tokens, Web Searches.
Cost Reports
claude-cost cost # Last 7 days, grouped by description
claude-cost cost --period 30d # Last 30 days
claude-cost cost --from 2026-01-01 --to 2026-01-31 # Custom date range
claude-cost cost --group-by workspace_id,description # Group by workspace and description
claude-cost cost --sum # Total cost onlyJSON output (for scripting):
claude-cost cost --json
claude-cost cost --sum --jsonOutput columns: Date, Description, Model, Amount (USD), Token Type, Tier.
Flag Reference
`usage`
| Flag | Description | Default |
|------|-------------|---------|
| `--from <date>` | Start date (YYYY-MM-DD or ISO) | 7 days ago |
| `--to <date>` | End date (YYYY-MM-DD or ISO) | now |
| `--period <days>` | Shorthand period (7d, 30d, 90d) | 7d |
| `--model <models>` | Filter by model(s), comma-separated | all |
| `--api-keys <ids>` | Filter by API key ID(s), comma-separated | all |
| `--group-by <fields>` | Group by model, api_key_id, workspace_id, service_tier | model |
| `--bucket <width>` | Bucket width: 1d, 1h, 1m | 1d |
| `--json` | Output as JSON | false |
`cost`
| Flag | Description | Default |
|------|-------------|---------|
| `--from <date>` | Start date (YYYY-MM-DD or ISO) | 7 days ago |
| `--to <date>` | End date (YYYY-MM-DD or ISO) | now |
| `--period <days>` | Shorthand period (7d, 30d, 90d) | 7d |
| `--group-by <fields>` | Group by workspace_id, description | description |
| `--sum` | Output total cost only | false |
| `--json` | Output as JSON | false |
Security and Data Storage
The following properties are by design and can be verified in the source code:
API Reference
This CLI wraps the Anthropic Admin API:
Documentation: https://platform.claude.com/docs/en/build-with-claude/usage-cost-api
More tools from the same signal band
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
Sign plugins, rotate agent credentials without losing identity, and publicly attest to plugin behavior with verifiable claims and authenticated transfers.
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your...