feat(coderd): add GET /api/experimental/chats/stats endpoint by mafredri · Pull Request #22563 · coder/coder
Add an admin-only endpoint that returns deployment-level chat usage statistics over a time range. Returns chat counts, active users, message counts by role, token usage totals, and per-status breakdowns. Sub chats (spawned by subagent delegation) are counted separately via total_sub_chats, but their messages and token usage are included in the totals so real LLM consumption is not undercounted. Chat counts, active users, and by_status only reflect top-level conversations. Authorization uses ResourceDeploymentConfig + ActionRead, matching the existing chat admin endpoints.