> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Session token count

> Learn how to use the session token count test to monitor total tokens used per session

## Definition

The session token count test monitors the **total tokens used per session**. It
aggregates the per-trace token count across all turns in a session. No LLM evaluator
is involved — it's a deterministic aggregation.

## Taxonomy

* **Task types**: LLM.
* **Availability**: <Tooltip tip="Continuously evaluate your models and datasets as you iterate on their versions.">development</Tooltip>
  and <Tooltip tip="Monitor a model in production, measure its health, check for drifts and set up alerts.">monitoring</Tooltip>.
* **Evaluation level**: session.
* **Computation**: deterministic aggregation.

## Why it matters

* Session-level token usage is the cleanest proxy for "how much work did the LLM do
  for this user".
* Outliers often reveal conversations that are hitting context-window limits, pulling
  in too much RAG context per turn, or looping.

## Available measurements

| Measurement              | What it means                                                               |
| ------------------------ | --------------------------------------------------------------------------- |
| `totalTokens`            | Sum of tokens across **all traces in the window** (global, not per-session) |
| `meanTokensPerSession`   | Mean of per-session token sums across sessions in the window                |
| `medianTokensPerSession` | Median of per-session token sums across sessions in the window              |

## Required columns

* **Session ID**: Groups turns belonging to the same conversation.
* **Token count**: Per-trace token count (usually populated automatically by the
  Openlayer client or via OpenTelemetry).

## Test configuration examples

<CodeGroup>
  ```json Monitoring theme={null}
  [
    {
      "name": "Mean session token count below 10k",
      "description": "Alert when average session token usage exceeds 10,000 tokens",
      "type": "performance",
      "subtype": "sessionTokenCount",
      "thresholds": [
        {
          "insightName": "sessionTokenCount",
          "measurement": "meanTokensPerSession",
          "operator": "<=",
          "value": 10000
        }
      ],
      "subpopulationFilters": null,
      "mode": "monitoring",
      "usesProductionData": true,
      "evaluationWindow": 3600,
      "delayWindow": 0
    }
  ]
  ```
</CodeGroup>

## Related

* [Session cost](/tests/catalog/session-cost) — cost view of the same usage.
* [Mean tokens](/tests/catalog/mean-tokens), [Max tokens](/tests/catalog/max-tokens), [Total tokens](/tests/catalog/total-tokens) — trace-level token metrics.
