Skip to main content

Get aggregated token usage statistics for an ai hosting plan of a customer

GET/v2/customers/{customerId}/ai-hostings/{planId}/usage
API version
v2
Request method
GET
Operation ID
ai-hosting-plan-get-usage-stats

Request​

  • customerIdstringrequired
  • planIdstring (uuid)required

Responses​

Format
application/json
Description

Aggregated token usage statistics for the ai hosting plan.

  • customerIdstringrequired
  • dailyarray of objectrequired
    • Array[
      • *object
        • byKeyobjectrequired
          • *integer (≥ 0, int64)
        • datestring (date)required
        • totalTokensinteger (≥ 0, int64)required
      ]
  • keysarray of objectrequired

    Every licence of the plan, most used in the timeframe first. Includes licences deleted inside the timeframe, which still carry usage but are no longer returned by the keys endpoint. Ordered, so callers can key chart colours off the position.

    • Array[
      • *object
        • idstring (uuid)required
        • namestringrequired
      ]
  • modelSharearray of objectrequired
    • Array[
      • *object
        • modelstringrequired
        • tokensinteger (≥ 0, int64)required
      ]
  • planIdstring (uuid)required
  • timeframeobjectrequired
    • endstring (date-time)required
    • startstring (date-time)required
  • totalTokensinteger (≥ 0, int64)required
Content-Type: application/json

{
"customerId": "string",
"daily": [
{
"byKey": {
"string": 123
},
"date": "string",
"totalTokens": 123
}
],
"keys": [
{
"id": "f0f86186-0a5a-45b2-aa33-502777496347",
"name": "string"
}
],
"modelShare": [
{
"model": "string",
"tokens": 123
}
],
"planId": "f0f86186-0a5a-45b2-aa33-502777496347",
"timeframe": {
"end": "1985-10-26T01:21:00.000Z",
"start": "1985-10-26T01:21:00.000Z"
},
"totalTokens": 123
}
{
"properties": {
"customerId": {
"type": "string"
},
"daily": {
"items": {
"properties": {
"byKey": {
"additionalProperties": {
"format": "int64",
"minimum": 0,
"type": "integer"
},
"type": "object"
},
"date": {
"format": "date",
"type": "string"
},
"totalTokens": {
"format": "int64",
"minimum": 0,
"type": "integer"
}
},
"required": [
"date",
"totalTokens",
"byKey"
],
"type": "object"
},
"type": "array"
},
"keys": {
"description": "Every licence of the plan, most used in the timeframe first. Includes licences deleted inside the timeframe, which still carry usage but are no longer returned by the keys endpoint. Ordered, so callers can key chart colours off the position.",
"items": {
"properties": {
"id": {
"format": "uuid",
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
],
"type": "object"
},
"type": "array"
},
"modelShare": {
"items": {
"properties": {
"model": {
"type": "string"
},
"tokens": {
"format": "int64",
"minimum": 0,
"type": "integer"
}
},
"required": [
"model",
"tokens"
],
"type": "object"
},
"type": "array"
},
"planId": {
"format": "uuid",
"type": "string"
},
"timeframe": {
"properties": {
"end": {
"format": "date-time",
"type": "string"
},
"start": {
"format": "date-time",
"type": "string"
}
},
"required": [
"start",
"end"
],
"type": "object"
},
"totalTokens": {
"format": "int64",
"minimum": 0,
"type": "integer"
}
},
"required": [
"customerId",
"planId",
"timeframe",
"totalTokens",
"daily",
"modelShare",
"keys"
],
"type": "object"
}

Usage examples​

$ curl \
--fail \
--location \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
https://api.mittwald.de/v2/customers/string/ai-hostings/f0f86186-0a5a-45b2-aa33-502777496347/usage?startDate=1985-10-26T01%3A21%3A00.000Z&endDate=1985-10-26T01%3A21%3A00.000Z&keyId=f0f86186-0a5a-45b2-aa33-502777496347
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";

const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.aiHosting.aiHostingPlanGetUsageStats({
"customerId": "string",
"planId": "f0f86186-0a5a-45b2-aa33-502777496347",
"queryParameters": {
"startDate": "1985-10-26T01:21:00.000Z",
"endDate": "1985-10-26T01:21:00.000Z",
"keyId": "f0f86186-0a5a-45b2-aa33-502777496347"
}
});

assertStatus(response, 200);

use \Mittwald\ApiClient\Generated\V2\Clients\AIHosting\AiHostingPlanGetUsageStats\AiHostingPlanGetUsageStatsRequest;

$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));

$request = (new AiHostingPlanGetUsageStatsRequest(
customerId: "string",
planId: "f0f86186-0a5a-45b2-aa33-502777496347"
))
->withStartDate("1985-10-26T01:21:00.000Z")
->withEndDate("1985-10-26T01:21:00.000Z")
->withKeyId("f0f86186-0a5a-45b2-aa33-502777496347");
$response = $client->aiHosting()->aiHostingPlanGetUsageStats($request);

var_dump($response->getBody();

On this page