Usage - TypeScript SDK
client.usage reads metering data. startDate and endDate 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
| Method | Description |
|---|---|
summary(options) | Aggregate usage over a time range. |
list(options) | Page individual usage records. |
trend(options) | Read time-bucketed usage. |
summary
Aggregate usage over a time range.
Request
Required startDate, endDate; optional ownerId.
Response
Server-defined summary object.
list
Page individual usage records.
Request
Required startDate, endDate; optional page, pageSize, keyId, modelId, ownerId.
Response
Server-defined page/object.
trend
Read time-bucketed usage.
Request
Required startDate, endDate; optional granularity, keyId, ownerId.
Response
Array<Record<string, unknown>>.
Field Reference and Examples
Usage objects intentionally have no fixed client model because the metering backend may add dimensions. All returned keys are preserved unchanged.
const startDate = 1782864000;
const endDate = 1785542400;
const summary = await client.usage.summary({ startDate, endDate });
const records = await client.usage.list({
startDate,
endDate,
page: 1,
pageSize: 20,
keyId: 7,
modelId: "model-id",
});
const trend = await client.usage.trend({
startDate,
endDate,
granularity: "day",
keyId: 7,
});
All methods use the shared authentication and typed error behavior described in Response Conventions and Retry and Security.