How to monitor Claude code token usage?



This content originally appeared on DEV Community and was authored by c3phalik

CC Usage example screenshot

Monitor Your Claude API Token Usage with CCUsage

If you’re leveraging the Claude API for your coding projects, keeping track of your token consumption is crucial to managing costs and staying within limits.

Well, there’s a handy tool designed to help you monitor your usage effectively: CCUsage. This tool provides a straightforward way to check your Claude API token usage and associated costs.

Getting Started with CCUsage

To use CCUsage, you’ll need to have Node.js installed, as the tool runs via npx. Here are the key commands to get started:

npx ccusage@latest

Check Token Usage by Time Period
Run the following command to view your token usage for a specific timeframe:

npx ccusage@latest opts [daily | weekly | monthly]

This command allows you to analyze your usage daily, weekly, or monthly, helping you understand your consumption patterns and costs.

Live Monitoring with Automatic Token Limit Detection
For real-time insights, CCUsage offers a live monitoring feature that automatically detects your token limits based on your usage history:

npx ccusage@latest blocks --live

If you’re using Claude code with the API (I don’t know why would anyone do that), this tool will help you a great deal.

And if you use CC via the monthly plans, it’s really cool to check how much you have saved using the subscription.


This content originally appeared on DEV Community and was authored by c3phalik