Usage Analytics

Usage analytics

Monitor credit consumption and request volume through the dashboard or API.

Dashboard widgets

  • Hourly, daily, weekly, and 30-day usage breakdowns
  • Top models by credit spend
  • Error rate trends with Prometheus-backed metrics
  • Export buttons for CSV/NDJSON aggregates

The dashboard visualizations are powered by the same endpoints documented below.

REST endpoints

GET /api/v1/usage

Returns high-level usage analytics for the authenticated key. Supported query parameters:

  • start_date / end_date (ISO 8601) – defaults to the last 30 days
  • group_by: hour | day | week | month
  • include_hourly: true | false
curl -X GET "https://api.kushrouter.com/api/v1/usage?group_by=day" \
  -H "Authorization: Bearer $API_KEY"

Example response:

{
  "summary": {
    "totalRequests": 1824,
    "totalCost": 36.48,
    "dateRange": {
      "from": "2025-09-10T12:00:00.000Z",
      "to": "2025-10-10T12:00:00.000Z"
    }
  },
  "data": [
    { "date": "2025-10-09", "requests": 212, "cost": 4.21 },
    { "date": "2025-10-10", "requests": 187, "cost": 3.88 }
  ],
  "logs": [],
  "totals": {
    "totalRequests": 1824,
    "totalCost": 36.48,
    "totalInputTokens": 124500,
    "totalOutputTokens": 0
  }
}

GET /api/v1/analytics

Provides formatted analytics for dashboards, including model breakdowns and daily aggregates. Query params:

  • days (default 30, max 90)
  • group_by: hour | day | week | month
  • include_hourly: true | false
curl -X GET "https://api.kushrouter.com/api/v1/analytics?days=7&group_by=day" \
  -H "Authorization: Bearer $API_KEY"

Example response:

{
  "success": true,
  "data": {
    "summary": {
      "totalRequests": 421,
      "totalCost": 8.42,
      "dateRange": { "from": "2025-10-08T00:00:00.000Z", "to": "2025-10-15T00:00:00.000Z" }
    },
    "modelBreakdown": [
      { "model": "gpt-4o-mini", "requests": 300, "cost": 6.2, "inputTokens": 0, "outputTokens": 0, "avgCostPerRequest": 0.02, "percentage": 71.25 }
    ],
    "dailyUsage": [
      { "date": "2025-10-14", "requests": 60, "cost": 1.2, "inputTokens": 0, "outputTokens": 0 }
    ],
    "hourlyDistribution": []
  },
  "meta": {
    "apiKeyId": "key_123",
    "generatedAt": "2025-10-15T05:00:00.000Z",
    "daysRequested": 7,
    "recordsFound": 7
  }
}

Errors

  • 401 – missing/invalid API key
  • 429 – rate limit exceeded
  • 5xx – transient errors

Exports

  • CSV / NDJSON exports are available in the dashboard and via the batches API for historical rollups.
  • Prometheus metrics (llm_requests_total, llm_tokens_used, etc.) feed the admin dashboards.

Further reading