npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gemistat

v0.1.1

Published

Gemini CLI wrapper with usage tracking

Downloads

22

Readme

gemistat

gemini + statistics — Comprehensive Gemini CLI usage analytics that track your token consumption and costs with precision!

⚠️ Under Development: This project is currently in active development. Features and APIs may change. Please report any issues or feedback!

A powerful wrapper for gemini-cli that provides detailed token usage tracking and cost analysis using OpenTelemetry data.

⚠️ Important: Replace your regular gemini commands with bunx gemistat to ensure logs are saved!

Regular gemini commands don't save any logs or usage data. You must use bunx gemistat instead to:

  • Automatically capture conversation logs and detailed telemetry
  • Enable token usage tracking and cost analytics
  • Store data with OpenTelemetry for analysis
# ❌ Don't use regular gemini (no logs saved)
# gemini chat
# gemini --model gemini-2.0-flash-exp

# ✅ Use gemistat instead (logs automatically saved)
bunx gemistat chat
bunx gemistat --model gemini-2.0-flash-exp

Features

  • 🎯 Accurate Token Tracking - Uses gemini-cli's native OpenTelemetry system for 100% precision
  • 💰 Real-time Cost Analysis - Fetches latest pricing from LiteLLM's comprehensive model database
  • 📊 Multiple Report Types - Daily, monthly aggregations with detailed breakdowns
  • 🔍 Date Range Filtering - Analyze usage for specific time periods
  • 📱 Smart Responsive Tables - Automatically adapts to terminal width with compact mode
  • 📄 JSON Export - Machine-readable output for integration with other tools
  • 🌐 Offline Mode - Use pre-cached pricing data when network is unavailable
  • 🎨 Beautiful Output - Colorful, well-formatted tables for easy reading
  • Fast Processing - Efficiently handles large telemetry files with streaming parsing

Installation

Quick Start (Recommended)

You can run gemistat directly without installation:

# Using bunx (recommended for speed)
bunx gemistat

# Using npx
npx gemistat@latest

# Using pnpm
pnpm dlx gemistat

💡 Tip: We recommend using bunx instead of npx for a massive speed improvement!

Prerequisites

Installing gemini-cli

# Install gemini-cli globally
npm install -g @google/generative-ai-cli

# Theen login with your Google account

For detailed setup instructions, see the gemini-cli documentation.

Usage

⚠️ Remember: gemistat acts as an alias for gemini commands with telemetry enabled. Always use bunx gemistat instead of gemini commands to ensure your usage data is captured and logged!

Basic Commands

# Wrapper mode (default) - acts as gemini alias with telemetry enabled
bunx gemistat [gemini-cli-options]
bunx gemistat chat
bunx gemistat --model gemini-2.0-flash-exp
bunx gemistat -p "hello how are you"

# Stats mode - view daily usage statistics (from saved telemetry data)
bunx gemistat daily

# Stats mode - view monthly usage statistics (from saved telemetry data)
bunx gemistat monthly

Command Replacement Guide

Replace all your regular gemini commands with bunx gemistat:

# Chat interactions
# instead of "gemini chat" ...
bunx gemistat chat
# instead of "gemini -p 'Tell me a joke'" ...
bunx gemistat -p "Tell me a joke"

# Model selection
# instead of "gemini --model gemini-2.0-flash-exp" ...
bunx gemistat --model gemini-2.0-flash-exp
# instead of "gemini chat --model gemini-1.5-pro" ...
bunx gemistat chat --model gemini-1.5-pro

# File operations
# instead of "gemini -f document.txt" ...
bunx gemistat -f document.txt
# instead of "gemini chat --file image.png" ...
bunx gemistat chat --file image.png

# All other gemini-cli options work exactly the same
# instead of "gemini [any-options]" ...
bunx gemistat [any-options]

Advanced Usage

# Stats mode - daily reports with filtering (from saved telemetry data)
bunx gemistat daily --since 2024-01-01 --until 2024-01-31
bunx gemistat daily --json                 # JSON output
bunx gemistat daily --compact              # Force compact tables
bunx gemistat daily --offline              # Use cached pricing

# Stats mode - monthly aggregations (from saved telemetry data)
bunx gemistat monthly --since 2024-01 --until 2024-03
bunx gemistat monthly --json

# Custom data directory for stats viewing
bunx gemistat daily --dir /path/to/telemetry/files

💡 More Options: Since gemistat shares similar options with gemistat, please refer to gemistat.com for detailed command-line options and advanced usage patterns.

Example Output

Daily Report

 ╭───────────────────────────────╮
 │                               │
 │  Gemini Usage Report - Daily  │
 │                               │
 ╰───────────────────────────────╯

┌──────────┬───────────────┬──────────┬──────────┬─────────────┬───────────┬─────────────┬───────────┐
│ Date     │ Models        │    Input │   Output │       Cache │     Cache │       Total │      Cost │
│          │               │          │          │      Create │      Read │      Tokens │     (USD) │
├──────────┼───────────────┼──────────┼──────────┼─────────────┼───────────┼─────────────┼───────────┤
│ 2025-08… │ -             │    6,319 │       10 │           0 │         0 │       6,329 │     $0.01 │
│          │ gemini-2.5-p… │          │          │             │           │             │           │
├──────────┼───────────────┼──────────┼──────────┼─────────────┼───────────┼─────────────┼───────────┤
│ Total    │               │    6,319 │       10 │           0 │         0 │       6,329 │     $0.01 │
└──────────┴───────────────┴──────────┴──────────┴─────────────┴───────────┴─────────────┴───────────┘

Configuration

Environment Variables

Customize telemetry file locations:

# Default configuration
~/.gemini/usage/{YYYY-MM-DD}/uuid.jsonl

# Custom directory
GEMISTAT_OUTPUT_DIR=/tmp/gemini-logs ./index.ts chat
# Results in: /tmp/gemini-logs/{YYYY-MM-DD}/uuid.jsonl

Note: Files are now organized by date directories with UUID-based filenames to prevent overwrites during multiple sessions on the same day.

Output Files

  • {YYYY-MM-DD}/uuid.jsonl - Raw OpenTelemetry events (auto-generated, organized by date with unique UUID filenames)
  • Files are saved to ~/.gemini/usage/ by default
  • Each gemini-cli session creates a unique UUID-based file within the appropriate date directory

How It Works

gemistat works by leveraging gemini-cli's built-in OpenTelemetry support to capture detailed usage metrics.

Why You Must Use gemistat Instead of Regular gemini Commands

The Problem: Regular gemini commands don't save any usage data

  • No token usage information is captured
  • No cost tracking is possible
  • No historical usage analysis
  • Conversations are lost after the session ends

The Solution: bunx gemistat automatically enables telemetry

  • Captures detailed token metrics for each API call
  • Records input tokens, output tokens, cached tokens, and more
  • Saves all data with timestamps for historical analysis
  • Enables accurate cost calculation using live pricing data

Why OpenTelemetry?

Regular gemini-cli logs don't contain token usage information, making it impossible to track consumption or calculate costs. gemistat solves this by enabling OpenTelemetry, which captures detailed token metrics for each API call including input tokens, output tokens, cached tokens, and more.

These OpenTelemetry events are then combined with the latest token pricing data from LiteLLM to calculate accurate costs. This allows gemistat to provide comprehensive usage analytics and cost tracking that wouldn't be possible with standard gemini-cli logs alone.

The Process

1. Telemetry Capture

# gemistat automatically adds these flags to gemini-cli
gemini chat --telemetry --telemetry-target=local --telemetry-outfile=~/.gemini/usage/{YYYY-MM-DD}/uuid.jsonl

2. OpenTelemetry Event Processing

The telemetry file contains structured events like:

{
	"attributes": {
		"event.name": "gemini_cli.api_response",
		"event.timestamp": "2024-01-15T14:30:45.123Z",
		"model": "gemini-1.5-pro",
		"input_token_count": 2100,
		"output_token_count": 856,
		"cached_content_token_count": 450,
		"thoughts_token_count": 0,
		"tool_token_count": 25
	}
}

3. Data Aggregation & Cost Calculation

  • Events are parsed and validated using Zod schemas
  • Token usage is aggregated by date/month
  • Costs are calculated using LiteLLM's live pricing database
  • Cache tokens, thoughts tokens, and tool tokens are tracked separately

For detailed information about gemini-cli's telemetry system, see the official telemetry documentation.

Troubleshooting

Common Issues

No usage data found

# Ensure gemini-cli is working first
gemini --version

# Check if telemetry files exist
ls ~/.gemini/usage/

# Try running with explicit directory
bunx gemistat daily --dir ~/.gemini/usage

Sponsors

Star History

License

MIT © @ryoppippi

Related Projects

Credits