# Metrics

Source: https://staging-docs.aiand.com/analytics/metrics/

```http
GET /analytics/metrics?range=<range>
```

Returns time-bucketed metrics for the calling organization. Useful for charts, dashboards, and capacity planning.

## Query parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `range` | string | Yes | One of `1h`, `24h`, `7days`, `30days`, `3months`. The server picks an appropriate bucket size. |

## Response

```json
{
  "range": "24h",
  "buckets": [
    {
      "ts": "2026-05-18T00:00:00Z",
      "requests": 1234,
      "input_tokens": 567890,
      "output_tokens": 12345,
      "cost_usd": 1.23,
      "errors": 5,
      "p50_latency_ms": 420,
      "p95_latency_ms": 1850
    }
  ]
}
```

## Caching

Responses are cached for **120 seconds** with singleflight deduplication — repeated calls within that window hit the cache and don't re-query the analytics backend.

## Auth

API key or JWT + `X-Org-ID`. See [Authentication](/authentication/).

<Aside type="note">
  Metrics are computed from an approximate analytics store. Numbers may drift slightly from billing-grade totals at very high request volumes — use [Summary](/analytics/summary/) when you need the authoritative aggregate.
</Aside>
