> ## 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**: development (Continuously evaluate your models and datasets as you iterate on their versions.)
  and monitoring (Monitor a model in production, measure its health, check for drifts and set up alerts.).
* **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

```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
  }
]
```

## Related

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.