ccusage: Analyze Your Claude Code AI Usage & Costs
Unlock Transparency: Analyze Your Claude AI Usage with ccusage
In the rapidly evolving landscape of AI, managing and understanding your AI model usage and associated costs is crucial for both individuals and organizations. For users leveraging Claude AI, a new open-source command-line interface (CLI) tool called ccusage emerges as an indispensable utility, offering unparalleled clarity into your AI interactions.
What is ccusage?
ccusage is a powerful CLI tool designed to analyze Claude Code usage directly from your local JSONL files. It provides detailed, incredibly fast, and informative reports on token consumption and costs. Whether you're a prompt engineer optimizing your queries or a developer managing AI expenditure, ccusage offers the insights you need to make informed decisions.
Key Features and Benefits:
- Comprehensive Reporting: Get a clear picture of your Claude AI usage with various report types:
- Daily Report: Track token usage and costs aggregated by date.
- Monthly Report: See your aggregated usage and expenses over longer periods.
- Session Report: Understand usage grouped by individual conversation sessions.
- 5-Hour Blocks Report: Monitor usage within Claude's specific billing windows, crucial for cost management.
- Live Monitoring: For real-time visibility, use the
ccusage blocks --livecommand to see an active session's progress, token burn rate, and cost projections. This feature is a game-changer for active development. - Detailed Breakdown: Identify exactly which Claude models (Opus, Sonnet, etc.) you're utilizing and view a per-model cost breakdown with the
--breakdownflag. - Flexible Filtering: Analyze specific periods with date filtering using
--sinceand--untiloptions. - Offline Capability: Access pre-cached pricing data even without an internet connection, ensuring continuous analysis.
- User-Friendly Output: Enjoy colorful, table-formatted displays that adapt automatically to your terminal's size. For narrow terminals, a smart compact mode ensures readability.
- JSON Export: Need to integrate data into other systems? Export your reports in a structured JSON format.
- Cost Tracking: All reports include clear cost figures in USD, helping you keep a tight rein on your budget.
- Cache Token Support: Differentiate between cache creation and cache read tokens for a more granular understanding of usage.
- MCP Integration: Built-in Model Context Protocol server allows for seamless integration with other tools.
Why ccusage Matters for You:
For anyone working with Claude AI, understanding consumption patterns is vital for several reasons:
- Cost Optimization: Pinpoint areas of high token usage or expensive model application to reduce your overall AI spending.
- Performance Monitoring: Analyze session data to identify inefficient prompts or conversations that consume excessive tokens.
- Budgeting: Accurately forecast your AI expenses based on historical usage data.
- Transparency: Gain complete visibility into your AI interactions, fostering better resource management.
Getting Started:
Installation is straightforward via npm:
npm i -g ccusage
Once installed, you can start analyzing your data with simple commands:
ccusage daily(for daily reports)ccusage blocks --live(for real-time monitoring)
With ccusage, managing your Claude AI token usage and costs is no longer a mystery. This robust, open-source tool empowers you to take control, optimize your AI workflow, and ensure efficient resource allocation. Dive into your data and unlock the full potential of your Claude AI initiatives today!