# Track your Antigravity token usage and cost

Antigravity CLI (`agy`) keeps every conversation in a local database, with the tokens each response used and the model that answered. agy-powerline reads those databases to show how many tokens you used today, this week and this month, per model, and what they would cost at the public API list prices: in a terminal dashboard, in the editor's Usage tab, and as widgets in the bar. It all happens on your machine, read-only and offline.

- [The usage dashboard](#the-usage-dashboard)
- [What each card shows](#what-each-card-shows)
- [Tokens and cost in the bar](#tokens-and-cost-in-the-bar)
- [Set a budget](#set-a-budget)
- [How the cost is estimated](#how-the-cost-is-estimated)
- [Export to JSON or CSV](#export-to-json-or-csv)
- [What it reads, and what it needs](#what-it-reads-and-what-it-needs)

## The usage dashboard

Run it in any terminal:

```bash
npx agy-powerline usage        # the last 90 days
npx agy-powerline usage 7d     # or 14d, 30d, 90d
```

The same dashboard is the Usage tab (`u`) of the interactive editor (`npx agy-powerline`): Enter steps the window through 7, 14, 30 and 90 days, and `r` reads the conversations again.

<p align="center">
  <img src="../../assets/screenshots/usage.png" alt="agy-powerline usage dashboard: Today, Last 7d and Last 30d cards with tokens, estimated cost and cache hit; a Models card beside the 14-day usage breakdown; an activity heatmap beside Highlights with budgets and pace" width="850" height="425">
</p>

## What each card shows

- **Today, Last 7d and Last 30d:** total tokens, the estimated cost, input and output, and the cache-hit share (how much of the prompt agy read from its cache).
- **Models:** one row per model with its tokens, its share and its cost over the window. The models agy offers stay listed even when the window didn't use them, faded. Models Google retired (Gemini 4 Argon and the Gemini Flash models) get no row, but their tokens still count in the totals.
- **Usage breakdown:** 7 or 8 rows, so the card stays short: one day each over 7 days, then equal spans of 2, 4 or 12 days over 14, 30 or 90 days, each labeled with its dates. `--weekly` and `--monthly` group by calendar week or month instead.
- **Activity heatmap:** the last 155 days by weekday, in five shades, with your current and best streak and your busiest weekday. `--heatmap` draws it over the chosen window instead.
- **Highlights:** your budgets with their share used, then the daily average, the cost per 1M tokens, the busiest day and how many days were active.

## Tokens and cost in the bar

Each total is also a widget, so the bar can show it while you work. Add them in the editor's Widgets tab (`a`), or in `~/.agy-powerline/statusline.config.json`:

| Widget                     | Shows                                              |
| -------------------------- | -------------------------------------------------- |
| `tokensToday`, `costToday` | Today, in your time zone                           |
| `tokensWeek`, `costWeek`   | The last 7 days                                    |
| `tokensCycle`, `costCycle` | The current 7-day quota cycle, from its reset time |
| `tokensMonth`, `costMonth` | The last 30 days                                   |
| `totalTokens`, `cost`      | This session only, as agy reports it               |

The [ready-made configs](statusline-configs.md) include a cost budget bar to start from, and [Configuration](../configuration.md#widgets) lists every option of these widgets.

## Set a budget

Give a token or cost widget a `budget`, and it shows the share used and turns to the caution and danger colors as you approach it:

```json
{
  "widgets": [
    { "id": "costWeek", "budget": 50 },
    { "id": "tokensToday", "budget": 2000000, "budgetMode": "remaining" }
  ]
}
```

- `"budgetMode": "remaining"` shows what's left (`$12.40 left (25%)`) instead of what's used.
- `"overage": 10` makes the budget a soft target: caution past it, danger only past budget plus overage.
- `"showAbove": 50` hides the widget until 50% of the budget is used.

The dashboard's Highlights card shows the same budgets, so you can check them without opening agy. In the editor, set one under Widgets › a Tokens or Cost widget › Budget.

## How the cost is estimated

The cost is an estimate, always shown with a `~`. It prices your tokens at the Gemini API and Claude API list prices for the models agy offers (input, output, cache reads and cache writes, each at its own rate). It isn't a bill: an agy plan is a subscription with quotas, so this tells you what the same work would cost at API prices, and which model it went to.

A model without a built-in price uses a fallback rate. To use your own rates, add a `pricing` map to your config ([Configuration](../configuration.md#widgets) shows how); `doctor` reports any entry it can't use.

## Export to JSON or CSV

```bash
npx agy-powerline usage 30d --json   # the whole summary, for scripts
npx agy-powerline usage 30d --csv    # one row per day: tokens, cache hits, estimated USD and cache savings
```

`--weekly` and `--monthly` make the CSV one row per week or month.

## What it reads, and what it needs

- It reads agy's conversation databases (`~/.gemini/antigravity-cli/conversations/*.db`), read-only: only token counts, model names, response IDs (so a response is never counted twice) and timestamps, never a message.
- The totals are kept per conversation in `.usage-cache.json` in the install folder, so a conversation is read again only when it changes. `--refresh` reads them all again.
- No network call, no telemetry. See [Security](../../SECURITY.md).
- It needs Node.js 22.13 or newer, for the built-in `node:sqlite`. On older Node, the dashboard says so and the token and cost widgets stay hidden; the rest of the bar works on Node 20.
- A conversation it can't read (locked, busy or not agy's format) is left out and counted as skipped. Conversations removed with `agy conversations clean` leave the totals with them; `agy conversations compact` keeps every count.
