Skip to main content
POST
/
clickhouse
/
traces
/
summary
/
{
  "filters": {
    "environment": {
      "operator": "",
      "value": ["production"]
    }
  }
}
{
  "total_count": 150,
  "total_cost": 52.45,
  "total_prompt_tokens": 125000,
  "total_completion_tokens": 67500,
  "total_tokens": 192500,
  "average_cost": 0.3497,
  "average_prompt_tokens": 833,
  "average_completion_tokens": 450,
  "average_tokens": 1283,
  "total_duration": 450.5,
  "average_duration": 3.003,
  "total_span_count": 525,
  "average_span_count": 3.5,
  "total_llm_call_count": 300,
  "average_llm_call_count": 2.0,
  "total_error_count": 5,
  "error_rate": 0.033
}
Retrieves aggregated summary statistics for traces matching your filters. Note: This endpoint is currently available at /clickhouse/traces/summary/. A version under /api/ (/api/traces/summary/) is planned.

Authentication

All endpoints require API key authentication:
Authorization: Bearer YOUR_API_KEY

Query Parameters

Same as the List Traces endpoint.
ParameterTypeDefaultDescription
start_timeISO 86011 hour agoStart of time range
end_timeISO 8601Current timeEnd of time range
environmentstringAllFilter by environment

Request Body (POST)

Use filters to refine results server-side. See the Filters API Reference for operators and format.
{
  "filters": {
    "environment": {
      "operator": "",
      "value": ["production"]
    }
  }
}

Examples

import requests

url = "https://api.keywordsai.co/clickhouse/traces/summary/"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
params = {"start_time": "2024-01-15T00:00:00Z", "end_time": "2024-01-15T23:59:59Z"}
body = {"filters": {"environment": {"operator": "", "value": ["production"]}}}

response = requests.post(url, headers=headers, params=params, json=body)
print(response.json())

Response

{
  "total_count": 150,
  "total_cost": 52.45,
  "total_prompt_tokens": 125000,
  "total_completion_tokens": 67500,
  "total_tokens": 192500,
  "average_cost": 0.3497,
  "average_prompt_tokens": 833,
  "average_completion_tokens": 450,
  "average_tokens": 1283,
  "total_duration": 450.5,
  "average_duration": 3.003,
  "total_span_count": 525,
  "average_span_count": 3.5,
  "total_llm_call_count": 300,
  "average_llm_call_count": 2.0,
  "total_error_count": 5,
  "error_rate": 0.033
}

Error Responses

400 Bad Request
{ "detail": "Invalid parameters or filters" }
401 Unauthorized
{ "detail": "Your API key is invalid or expired, please check your API key at https://platform.keywordsai.co/platform/api/api-keys" }