- query - Query reporting metrics
Returns time-series, scalar, and top-list analytics for AI usage, cost, latency, evaluator results, and guardrail outcomes.
from orq_ai_sdk import Orq
from orq_ai_sdk.utils import parse_datetime
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.reporting.query(metric="genai.evaluator.score.avg", from_=parse_datetime("2026-12-14T22:21:09.964Z"), to=parse_datetime("2026-03-06T12:20:53.904Z"))
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
metric |
models.Metric | ✔️ | Catalogue metric to query. |
from_ |
date | ✔️ | Inclusive lower bound for the report window (RFC 3339, UTC). |
to |
date | ✔️ | Exclusive upper bound for the report window (RFC 3339, UTC). |
grain |
Optional[models.Grain] | ➖ | Requested bucket grain. Use auto or omit the field to let the server choose based on the requested range. |
group_by |
List[models.GroupBy] | ➖ | Reporting dimensions to break down by. Valid dimensions depend on the selected metric. |
filters |
List[models.Filter] | ➖ | Up to 20 allowlisted predicates combined with AND. |
limit |
Optional[int] | ➖ | Maximum bucket rows returned. Defaults to 1000 and is capped at 5000. |
time_zone |
Optional[str] | ➖ | IANA time zone applied to bucket boundaries, for exampleAmerica/New_York. Response timestamps remain UTC. Empty means UTC. |
include_totals |
Optional[bool] | ➖ | When true, include a totals block aggregated across the fullreport window. |
mode |
Optional[models.QueryReportRequestMode] | ➖ | Value shaping. timeseries (default) buckets by time; scalar returns one aggregated row per group over the whole window, ordered by value (top list), or a single row when group_by is empty. |
sort |
Optional[models.Sort] | ➖ | Value ordering for scalar rows. Defaults to desc. Ignored for timeseries. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.APIDefaultError | 4XX, 5XX | */* |