Skip to main content

cmind/metering/v1/tenant_usage_service.proto

Package: cmind.metering.v1

Messages

GetTokenUsageSeriesRequest

FieldTypeNumberDescription
windowTimeWindow1
stepgoogle.protobuf.Duration2The bucket width the caller is asking for. The server picks the width it actually returns and may coarsen this one, so read each point's window rather than assuming the request was honoured.
groupByTokenUsageGroupBy3Grouping by tenant is rejected here.
modelIdsrepeated string4Empty means every model.
userIdsrepeated string5Empty means every user.
apiKeyIdsrepeated string6Empty means every API key.

GetTokenUsageSeriesResponse

FieldTypeNumberDescription
seriesrepeated TokenUsageSeries1

GetCallCountSeriesRequest

FieldTypeNumberDescription
windowTimeWindow1
stepgoogle.protobuf.Duration2
kindCallKind3One kind per query: counts of different kinds do not sum, so a total over several would be a number that means nothing.
groupByCallGroupBy4Grouping by tenant is rejected here.
resourceIdsrepeated string5Empty means every resource.
userIdsrepeated string6Empty means every user.
apiKeyIdsrepeated string7Empty means every API key.

GetCallCountSeriesResponse

FieldTypeNumberDescription
seriesrepeated CallCountSeries1

ListTokenUsageRequest

FieldTypeNumberDescription
windowTimeWindow1
groupByTokenUsageGroupBy2Grouping by tenant is rejected here.
limituint323Cap on the rows returned, highest total first. 0 = no cap.
modelIdsrepeated string4Empty means every model.
userIdsrepeated string5Empty means every user.
apiKeyIdsrepeated string6Empty means every API key.

ListTokenUsageResponse

FieldTypeNumberDescription
windowTimeWindow1Echoed because a row carries no time of its own.
groupsrepeated TokenUsageGroup2

GetApiKeyTokenUsageSeriesRequest

FieldTypeNumberDescription
apiKeyIdstring1
windowTimeWindow2
stepgoogle.protobuf.Duration3

GetApiKeyTokenUsageSeriesResponse

FieldTypeNumberDescription
seriesrepeated TokenUsageSeries1

ExportTokenUsageByApiKeyRequest

FieldTypeNumberDescription
windowTimeWindow1

ExportTokenUsageByApiKeyResponse

FieldTypeNumberDescription
filenamestring1
csvbytes2

Services

TenantUsageService

TenantUsageService reads metered usage from inside one tenant. No method takes a tenant id: the tenant is the request's scope, carried by the passport, and it is the only one these methods can answer for. A parameter would either restate that scope or contradict it, and both are traps. The platform-facing equivalents live in PlatformUsageService, where a tenant filter is honest because it selects among tenants the caller may see.

GetTokenUsageSeries

GET /cmind.metering.v1.TenantUsageService/GetTokenUsageSeries

GetTokenUsageSeries returns the tenant's token totals per time bucket, as one series per model or one summed series.

Request: GetTokenUsageSeriesRequest

Response: GetTokenUsageSeriesResponse

GetCallCountSeries

GET /cmind.metering.v1.TenantUsageService/GetCallCountSeries

GetCallCountSeries returns the number of distinct metered calls the tenant made, per time bucket, grouped as on GetTokenUsageSeries.

Request: GetCallCountSeriesRequest

Response: GetCallCountSeriesResponse

ListTokenUsage

GET /cmind.metering.v1.TenantUsageService/ListTokenUsage

ListTokenUsage returns the tenant's token totals for the window, grouped by model or not at all. Grouping by tenant is not offered: there is one.

Request: ListTokenUsageRequest

Response: ListTokenUsageResponse

GetApiKeyTokenUsageSeries

GET /cmind.metering.v1.TenantUsageService/GetApiKeyTokenUsageSeries

GetApiKeyTokenUsageSeries returns one API key's token totals per time bucket. Gated on the key rather than the tenant so a key's owner can inspect their own usage without administering the tenant; a tenant admin still reaches it, because can_manage on a tenant-managed key resolves through the owning tenant. A key belonging to another tenant returns nothing.

Request: GetApiKeyTokenUsageSeriesRequest

Response: GetApiKeyTokenUsageSeriesResponse

ExportTokenUsageByApiKey

GET /cmind.metering.v1.TenantUsageService/ExportTokenUsageByApiKey

ExportTokenUsageByApiKey returns a CSV with one row per API key in the tenant, totalled over the window.

Request: ExportTokenUsageByApiKeyRequest

Response: ExportTokenUsageByApiKeyResponse