Analytics Endpoints
The analytics API provides RBAC-protected endpoints for querying agent thinking performance data including model statistics, path frequency analysis, cost breakdowns, and latency distributions.
Base Path
/api/v1/context-graph/analytics/Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /analytics/model-performance | Per-model token, cost, and quality statistics |
| GET | /analytics/path-analysis | Agent path frequency and outcome analysis |
| GET | /analytics/cost-breakdown | Cost breakdown by model, tenant, or session |
| GET | /analytics/latency-distribution | Latency percentiles per step type |
GET /model-performance
Returns per-model performance statistics for a tenant.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tenant_id | string | Yes | Tenant identifier |
model_id | string | No | Filter by specific model |
start_time | datetime | No | Start of time window |
end_time | datetime | No | End of time window |
Response
{
"tenant_id": "acme",
"models": [
{
"model_id": "gpt-4",
"total_calls": 1523,
"total_input_tokens": 4500000,
"total_output_tokens": 1200000,
"total_thinking_tokens": 800000,
"total_cost_usd": 125.50,
"avg_latency_ms": 450.2,
"avg_confidence": 0.89,
"p50_latency_ms": 380.0,
"p95_latency_ms": 1200.0,
"p99_latency_ms": 2500.0
}
],
"total_calls": 1523,
"total_cost_usd": 125.50
}GET /path-analysis
Returns agent path frequency analysis with outcome statistics.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tenant_id | string | Yes | Tenant identifier |
limit | integer | No | Maximum paths to return (default: 20) |
start_time | datetime | No | Start of time window |
end_time | datetime | No | End of time window |
Response
{
"tenant_id": "acme",
"paths": [
{
"path": ["INTENT_ANALYSIS", "SQL_GENERATION", "VALIDATION"],
"path_key": "INTENT_ANALYSIS->SQL_GENERATION->VALIDATION",
"count": 342,
"success_count": 310,
"failure_count": 32,
"success_rate": 0.906,
"avg_duration_ms": 1250.5,
"avg_cost_usd": 0.035
}
],
"total_traces": 1523,
"unique_paths": 15
}GET /cost-breakdown
Returns cost breakdown grouped by a specified dimension.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tenant_id | string | Yes | Tenant identifier |
group_by | string | No | model, step_type, session, time (default: model) |
start_time | datetime | No | Start of time window |
end_time | datetime | No | End of time window |
Response
{
"tenant_id": "acme",
"group_by": "model",
"entries": [
{
"key": "gpt-4",
"total_cost_usd": 95.30,
"total_tokens": 5500000,
"call_count": 1200
},
{
"key": "gpt-3.5-turbo",
"total_cost_usd": 12.45,
"total_tokens": 8200000,
"call_count": 2100
}
]
}GET /latency-distribution
Returns latency percentile distributions per step type.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tenant_id | string | Yes | Tenant identifier |
step_type | string | No | Filter by specific step type |
Response
{
"tenant_id": "acme",
"distributions": [
{
"step_type": "SQL_GENERATION",
"p50_ms": 450.0,
"p75_ms": 780.0,
"p90_ms": 1200.0,
"p95_ms": 1800.0,
"p99_ms": 3500.0,
"count": 1523
}
]
}Required Permissions
| Endpoint | Minimum Permission |
|---|---|
| Model Performance | context_graph:metrics:read |
| Path Analysis | context_graph:metrics:read |
| Cost Breakdown | context_graph:metrics:read |
| Latency Distribution | context_graph:metrics:read |