# Usage, logs & transactions

> See credits remaining, recent spend, request logs and your credit ledger from the terminal.


# Usage, logs & transactions

Three read-only commands show your account activity. They use the same key as your launches, so there is no extra setup after [login](/cli/login).

## Credits and spend

```bash
anyr usage
```

```text
Credits remaining  $18.42
                   monthly $16.00 · top-up $2.42
Spend (24h)        $1.37
Lifetime used      $103.11
Top models
  anthropic/claude-sonnet-4-6  $0.98 · 41 req
  z-ai/glm-4.7                 $0.39 · 87 req
```

The 24h spend and top models are aggregated from recent logs. On a very busy day the crawl is bounded and the number shows as a floor (`≥ $…`). Offline, the last cached snapshot prints, marked `(cached · 2h ago)`. `--no-detail` skips the aggregation and makes one API call.

## Request logs

```bash
anyr logs                    # latest 20 requests, newest first
anyr logs --limit 50         # 1 to 100 per call
anyr logs --status error     # ok | error (the error code shows inline)
anyr logs --model z-ai/glm-4.7
anyr logs <id>               # one request in detail
anyr logs sessions           # requests grouped by session
```

Columns: time (local zone), model, provider, status, tokens in and out, cost, latency. History depth follows your plan's log retention.

## Credit ledger

```bash
anyr transactions            # newest first, 20 rows
anyr transactions --type purchase
anyr transactions --limit 100
```

Every credit movement (top-ups, per-request spend, refunds) with the signed amount, the balance after it when known, and a note.

## Scripting

All three accept `--json`, print plain text when piped, and exit non-zero with a one-line reason on failure. Pass a key with `--key` or `ANYROUTER_API_KEY` (useful in CI).

```bash
anyr usage --json | jq .balance
anyr logs --json --status error | jq '.data | length'
```

Errors print `error: <message>` on stderr (JSON with `--json`). Exit codes: 1 error, 2 usage, 3 not found, 4 no key or missing permission (the message names the scope), 5 rate limited. See [Use anyr from scripts and AI agents](/cli/agents).


## Related

- [Use anyr from scripts and AI agents](/docs/cli/agents.md)
- [Login with AnyRouter](/docs/cli/login.md)
