Table of contents
Official Content
  • This documentation is valid for:

This article provides access to Analytics API endpoints with the data and metrics available in the Tokens tab in Dashboard.

Check the generic variables needed to use the API.

Endpoints

Method Path Description
GET /analytics/requests/number-of-tokens Returns the total number of tokens consumed.
GET /analytics/requests/average-tokens-per-request Provides the average number of input, output, and total tokens per request.
GET /analytics/requests/number-of-tokens-per-agent Provides the number of input, output, and total tokens grouped by agent and model.
GET /analytics/requests/number-of-tokens-per-day Returns the number of input, output, and total tokens used each day.

Authentication

All endpoints require authentication using one of the following:

  • Authorization: Bearer $GEAI_APITOKEN
  • Authorization: Bearer $OAuth_accesstoken

For $OAuth_accesstoken, you must also include the header: ProjectId: $GEAI_PROJECTID (otherwise, this and OrganizationId:$GEAI_ORGANIZATIONID headers are optional) Some endpoints may require additional headers such as:

  • Content-Type: application/json

GET /analytics/requests/number-of-tokens

Returns the total number of input, output, and total API Tokens for all requests, supporting usage and billing analysis.

Parameters

Name Type Description
startDate string Start date for the query (YYYY-MM-DD)
endDate string End date for the query (YYYY-MM-DD)

Request

  • Method: GET
  • Path: $BASE_URL/v1/analytics/requests/number-of-tokens
  • Body: Empty

Response

{
  "input": integer,                                // Total input tokens.
  "output": integer,                             // Total output tokens.
  "total": integer                                 // Sum of input and output tokens.
}

cURL Sample

curl -X GET "$BASE_URL/v1/analytics/requests/number-of-tokens?startDate=2024-01-01&endDate=2024-01-31" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -H "OrganizationId: $GEAI_ORGANIZATIONID" \
  -H "ProjectId: $GEAI_PROJECTID"

GET /analytics/requests/average-tokens-per-request

Returns the average number of input, output, and total tokens per request, supporting analysis of typical request size and complexity.

Parameters

Name Type Description
startDate string Start date for the query (YYYY-MM-DD)
endDate string End date for the query (YYYY-MM-DD)

Request

  • Method: GET
  • Path: $BASE_URL/v1/analytics/requests/average-tokens-per-request
  • Body: Empty

Response

{
  "input": number,                                  // Average input tokens per request.
  "output": number,                                 // Average output tokens per request.
  "total": number                                   // Average total tokens per request.
}

cURL Sample

curl -X GET "$BASE_URL/v1/analytics/requests/average-tokens-per-request?startDate=2024-01-01&endDate=2024-01-31" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -H "OrganizationId: $GEAI_ORGANIZATIONID" \
  -H "ProjectId: $GEAI_PROJECTID"

GET /analytics/requests/number-of-tokens-per-day

Returns the number of input, output, and total tokens used each day, enabling daily token consumption tracking.

Parameters

Name Type Description
startDate string Start date for the query (YYYY-MM-DD)
endDate string End date for the query (YYYY-MM-DD)

Request

  • Method: GET
  • Path: $BASE_URL/v1/analytics/requests/number-of-tokens-per-day
  • Body: Empty

Response

{
  "numberOfTokens": [
    {
      "date": "string",                                // Expressed in YYYY-MM-DD.
      "input": integer,                             // Number of input tokens.
      "output": integer,                            // Number of output tokens.
      "total": integer                               // Total number of tokens.
    },
    {
      "date": "string",
      "input": integer,
      "output": integer,
      "total": integer
    },
  ]
}

cURL Sample

curl -X GET "$BASE_URL/v1/analytics/requests/number-of-tokens-per-day?startDate=2024-01-01&endDate=2024-01-31" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -H "OrganizationId: $GEAI_ORGANIZATIONID" \
  -H "ProjectId: $GEAI_PROJECTID"

GET /analytics/requests/number-of-tokens-per-agent

Returns the number of input, output, and total tokens grouped by Agent and model, supporting agent-level token usage analysis.

Parameters

Name Type Description
startDate string Start date for the query (YYYY-MM-DD)
endDate string End date for the query (YYYY-MM-DD)

Request

  • Method: GET
  • Path: $BASE_URL/v1/analytics/requests/number-of-tokens-per-agent
  • Body: Empty

Response

{
  "numberOfTokens": [
    {
      "agent": "string",                                   // If not available, returns N/D..
      "input": integer,                                // Total number of input tokens.
      "model": "string",                             // If not available, returns N/D.
      "output": integer,                               // Total number of input tokens.
      "total": integer                                // Total number of tokens.
   },
    {
      "agent": "string",
      "input": integer,
      "model": "string",
      "output": integer,
      "total": integer
    },
    ]
}

cURL Sample

curl -X GET "$BASE_URL/v1/analytics/requests/number-of-tokens-per-agent?startDate=2024-01-01&endDate=2024-01-31" \
  -H "Authorization: Bearer $GEAI_APITOKEN" \
  -H "Content-Type: application/json" \
  -H "OrganizationId: $GRAI_ORGANIZATIONID" \
  -H "ProjectId: $GEAI_PROJECTID"

Availability

Since version 2025-09.

Last update: December 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant