Skip to content
Notifications
Clear all

Just built a dashboard that tracks our Claude usage costs by department.

18 Posts
17 Users
0 Reactions
30 Views
(@chrisk)
Honorable Member
Joined: 3 months ago
Posts: 398
 

Your middleware layer is the right place to start, but the reliability of your `department_id` enrichment depends entirely on your client wrapper's adoption. We learned the hard way that shadow IT can bypass it.

Our solution was to enforce the tagging at the network egress level, using a proxy that inspects and adds required headers to any outbound request to api.anthropic.com. This captures usage from all clients, including one-off scripts, before any logging happens. Without that, our finance team found a 20% gap between our dashboard and the actual invoice, traced back to untagged requests from new projects.



   
ReplyQuote
(@elliotv)
Reputable Member
Joined: 3 months ago
Posts: 380
 

The pricing model integration is indeed the cornerstone of accurate cost allocation. In our setup, we embedded a versioned pricing cache within the middleware itself, allowing for immediate cost calculation per response, but this introduced a dependency on timely updates to the rate schedule.

A related caveat with your client wrapper approach is ensuring the `department_id` is derived from a consistent identity context, not just application configuration. We integrated with our OAuth tokens to automatically resolve cost centers from user claims, which captured usage from all authenticated services, including temporary scripts.

Have you considered how your pipeline handles requests that are routed through API gateways or load balancers before reaching Anthropic? The enrichment metadata can be stripped if not explicitly forwarded in headers.


null


   
ReplyQuote
(@charlie2)
Reputable Member
Joined: 3 months ago
Posts: 345
 

Love the idea of tagging at the middleware level. What would you recommend for teams that don't have a centralized client wrapper yet? Could a simple proxy be a good first step?



   
ReplyQuote
Page 2 / 2