AppMage

AITelemetryRpc

AITelemetryRpc exposes RPC methods for reading AI telemetry stored in the telemetry_ai_inferences collection. The available operations support thread-style browsing, single-trace lookup, and aggregate statistics over a filtered telemetry set.

Endpoints

POST /api/rpc (Method: AITelemetryRpc.listThreads)

  • Description: Returns paginated telemetry traces grouped by threadId, with solo traces grouped under their own traceId. Results are ordered by the most recent requestTimestamp in each group.

  • Request Body:

    {
      "method": "AITelemetryRpc.listThreads",
      "params": {
        "page": 1,
        "pageSize": 50,
        "filter": {},
        "sort": {}
      }
    }
  • Parameters:

    Name Type Required Description
    page Number No Page number, starting at 1. Defaults to 1.
    pageSize Number No Number of grouped threads to return per page. Defaults to 50, with a maximum of 200.
    filter Any No Optional filter object used to constrain the telemetry query. Supported keys are confirmed by source to include callerType, callerName, threadId, subscriptionId, status, dateFrom, and dateTo.
    sort Any No Optional sort object. The source reads sort.direction; when it is 'asc', results are sorted oldest-to-newest, otherwise newest-to-oldest.
  • Response:

    {
      "success": true,
      "data": {
        "data": [
          {
            "threadId": "string",
            "latestTimestamp": "string|number",
            "earliestTimestamp": "string|number",
            "turnCount": 1,
            "totalTokens": 0,
            "cachedTokens": 0,
            "callerType": "string",
            "callerName": "string",
            "subscriptionId": "string",
            "hasErrors": false
          }
        ],
        "totalCount": 0
      }
    }

    The data array contains grouped thread summaries. totalCount is the number of grouped threads matching the filter.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AITelemetryRpc.listThreads",
        "params": {
          "page": 1,
          "pageSize": 50,
          "filter": {
            "callerType": "assistant"
          },
          "sort": {
            "direction": "desc"
          }
        }
      }'

POST /api/rpc (Method: AITelemetryRpc.getThread)

  • Description: Returns all telemetry traces for a single thread, ordered chronologically by requestTimestamp. If a trace was stored without a threadId, the method also matches records whose traceId equals the requested thread identifier.

  • Request Body:

    {
      "method": "AITelemetryRpc.getThread",
      "params": {
        "threadId": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    threadId String Yes Thread identifier to retrieve.
  • Response:

    {
      "success": true,
      "data": [
        {}
      ]
    }

    The method returns an array of trace records in ascending requestTimestamp order. If no records match, the result is an empty array.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AITelemetryRpc.getThread",
        "params": {
          "threadId": "thread-123"
        }
      }'

POST /api/rpc (Method: AITelemetryRpc.getTrace)

  • Description: Returns a single telemetry trace by its traceId. If no matching trace exists, the method throws an error stating that the trace was not found.

  • Request Body:

    {
      "method": "AITelemetryRpc.getTrace",
      "params": {
        "traceId": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    traceId String Yes Trace identifier. The request schema requires a UUID string.
  • Response:

    {
      "success": true,
      "data": {}
    }

    The method returns the first matching trace record. The source does not define a fixed response shape beyond the stored trace document.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AITelemetryRpc.getTrace",
        "params": {
          "traceId": "550e8400-e29b-41d4-a716-446655440000"
        }
      }'

POST /api/rpc (Method: AITelemetryRpc.getStats)

  • Description: Returns aggregate telemetry statistics for the matching records. The method calculates totals, error count, average duration, unique thread count, and cache hit rate.

  • Request Body:

    {
      "method": "AITelemetryRpc.getStats",
      "params": {
        "filter": {}
      }
    }
  • Parameters:

    Name Type Required Description
    filter Any No Optional filter object used to constrain the aggregation. Supported keys are confirmed by source to include callerType, callerName, threadId, subscriptionId, status, dateFrom, and dateTo.
  • Response:

    {
      "success": true,
      "data": {
        "totalTraces": 0,
        "totalTokens": 0,
        "totalCachedTokens": 0,
        "errorCount": 0,
        "avgDurationMs": 0,
        "uniqueThreadCount": 0,
        "cacheHitRate": 0
      }
    }

    When no matching records exist, the method returns zero-valued statistics.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AITelemetryRpc.getStats",
        "params": {
          "filter": {
            "status": "error"
          }
        }
      }'