---
title: "Counts per AI agent (fast)"
description: "Get session, message, and user counts per AI agent with counts_per_brain_fast, a GraphQL function backed by materialized views."
---

# Counts per AI agent (fast)

> Get session, message, and user counts per AI agent with counts_per_brain_fast, a GraphQL function backed by materialized views.

## 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

```graphql
query CountsPerBrainFast(
  $accountId: uuid
  $deskIds: _uuid
  $brainIds: _uuid
  $startDate: timestamp
  $endDate: timestamp
  $isTest: Boolean
) {
  rows: counts_per_brain_fast(
    args: {
      account_id: $accountId
      desk_ids: $deskIds
      brain_parent_ids: $brainIds
      start_time: $startDate
      end_time: $endDate
      is_test: $isTest
    }
  ) {
    brain_parent_id: id
    num_requests
    num_sessions
    num_users
    last_used
  }
}
```

**Variables:**

```json
{
  "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

<GraphiQLPlayground
  query={`query CountsPerBrainFast(
  \$accountId: uuid
  \$deskIds: _uuid
  \$brainIds: _uuid
  \$startDate: timestamp
  \$endDate: timestamp
  \$isTest: Boolean
) {
  rows: counts_per_brain_fast(
    args: {
      account_id: \$accountId
      desk_ids: \$deskIds
      brain_parent_ids: \$brainIds
      start_time: \$startDate
      end_time: \$endDate
      is_test: \$isTest
    }
  ) {
    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"
}`}
  endpoint="https://logs.moveo.ai/v1/graphql"
/>

**Account overview**

Get counts for all AI agents in an account:

```json
{
  "accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
  "startDate": "2024-01-08",
  "endDate": "2024-01-17"
}
```

**Specific AI agents**

Filter by specific AI agents:

```json
{
  "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"
}
```

**Production only**

Exclude test sessions:

```json
{
  "accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
  "isTest": false,
  "startDate": "2024-01-08",
  "endDate": "2024-01-17"
}
```

## Example response

```json
{
  "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"
      }
    ]
  }
}
```
