AppMage

Admin Analytics

This endpoint group provides methods for retrieving aggregated AI usage data and overall system health information for the AppBuilder application.

Endpoints

POST /api/rpc (Method: AdminAnalyticsRpc.getUsageData)

  • Description: Fetches aggregated AI usage data for the current tenant context.

  • Request Body:

    {
      "method": "AdminAnalyticsRpc.getUsageData",
      "params": {
        "groupBy": "model"
      }
    }
  • Parameters:

    Name Type Required Description
    groupBy String No The field by which to group the usage data. Can be "model", "provider", or "status". Defaults to "model".
  • Response:

    {
      "success": true,
      "data": [
        {
          "model": "gpt-4",
          "requestCount": 100,
          "totalCost": 15.25,
          "totalTokens": 50000,
          "errorCount": 5
        }
      ]
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminAnalyticsRpc.getUsageData",
        "params": { "groupBy": "model" }
      }'

POST /api/rpc (Method: AdminAnalyticsRpc.getOverallUsageSummary)

  • Description: Fetches overall AI usage summary for the current tenant context.

  • Request Body:

    {
      "method": "AdminAnalyticsRpc.getOverallUsageSummary",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
    This method takes no parameters.
  • Response:

    {
      "success": true,
      "data": {
        "totalRequests": 150,
        "totalCost": 20.50,
        "totalTokens": 75000,
        "totalErrors": 8
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminAnalyticsRpc.getOverallUsageSummary",
        "params": {}
      }'

POST /api/rpc (Method: AdminAnalyticsRpc.getAiUsageStats)

  • Description: Gets statistics about AI usage from the inference log.

  • Request Body:

    {
      "method": "AdminAnalyticsRpc.getAiUsageStats",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
    This method takes no parameters.
  • Response:

    {
      "success": true,
      "data": {
        "totalCost30d": 123.45,
        "topModels": [
          {
            "model": "gpt-4",
            "count": 500
          },
          {
            "model": "claude-3",
            "count": 300
          }
        ]
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminAnalyticsRpc.getAiUsageStats",
        "params": {}
      }'

POST /api/rpc (Method: AdminAnalyticsRpc.getAppSpecificStats)

  • Description: Gets application-specific custom statistics. Projects should override this RPC.

  • Request Body:

    {
      "method": "AdminAnalyticsRpc.getAppSpecificStats",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
    This method takes no parameters.
  • Response:

    {
      "success": true,
      "data": {}
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminAnalyticsRpc.getAppSpecificStats",
        "params": {}
      }'