Get monthly usage and cost
GET/api/v2/Usage/monthly
Returns a paginated, month-by-month breakdown of the tenant's usage and cost. Each record aggregates one combination of subtenant, model, agent version, user, usage type, channel and connection, with token counts and the cost expressed in the tenant's currency.
Every filter is optional and they combine with AND. When neither From nor To is given, the last 12 months are returned; an explicit period may not be inverted and may not span more than 12 months.
Requires an administrator role. The caller must hold one of BackofficeTenantAdministrator, BackofficeCostAdministrator or BackofficeAgentUsageAdministrator. A plain agent API key is not enough and will receive a 403.
Request
Query Parameters
Code of the agent whose usage is requested.
Version of the agent whose usage is requested. Requires AgentCode.
Possible values: <= 256 characters
Identifier of the end user whose usage is requested. Compared case-insensitively.
Possible values: [Agent, AgentServices, Services]
Kind of usage: agent execution, services invoked by an agent, or direct service calls.
Possible values: [AudioTranscription, Embeddings, Image, Vision, SpeechGeneration, Ocr, Inference]
AI service that produced the usage, for service consumption.
Possible values: <= 64 characters
Channel the execution came through.
First month of the period, normalised to the first day of the month. Defaults to 12 months back when omitted. The period may not span more than 12 months.
Last month of the period, normalised to the first day of the month. Defaults to the current month when omitted.
The unique identifier of the AI model to use. Used instead of Vendor and ModelCode.
The model code to use. Used together with Vendor when AIModelId is not provided.
The vendor of the model to use. Used together with ModelCode when AIModelId is not provided.
Default value: 1
The page number to retrieve.
Default value: 20
Number of items per page. May not exceed 1000.
Use this param to override the culture of the response. Options: - en (default) - es
Responses
- 200
- 400
- 401
- 403
- 404
- 500
Returns a paginated list of monthly usage records, empty when no usage matches the filters.
- application/json
- Schema
- Example (from schema)
Schema
Array [
Array [
]
]
Array [
]
items
object[]
nullable
links
object[]
nullable
First day of the month, in UTC.
Null when the usage does not belong to a subtenant.
model
object
agent
object
connection
object
Possible values: [Agent, AgentServices, Services]
The source of the usage: a direct agent execution, an AI service invoked by an agent, or a direct AI service call.
Possible values: [AudioTranscription, Embeddings, Image, Vision, SpeechGeneration, Ocr, Inference]
The AI service that produced the usage.
Bonified input tokens. Already included in tokenInputCount.
Bonified output tokens. Already included in tokenOutputCount.
cost
object
Costs, always expressed in the tenant's currency.
currency
object
links
object[]
nullable
{
"items": [
{
"links": [
{
"method": "string",
"url": "string",
"rel": "string"
}
],
"month": "2024-07-29T15:51:28.071Z",
"subtenantCode": "string",
"model": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"code": "string",
"vendor": "string",
"name": "string"
},
"agent": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"code": "string",
"name": "string",
"version": 0
},
"connection": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string"
},
"userIdentifier": "string",
"type": "Agent",
"serviceType": "AudioTranscription",
"channel": "string",
"instancesCount": 0,
"tokenInputCount": 0,
"tokenOutputCount": 0,
"bonifiedTokenInputCount": 0,
"bonifiedTokenOutputCount": 0,
"cost": {
"amount": 0,
"bonifiedAmount": 0,
"currency": {
"isoCode": "string",
"symbol": "string"
}
}
}
],
"total": 0,
"pageSize": 0,
"page": 0,
"links": [
{
"method": "string",
"url": "string",
"rel": "string"
}
]
}
If the page size exceeds 1000, the model is given both by id and by code and vendor, the vendor is unknown, the agent version comes without an agent code, or the period is inverted or longer than 12 months.
- application/json
- Schema
- Example (from schema)
Schema
errors
object
nullable
{
"message": "string",
"errors": {}
}
The user is unauthorized or the session expired
The caller does not hold any of the roles allowed to read usage
The entity was not found
There was an unexpected error