> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensormesh.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# tm cost

> Per-model serverless spend and KV-cache savings.

## When To Use This

Use `tm cost` to see what you spent **and what KV caching saved you**, without configuring a separate cost-tracking proxy. Spend comes from `BillingTransaction.details` (populated by the billing service at charge time, so it reconciles with the ledger). Cache savings is `cached_tokens x input rate` — what those tokens would have cost at full price, served at \~\$0 by the cache.

Cache savings is always computed over the exact window. Per-model dollar spend is calendar-month granular (one serverless transaction per user per month): `--month YYYY-MM` is exact, while `--window 24h|7d|30d` and `--start/--end` report the overlapping monthly spend (noted in the output).

## Usage

```sh theme={null}
tm cost [OPTIONS]
```

## Examples

### Last 30-day spend + cache savings, per model.

```sh theme={null}
tm cost
```

### Last 7-day total (per-model defaults to current month).

```sh theme={null}
tm cost --window 7d
```

### Exact calendar-month spend + savings for May 2026.

```sh theme={null}
tm cost --month 2026-05
```

### Exact-window spend + cache savings.

```sh theme={null}
tm cost --start 2026-05-01 --end 2026-05-15
```

### Machine-friendly JSON for piping into other tools.

```sh theme={null}
tm --output json cost
```

## Details

Show per-model serverless spend and KV-cache savings.

Spend comes from `BillingTransaction.details` (authoritative, reconciles
with the ledger; calendar-month granularity). Cache savings is computed as
cached\_tokens x input rate — the cost those tokens would have incurred at
full input price, served at \~\$0 thanks to caching — with cached tokens read
from the serverless usage history for the exact window.

Every view shows the same shape: a per-model table plus the serverless
subtotal and total cache saved. `--window 24h|7d|30d` (rolling),
`--month YYYY-MM` (exact calendar month), and `--start/--end` (exact range)
just change the window. Cache savings is always window-exact; per-model
dollar spend is calendar-month granular (the finest the ledger records), so
every view except `--month` notes that.

## Options

| Name        | Type          | Required | Default | Details                                                                                                                                                                                                      |         |                                                                                    |
| ----------- | ------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- | ---------------------------------------------------------------------------------- |
| `--user-id` | `text`        | no       |         | Optional user id to scope the report (defaults to the authenticated user).                                                                                                                                   |         |                                                                                    |
| `--window`  | \`choice\[24h | 7d       | 30d]\`  | no                                                                                                                                                                                                           | `"30d"` | Rolling window for the report (mutually exclusive with --month and --start/--end). |
| `--month`   | `text`        | no       |         | Per-model spend + savings for a specific calendar month (YYYY-MM), aligned with how serverless transactions are aggregated.                                                                                  |         |                                                                                    |
| `--start`   | `text`        | no       |         | Arbitrary window start (ISO 8601). With --end, reports per-model spend + cache savings for an exact range (savings is window-exact; per-model dollar spend comes from the overlapping monthly transactions). |         |                                                                                    |
| `--end`     | `text`        | no       |         | Arbitrary window end (ISO 8601); defaults to now when --start is given.                                                                                                                                      |         |                                                                                    |
| `--timeout` | `float`       | no       |         | HTTP timeout in seconds.                                                                                                                                                                                     |         |                                                                                    |

## Inherited Global Options

| Name                  | Type           | Required | Default                              | Details                                                                                                                      |          |    |          |                                                                   |
| --------------------- | -------------- | -------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | -------- | -- | -------- | ----------------------------------------------------------------- |
| `--version`, `-V`     | `boolean`      | no       | `false`                              | Show the version and exit. Boolean flag.                                                                                     |          |    |          |                                                                   |
| `--config`            | `path`         | no       | `"~/.config/tensormesh/config.toml"` | Path to config TOML file                                                                                                     |          |    |          |                                                                   |
| `--output`            | \`choice\[text | json     | yaml                                 | raw                                                                                                                          | table]\` | no | `"text"` | Output format (text is human-readable; json is machine-friendly). |
| `--quiet`             | `boolean`      | no       | `false`                              | Suppress non-essential output. Boolean flag.                                                                                 |          |    |          |                                                                   |
| `--debug`             | `boolean`      | no       | `false`                              | Print debug logs to stderr (secrets redacted). Boolean flag.                                                                 |          |    |          |                                                                   |
| `--ca-bundle`         | `path`         | no       |                                      | Path to a PEM CA bundle for TLS verification (overrides TENSORMESH\_CA\_BUNDLE).                                             |          |    |          |                                                                   |
| `--max-retries`       | `integer`      | no       |                                      | Max retries for idempotent HTTP requests on transient errors (overrides TENSORMESH\_MAX\_RETRIES; subcommands may override). |          |    |          |                                                                   |
| `--controlplane-base` | `text`         | no       |                                      | Override the Control Plane base URL.                                                                                         |          |    |          |                                                                   |

## Related Commands

* [`tm billing spending summary`](/cli/reference/billing/spending/summary)
* [`tm billing transactions list`](/cli/reference/billing/transactions/list)
* [`tm billing pricing serverless list`](/cli/reference/billing/pricing/serverless/list)

## Parent Command

* [`tm`](/cli/reference)
