Usage & Cost Tracking

Usage & Cost Tracking

The Usage page provides detailed token consumption analytics with time-series charts, per-agent and per-model breakdowns, and cost estimation.

Token Usage Chart

A Recharts area chart shows input and output token usage over time. Select a time range to zoom in:

RangeResolution
10 minutesPer-minute data points
1 hourPer-minute
6 hoursPer-minute
24 hoursPer-hour aggregation
7 daysPer-hour
30 daysPer-hour

The chart displays two stacked areas:

  • Input tokens (lighter shade)
  • Output tokens (darker shade)

Data Collection

Usage data is collected automatically by a client-side collector that:

  1. Polls the gateway every 10 seconds for session token counts
  2. Computes deltas (new tokens since last poll)
  3. Stores snapshots in the PostgreSQL database

Data is aggregated at two levels:

  • Per-minute — for short-range queries (≤6h)
  • Per-hour — for long-range queries (>6h)

The collector runs in the browser while LordClaw is open. If the dashboard is closed, no usage data is captured for that period.

Per-Agent Breakdown

Below the chart, a breakdown shows token usage per agent with progress bars indicating relative consumption. Click an agent to filter the chart.

Per-Model Breakdown

A similar breakdown shows usage per model (e.g., claude-sonnet-4, gpt-4o, deepseek-chat), also with progress bars.

Cost Estimation

Estimated costs are calculated using a built-in pricing table covering major providers:

ProviderModels
AnthropicClaude Opus, Sonnet, Haiku
OpenAIGPT-4o, GPT-4o-mini, o1, o3
GoogleGemini Pro, Flash
DeepSeekDeepSeek Chat, Reasoner
MiniMaxM1, M2
MoonshotKimi K2

Cost projections are shown as daily, weekly, and monthly estimates based on current usage patterns.

Database Requirements

Usage tracking requires PostgreSQL:

# Start Postgres (uses Docker, port 5555)
docker compose up -d
 
# Run migrations
npx prisma migrate dev
⚠️

If PostgreSQL isn’t running, the Usage page will still show the chart but won’t persist historical data. The collector silently fails and retries on each poll.