# spend and analytics

> Budget, spend and usage.

Budget, spend and usage.

## nexus spend

```sh
nexus spend [calls] [--by team|person|model|provider|key|product|day] [--from D] [--to D] [--team T] [--person P] [--model M] [--provider P] [--product P] [--status S] [--session S] [--limit N] [--cursor C] [--csv | --jsonl] [--out F]
```

Budget and spend by product and capability, or by team; spend calls lists each model call, and --csv or --jsonl writes them to a file.

| Option | Meaning |
| --- | --- |
| `--by <team|person|model|provider|key|product|day>` | Show the analytics table grouped by team, person, model, provider, key, product or day |
| `--from <D>` | With --by, calls, --csv or --jsonl: from this day (YYYY-MM-DD, UTC; at most 366 days in all) |
| `--to <D>` | With --by, calls, --csv or --jsonl: until this day, included (YYYY-MM-DD, UTC) |
| `--team <T>` | With --by, calls, --csv or --jsonl: only this team and the teams under it; with calls or a file, unassigned for calls with no team |
| `--person <P>` | With calls, --csv or --jsonl: only this person's calls (a user id) |
| `--model <M>` | With calls, --csv or --jsonl: only this model; - for calls with none |
| `--provider <P>` | With calls, --csv or --jsonl: only this provider; - for calls with none |
| `--product <P>` | With calls, --csv or --jsonl: only this product, or product/capability (Analytics' key) |
| `--status <S>` | With calls, --csv or --jsonl: only these statuses, comma-separated: settled, failed, refused, released |
| `--session <S>` | With calls, --csv or --jsonl: only this agent or chat session's calls (its id) |
| `--limit <N>` | With calls: at most this many calls on a page (1 to 500, default 50) |
| `--cursor <C>` | With calls, --csv or --jsonl: the next page of calls, or where a stopped file continues (its manifest's nextCursor) |
| `--csv` | Write the matching calls as CSV, at most 100,000 rows a file; its manifest (rows, nextCursor for the rest) is in the audit log |
| `--jsonl` | Write the matching calls as JSON Lines, at most 100,000 rows a file; its last line is the manifest |
| `--out <F>` | With --csv or --jsonl: write the file here instead of stdout |

```sh
nexus spend
nexus spend --by team --json
nexus spend calls --team web --status failed
nexus spend --csv --from 2026-10-01 > calls.csv
nexus spend --jsonl --out calls.jsonl
```

## nexus analytics

```sh
nexus analytics [--by team|person|model|provider|key|product|day] [--days N] [--from D] [--to D] [--team T] [--depth N] [--under T] [--person P] [--model M] [--provider P] [--product P] [--csv | --jsonl] [--cursor C] [--out F]
```

Usage by team, person, model, provider, key, product or day, with a daily series.

| Option | Meaning |
| --- | --- |
| `--by <team|person|model|provider|key|product|day>` | Group by team, person, model, provider, key, product or day |
| `--days <N>` | The last N days (1 to 366) |
| `--from <D>` | From this day (YYYY-MM-DD) |
| `--to <D>` | Until this day (YYYY-MM-DD) |
| `--team <T>` | Only this team's usage |
| `--depth <N>` | How many levels of teams to show or roll up |
| `--under <T>` | Only teams under this one |
| `--person <P>` | With --csv or --jsonl: only this person's usage (a user id) |
| `--model <M>` | With --csv or --jsonl: only this model; - for calls with none |
| `--provider <P>` | With --csv or --jsonl: only this provider; - for calls with none |
| `--product <P>` | With --csv or --jsonl: only this product, or product/capability |
| `--csv` | Write the usage file as CSV, one row per day, team, person, model, provider and product; its manifest is in the audit log |
| `--jsonl` | Write the usage file as JSON Lines; its last line is the manifest |
| `--cursor <C>` | With --csv or --jsonl: continue a file the row limit stopped, from its manifest's nextCursor |
| `--out <F>` | With --csv or --jsonl: write the file here instead of stdout |

```sh
nexus analytics --by team --days 7
nexus analytics --by model --json
nexus analytics --csv --days 30 > usage.csv
nexus analytics --jsonl --team web --out usage.jsonl
```
