cmind/metering/v1/tenant_usage_service.proto
Package: cmind.metering.v1
Messages
GetTokenUsageSeriesRequest
| Field | Type | Number | Description |
|---|---|---|---|
window | TimeWindow | 1 | |
step | google.protobuf.Duration | 2 | The 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. |
groupBy | TokenUsageGroupBy | 3 | Grouping by tenant is rejected here. |
modelIds | repeated string | 4 | Empty means every model. |
userIds | repeated string | 5 | Empty means every user. |
apiKeyIds | repeated string | 6 | Empty means every API key. |
GetTokenUsageSeriesResponse
| Field | Type | Number | Description |
|---|---|---|---|
series | repeated TokenUsageSeries | 1 |
GetCallCountSeriesRequest
| Field | Type | Number | Description |
|---|---|---|---|
window | TimeWindow | 1 | |
step | google.protobuf.Duration | 2 | |
kind | CallKind | 3 | One kind per query: counts of different kinds do not sum, so a total over several would be a number that means nothing. |
groupBy | CallGroupBy | 4 | Grouping by tenant is rejected here. |
resourceIds | repeated string | 5 | Empty means every resource. |
userIds | repeated string | 6 | Empty means every user. |
apiKeyIds | repeated string | 7 | Empty means every API key. |
GetCallCountSeriesResponse
| Field | Type | Number | Description |
|---|---|---|---|
series | repeated CallCountSeries | 1 |
ListTokenUsageRequest
| Field | Type | Number | Description |
|---|---|---|---|
window | TimeWindow | 1 | |
groupBy | TokenUsageGroupBy | 2 | Grouping by tenant is rejected here. |
limit | uint32 | 3 | Cap on the rows returned, highest total first. 0 = no cap. |
modelIds | repeated string | 4 | Empty means every model. |
userIds | repeated string | 5 | Empty means every user. |
apiKeyIds | repeated string | 6 | Empty means every API key. |
ListTokenUsageResponse
| Field | Type | Number | Description |
|---|---|---|---|
window | TimeWindow | 1 | Echoed because a row carries no time of its own. |
groups | repeated TokenUsageGroup | 2 |
GetApiKeyTokenUsageSeriesRequest
| Field | Type | Number | Description |
|---|---|---|---|
apiKeyId | string | 1 | |
window | TimeWindow | 2 | |
step | google.protobuf.Duration | 3 |
GetApiKeyTokenUsageSeriesResponse
| Field | Type | Number | Description |
|---|---|---|---|
series | repeated TokenUsageSeries | 1 |
ExportTokenUsageByApiKeyRequest
| Field | Type | Number | Description |
|---|---|---|---|
window | TimeWindow | 1 |
ExportTokenUsageByApiKeyResponse
| Field | Type | Number | Description |
|---|---|---|---|
filename | string | 1 | |
csv | bytes | 2 |
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
GetTokenUsageSeries returns the tenant's token totals per time bucket, as one series per model or one summed series.
Request: GetTokenUsageSeriesRequest
Response: GetTokenUsageSeriesResponse
GetCallCountSeries
GetCallCountSeries returns the number of distinct metered calls the tenant made, per time bucket, grouped as on GetTokenUsageSeries.
Request: GetCallCountSeriesRequest
Response: GetCallCountSeriesResponse
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
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
ExportTokenUsageByApiKey returns a CSV with one row per API key in the tenant, totalled over the window.
Request: ExportTokenUsageByApiKeyRequest
Response: ExportTokenUsageByApiKeyResponse