Skip to main content

@ccusage/pi

Analyze pi-agent session usage with the same reporting experience as ccusage. Track token usage and costs from your pi-agent sessions with daily, monthly, and session-based reports.

What is pi-agent?

Pi-agent is an alternative Claude coding agent. It stores usage data in a similar JSONL format to Claude Code but in a different directory structure.

Quick Start

npx @ccusage/pi@latest --help

Installation

Since npx @ccusage/pi@latest is quite long to type repeatedly, set up a shell alias:
alias ccusage-pi='bunx @ccusage/pi@latest'
Then simply run:
ccusage-pi daily
ccusage-pi monthly --json

Data Source

The CLI reads pi-agent session data from:
  • Default: ~/.pi/agent/sessions/
  • Custom: Set PI_AGENT_DIR environment variable or use --pi-path flag
Pi-agent uses JSONL files similar to Claude Code, making it easy to track usage across sessions.

Common Commands

Daily Usage Report

View token usage and costs grouped by date:
npx @ccusage/pi@latest daily

Monthly Report

View usage aggregated by month:
npx @ccusage/pi@latest monthly

Session Report

Detailed breakdown by individual sessions:
npx @ccusage/pi@latest session

JSON Output

Export structured data for scripting:
npx @ccusage/pi@latest daily --json

Custom Path

Specify a custom pi-agent sessions directory:
npx @ccusage/pi@latest daily --pi-path /path/to/sessions

Date Range Filtering

Filter reports by specific date ranges:
npx @ccusage/pi@latest daily --since 2025-12-01 --until 2025-12-19

Features

Daily Reports

Same reporting options as ccusage for daily tracking

Monthly Reports

Aggregate usage by month for budget tracking

Session Reports

Detailed breakdown by individual conversation sessions

Accurate Costs

Uses LiteLLM pricing database for accurate cost calculation

JSON Output

Export data in structured JSON format with —json

Compact Mode

Use —compact flag for narrow terminals, perfect for screenshots

Environment Variables

VariableDescriptionDefault
PI_AGENT_DIROverride pi-agent sessions directory~/.pi/agent/sessions/
LOG_LEVELControl log verbosity (0 silent … 5 trace)-

Use Cases

Budget Tracking

Track your pi-agent usage costs over time:
ccusage-pi monthly --json > usage.json

Session Analysis

Analyze individual sessions to understand costs per conversation:
ccusage-pi session

Date Range Reports

Generate reports for specific time periods:
ccusage-pi daily --since 2025-12-01 --until 2025-12-31

Comparison with Other Tools

While pi-agent uses similar JSONL format to Claude Code, the directory structure differs:
ToolData LocationFormat
Claude Code~/.claude/projects/JSONL per session
pi-agent~/.pi/agent/sessions/JSONL per session
OpenCode~/.local/share/opencode/JSON per message
The @ccusage/pi tool handles pi-agent’s specific directory structure while providing the same reporting capabilities.

npm Package

View on npm registry

pi-agent

Official pi-agent repository

ccusage Family

Explore all related tools

Main Documentation

Full ccusage documentation

Build docs developers (and LLMs) love