PLATAFORMA: Dev.to
The Anthropic console gives you one number: your monthly bill. If you're building a multi-tenant app on top of Claude, that's not nearly enough. You need to know which customers are costing you the most, which features are driving that cost, and how to spot a runaway bill before it happens.
Here are three ways to get more granular cost data, from the simple to the more robust.
1. The Usage API: A Good First Step
Anthropic's Usage API is a solid starting point. You can query it to get cost data broken down by user_id (if you're creating a key per user, which I don't recommend), model, and date.
It's better than nothing, but it's still reactive. You're looking at costs that have already been incurred.
2. The SDK Wrapper: Proactive, But More Work
A better approach is to wrap the Anthropic SDK. This lets you intercept every API call, log the token counts from the response along with your own internal customer_id or feature_id, and then store that data in your own database.
This is a more proactive approach. You can build your own real-time dashboards and set up alerts based on your own business logic. The downside is that you have to build and maintain it yourself.
3. Unified, Proxyless Monitoring: The Best of Both Worlds
The ideal solution is a dedicated, open-source tool that handles this for you. That's why I built LLMeter.
LLMeter uses async, out-of-band monitoring to track your costs without adding any latency to your API calls. It gives you a unified dashboard for all your LLM providers (not just Anthropic), with per-user and per-feature cost attribution out of the box.
You can self-host it, so your data never leaves your infrastructure.
The Anthropic console is fine for a hobby project. But if you're building a business on top of their API, you need to own your cost data. Don't wait for the end-of-month surprise.
Top comments (0)