Skip to main content

Metrics Summary

curl "https://api.trainlyai.com/v1/{project_id}/analytics/metrics" \
  -H "Authorization: Bearer tk_your_api_key"
GET /v1/{project_id}/analytics/metrics

Response

{
  "total_queries": 48210,
  "successful": 47895,
  "failed": 315,
  "avg_response_time_ms": 723.4,
  "total_cost": 142.87,
  "avg_cost_per_query": 0.00296
}

Export Logs

curl "https://api.trainlyai.com/v1/{project_id}/analytics/export?format=csv" \
  -H "Authorization: Bearer tk_your_api_key" \
  -o traces.csv
GET /v1/{project_id}/analytics/export

Query Parameters

ParameterTypeDefaultDescription
formatstringjsonExport format: csv, json, or jsonl
Returns the file directly with the appropriate Content-Type header.

Cost Breakdown

curl "https://api.trainlyai.com/v1/{project_id}/analytics/costs" \
  -H "Authorization: Bearer tk_your_api_key"
GET /v1/{project_id}/analytics/costs

Response

{
  "total_cost": 142.87,
  "llm_cost": 128.53,
  "embedding_cost": 11.20,
  "reranking_cost": 3.14,
  "currency": "USD",
  "period_start": "2026-04-01T00:00:00Z",
  "period_end": "2026-04-07T23:59:59Z"
}

Performance Stats

curl "https://api.trainlyai.com/v1/{project_id}/analytics/performance" \
  -H "Authorization: Bearer tk_your_api_key"
GET /v1/{project_id}/analytics/performance

Response

{
  "p50_latency_ms": 540.2,
  "p95_latency_ms": 1823.7,
  "p99_latency_ms": 3102.1,
  "avg_latency_ms": 723.4,
  "total_traces": 48210,
  "period_start": "2026-04-01T00:00:00Z",
  "period_end": "2026-04-07T23:59:59Z"
}