# Cost tracking

> Estimated model cost from agent transcripts and reported usage, per session, lane, agent, day and model, with your own rates and team budgets.

Availability: CLI; team rollups and budgets on the Team plan.

Lanekeeper reads the token usage Claude Code records in each session's transcript and turns it into an estimated
cost. It happens on your machine. With team sync on, each machine also uploads its daily totals (per day, model and
agent; token counts and the estimated cost, nothing else) so the team sees one picture.

## How it works

When a Claude Code turn ends (the `Stop` hook) and when a session ends, the daemon reads the new part of that
session's transcript and adds up input, output, cache-read and cache-write tokens per model. It remembers how far
it has read, so a hook that fires twice never counts twice, and a transcript resumed in a new session isn't counted
again.

```sh
lk usage                 # by model
lk usage --by agent      # or lane, day, session
lk usage --json
```

## Estimates, not a bill

Costs come from a table of per-model rates in US dollars per million tokens (`packages/rules/pricing.json`). The
rates there are **placeholders** until you set them to what your plan actually costs; your provider's invoice is
the source of truth. Set your own rates in `.lanekeeper/config.yml`, by model id or id prefix:

```yaml
cost:
  pricing:
    claude-sonnet-5-5: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 }
    gpt-5: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 0 }
```

They apply to usage recorded from then on.

## Other agents

Agents whose transcripts Lanekeeper can't read can report their own usage through the MCP tool
`lanekeeper_report_usage` (`model`, `inputTokens`, `outputTokens`, optional `cacheRead`, `cacheWrite`,
`sessionId`). It's off until the repository opts in, so an agent can't add to the numbers unasked:

```yaml
cost:
  acceptReportedUsage: true
```

Or import a file: a Claude Code transcript, or one JSON object per line in the same shape as the MCP tool.

```sh
lk usage import usage.jsonl --session codex-tuesday
```

## Across the team

The dashboard's **Usage and cost** page shows a month of estimated spend across the organization by repository,
model, agent or day; owners and admins also see it by developer. Machines upload after each session that recorded
usage, and again on start; an upload replaces that machine's earlier numbers for the same days, so nothing is counted
twice.

Owners and admins set monthly budgets there, for the whole organization or one repository. The first time a budget
passes 80%, and again at 100%, in a month, Lanekeeper posts to the organization's Slack channel (turn it off under
Settings, Slack).

## Not yet

OpenTelemetry import.
