Analytics
Use analytics endpoints to inspect usage, latency, errors, token counts, tool calls, and individual request sequences for an organization. These are the same usage analytics available in the console.
All timestamps in analytics query parameters are Unix milliseconds.
Get Analytics Overview
GET /organizations/{org_id}/analytics/overview
Returns summary, timeseries, breakdown, status, and tool-call analytics.
Permission: api-read
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
range_start | integer | Yes | Start timestamp in Unix milliseconds. |
range_end | integer | Yes | End timestamp in Unix milliseconds. |
group_by | string | Yes | Breakdown dimension. |
metric | string | Yes | Breakdown metric. |
buckets | integer | No | Requested timeseries bucket count. Clamped to 1 through 1000. |
f | string | No | Repeated filter. |
Metrics:
| Metric | Measures |
|---|---|
requests | Request count. |
errors | Error count. |
in_tokens | Input tokens. |
cached_in_tokens | Cached input tokens. |
out_tokens | Output tokens. |
duration | Total sequence duration. |
p50_latency | Median gateway latency. |
p95_latency | 95th percentile gateway latency. |
error_rate | Errors divided by requests. |
Response:
{
"data": {
"range": {
"start": 1767225600000,
"end": 1767312000000
},
"summary": {
"requests": 100,
"errors": 2,
"in_tokens": 50000,
"cached_in_tokens": 10000,
"out_tokens": 25000,
"duration_ms": 123456,
"p50_latency_ms": 220,
"p95_latency_ms": 900,
"error_rate": 0.02
},
"timeseries": {
"bucket_ms": 3600000,
"buckets": []
},
"breakdown": {
"dim": "model",
"metric": "requests",
"rows": [
{ "key": "qwen/qwen3.5-4b-free", "value": 80, "count": 80 }
]
},
"status": {
"rows": [
{ "key": "success", "count": 98 }
]
},
"tool_calls": {
"rows": []
}
}
}Each timeseries bucket contains t0, t1, requests, errors, in_tokens, cached_in_tokens, out_tokens, duration_ms, p50_latency_ms, and p95_latency_ms.
List Analytics Sequences
GET /organizations/{org_id}/analytics/sequences
Lists request sequences.
Permission: api-read
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
range_start | integer | Yes | Start timestamp in Unix milliseconds. |
range_end | integer | Yes | End timestamp in Unix milliseconds. |
f | string | No | Repeated filter. |
after | string | No | Cursor from the previous response. |
limit | integer | No | Defaults to 50; maximum is 500. |
include_total | boolean | No | Include a total row count. |
Response:
{
"data": {
"sequences": [
{
"seq_id": "seq_...",
"timestamp": 1767225600000,
"model": "qwen/qwen3.5-4b-free",
"api_key_id": "ak_...",
"call_source": "chat_completions",
"client_ip": "203.0.113.10",
"client_ua": "curl/8.0",
"input_tokens": 100,
"cached_input_tokens": 0,
"output_tokens": 40,
"seq_duration_ms": 1200,
"gateway_latency_ms": 50,
"result": "success",
"error_code": null,
"error_message": null,
"tool_calls": []
}
],
"next_cursor": null,
"total": 1
}
}api_key_id, client_ip, client_ua, error_code, and error_message may be null. total is null unless include_total=true.
Get Analytics Sequence
GET /organizations/{org_id}/analytics/sequences/{seq_id}
Returns one request sequence.
Permission: api-read
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
range_start | integer | No | Optional start timestamp in Unix milliseconds. |
range_end | integer | No | Optional end timestamp in Unix milliseconds. |
Response:
{
"data": {
"sequence": {
"seq_id": "seq_...",
"timestamp": 1767225600000,
"model": "qwen/qwen3.5-4b-free",
"api_key_id": "ak_...",
"call_source": "chat_completions",
"client_ip": "203.0.113.10",
"client_ua": "curl/8.0",
"input_tokens": 100,
"cached_input_tokens": 0,
"output_tokens": 40,
"seq_duration_ms": 1200,
"gateway_latency_ms": 50,
"result": "success",
"error_code": null,
"error_message": null,
"tool_calls": []
}
}
}Filters
Analytics endpoints accept repeated f query parameters:
f=dimension:value
f=!dimension:valueThe ! prefix negates the filter.
| Dimension | Filters by |
|---|---|
model | Model SKU. |
api_key_id | API key id. |
call_source | Request source, such as chat completions. |
client_ip | Client IP address. |
client_ua | Client user agent. |
result | Request result. |
error_code | Error code for failed requests. |
tool_calls | Tool name used during the request. |
# Shows successful requests for one model, excluding requests from a specific API key.
?f=model:qwen/qwen3.5-4b-free&f=result:success&f=!api_key_id:ak_...Errors
All endpoints can return:
{
"error": {
"message": "resource not found"
}
}Common statuses:
| Status | Code | When |
|---|---|---|
400 | none | Missing range, unknown group_by, unknown metric, invalid filter, invalid integer, or invalid boolean. |
401 | none | Authentication failed. |
403 | insufficient_api_key_permissions | API key does not have api-read. |
404 | none | Organization, sequence, or API-key organization scope was not found. |
503 | none | Analytics is not configured on the server. |
500 | none | Internal error. |