Skip to main content
GET
/
api
/
v2
/
experiments
/
{experiment_id}
/
logs
/
summary
/
{
  "filters": [
    {
      "field": "status",
      "operator": "=",
      "value": "completed"
    },
    {
      "field": "total_cost",
      "operator": ">=",
      "value": 0.01
    }
  ]
}
{
  "total_count": 150,
  "total_cost": 12.45,
  "total_tokens": 50000,
  "total_prompt_tokens": 30000,
  "total_completion_tokens": 20000,
  "avg_latency": 1.23
}
Retrieves aggregated summary statistics for experiment traces matching the current filters. This is useful for getting overview metrics without retrieving individual traces.

Authentication

  • API key: Authorization: Bearer <API key>

Path Parameters

experiment_id
string
required
The ID of the experiment to get summary statistics for.

Query Parameters

start_time
string
Filter start time (ISO format).
end_time
string
Filter end time (ISO format).

POST Request Body (Optional)

For advanced filtering, you can send a POST request with filters in the body:
{
  "filters": [
    {
      "field": "status",
      "operator": "=",
      "value": "completed"
    },
    {
      "field": "total_cost",
      "operator": ">=",
      "value": 0.01
    }
  ]
}
Supported Filter Operators:
  • = or "": Exact match
  • != or "not": Not equal
  • >, >=, <, <= or "gt", "gte", "lt", "lte": Numeric comparisons
  • contains: String contains (case-insensitive)
  • startsWith: String starts with
  • endsWith: String ends with
  • in or IN: Value in list
  • not_in or NOT IN: Value not in list

Examples

import requests

experiment_id = "experiment_id_123"
url = f"https://api.keywordsai.co/api/v2/experiments/{experiment_id}/logs/summary/"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}

# GET request
response = requests.get(url, headers=headers)
print(response.json())

# POST request with filtering
data = {
    "filters": [
        {
            "field": "status",
            "operator": "=",
            "value": "completed"
        }
    ]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())

Response

{
  "total_count": 150,
  "total_cost": 12.45,
  "total_tokens": 50000,
  "total_prompt_tokens": 30000,
  "total_completion_tokens": 20000,
  "avg_latency": 1.23
}
Response Fields:
  • total_count: Total number of traces matching filters
  • total_cost: Sum of all trace costs (in dollars)
  • total_tokens: Sum of all tokens (input + output)
  • total_prompt_tokens: Sum of all input tokens
  • total_completion_tokens: Sum of all output tokens
  • avg_latency: Average latency across all traces (in seconds)
Notes:
  • Uses same filtering logic as list endpoint for consistency
  • Returns zeros if no traces match the filters
  • Supports both GET and POST methods (POST for advanced filtering)
  • Efficient aggregation without loading individual trace data