Counts per AI agent (fast)
Overview
The counts_per_brain_fast function provides a performance-optimized way to retrieve session, message, and user counts grouped by AI agent. This fast variant uses materialized views for improved query performance on large datasets. Use this endpoint to:
- Build fast AI agent comparison dashboards
- Track agent performance metrics at scale
- Generate quick reports on AI agent usage
Quick start
query CountsPerBrainFast(
$accountId: uuid
$deskIds: _uuid
$brainIds: _uuid
$startDate: timestamp
$endDate: timestamp
) {
rows: counts_per_brain_fast(
args: {
account_id: $accountId
desk_ids: $deskIds
brain_parent_ids: $brainIds
start_time: $startDate
end_time: $endDate
}
) {
brain_parent_id: id
num_requests
num_sessions
num_users
last_used
}
}
Variables:
{
"accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
"startDate": "2024-01-08",
"endDate": "2024-01-17"
}
Parameters
| Parameter | Type | Description |
|---|---|---|
accountId | uuid | Account identifier |
deskIds | _uuid | Filter by desk IDs |
brainIds | _uuid | Filter by AI agent IDs |
startDate | timestamp | Start date (format: yyyy-mm-dd) |
endDate | timestamp | End date (format: yyyy-mm-dd) |
isTest | Boolean | Exclude test sessions |
Response fields
| Field | Type | Description |
|---|---|---|
brain_parent_id | uuid | AI agent identifier |
num_requests | Int | Total messages processed |
num_sessions | Int | Total conversation sessions |
num_users | Int | Total unique users |
last_used | timestamp | Last activity timestamp |
Common use cases
Try it
Loading GraphQL Playground...
- Account overview
- Specific AI agents
- Production only
Get counts for all AI agents in an account:
{
"accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
"startDate": "2024-01-08",
"endDate": "2024-01-17"
}
Filter by specific AI agents:
{
"accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
"brainIds": "{a2wv9283-9b53-4d7b-b77d-2650f3a1a99c, 99xx33p9-dfab-44e5-9303-9b2bf13f1c94}",
"startDate": "2024-01-08",
"endDate": "2024-01-17"
}
Exclude test sessions:
{
"accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
"isTest": false,
"startDate": "2024-01-08",
"endDate": "2024-01-17"
}
Example response
{
"data": {
"rows": [
{
"brain_parent_id": "a2wv9283-9b53-4d7b-b77d-2650f3a1a99c",
"num_requests": 309,
"num_sessions": 309,
"num_users": 309,
"last_used": "2024-01-12T15:09:18.58"
},
{
"brain_parent_id": "99xx33p9-dfab-44e5-9303-9b2bf13f1c94",
"num_requests": 1564,
"num_sessions": 448,
"num_users": 448,
"last_used": "2024-01-12T16:00:33.701"
}
]
}
}