Skip to main content

Usage - Python SDK

client.usage reads metering data. start_date and end_date are required Unix epoch timestamps in seconds. For compatibility, the SDK also accepts 13-digit millisecond values and converts them to seconds before the request.

Overview​

Available Operations​

MethodDescription
summary(...)Aggregate usage over a time range.
list(...)Page individual usage records.
trend(...)Read time-bucketed usage.

summary​

Aggregate usage over a time range.

Request​

Required start_date, end_date; optional owner_id.

Response​

Server-defined usage summary dict.

list​

Page individual usage records.

Request​

Required start_date, end_date; optional page, page_size, key_id, model_id, owner_id.

Response​

Server-defined page/map.

trend​

Read time-bucketed usage.

Request​

Required start_date, end_date; optional granularity, key_id, owner_id.

Response​

list[dict].

Field Reference and Examples​

Usage maps are intentionally returned without a fixed client model because the metering backend may add dimensions. Known keys are preserved unchanged.

start_seconds = 1782864000
end_seconds = 1785542400

summary = client.usage.summary(start_date=start_seconds, end_date=end_seconds)
records = client.usage.list(
start_date=start_seconds,
end_date=end_seconds,
page=1,
page_size=20,
key_id=7,
model_id="model-id",
)
trend = client.usage.trend(
start_date=start_seconds,
end_date=end_seconds,
granularity="day",
key_id=7,
)

All methods use the shared authentication and typed error behavior described in Response Conventions and Retry and Security.