Track AI token spend by team
Break down agent token cost by team in SecureAuth Agent Authority with OIDC group filters, then catch spikes early in LLM Usage analytics.
Finance wants to know what Claude Code and Codex are costing per team, not just org-wide. The LLM Usage analytics tab already tracks tokens and cost per user and per model; the remaining piece is attributing that spend to a team, which means anchoring on the OIDC groups your identity provider already sends. The same Group filter also exists on the MCP Usage and Security tabs and in Agent Trail, so one lens carries you from a team's token cost to the tool calls behind it.
What you'll need
- Claude Code or Codex sending telemetry to the gateway
- Teams represented as groups on your users (identity and sign-in), reflected in each user's
user.groups - The LLM-analytics permission, to see the LLM Usage tab
Steps
- Mint an ingest key on the Telemetry page and roll it out through your device-management tooling so every developer's machine reports usage without per-user setup — see Claude and Codex for the exact config block.
- Navigate to Analytics and open the LLM Usage tab.
- Use the Group filter to select one team's OIDC group. The headline Total Cost (USD), Total Tokens, Cost Over Time (USD), and Top Users by Cost (USD) all narrow to that team's members.
- Switch the Group filter to each team in turn (combined with the date-range picker, for example This month) to compare spend side by side.
- Open the Sessions table and sort by cost. The Session metrics panel shows the typical (median) and peak (P95) session cost for the filtered slice, so you have a baseline for what a normal session costs this team. Open any session that sits well above those numbers — its percentile rank appears in the session detail drawer, which calls out sessions in the top 5%.
- For the same team's non-LLM activity — tool calls, not tokens — switch to the MCP Usage or Security tab and set the same Group filter. It's the one dimension that partitions tool calls by team, because it follows the person who made the call.
Why not agent tags?
The Agent tag filter sits next to Group on those tabs, and it's tempting to reach for it here — but it won't split teams in this scenario. Agent tags attach to agent slugs: org-wide agent products like claude-code and codex, auto-registered once per product on first connect, not one registry entry per team. Tag claude-code with team-payments and the filter matches every team's Claude Code traffic; tag it team-platform as well and both filters return the same org-wide data. Agent tags earn their keep labeling the products themselves (coding, trusted), and they only separate teams when each team runs a distinct agent. Use Group for team attribution.
Verify it works
- Run a Claude Code or Codex session as a member of one team's group.
- Once telemetry lands, open Analytics → LLM Usage, filter by that team's group, and confirm the session appears in the Sessions table and moves the team's total cost.
- Cross-check the same window in Agent Trail (Audit log), filtered by the same Group, to see the tool calls behind that spend.
Next steps
- OpenTelemetry — the full ingest-key and managed-settings setup for Claude and Codex.
- Tags — how tag namespaces, assignment, and deletion safety work.
- Audit everything an AI agent did — pair a cost spike with the exact tool calls that caused it.