MATIH Platform is in active MVP development. Documentation reflects current implementation status.
14. Context Graph & Ontology
API Reference
Analytics Endpoints

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

MethodPathDescription
GET/analytics/model-performancePer-model token, cost, and quality statistics
GET/analytics/path-analysisAgent path frequency and outcome analysis
GET/analytics/cost-breakdownCost breakdown by model, tenant, or session
GET/analytics/latency-distributionLatency percentiles per step type

GET /model-performance

Returns per-model performance statistics for a tenant.

Query Parameters

ParameterTypeRequiredDescription
tenant_idstringYesTenant identifier
model_idstringNoFilter by specific model
start_timedatetimeNoStart of time window
end_timedatetimeNoEnd 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

ParameterTypeRequiredDescription
tenant_idstringYesTenant identifier
limitintegerNoMaximum paths to return (default: 20)
start_timedatetimeNoStart of time window
end_timedatetimeNoEnd 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

ParameterTypeRequiredDescription
tenant_idstringYesTenant identifier
group_bystringNomodel, step_type, session, time (default: model)
start_timedatetimeNoStart of time window
end_timedatetimeNoEnd 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

ParameterTypeRequiredDescription
tenant_idstringYesTenant identifier
step_typestringNoFilter 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

EndpointMinimum Permission
Model Performancecontext_graph:metrics:read
Path Analysiscontext_graph:metrics:read
Cost Breakdowncontext_graph:metrics:read
Latency Distributioncontext_graph:metrics:read