Usage Metrics API

The usage metrics endpoint provides usage statistics and quota information for the authenticated tenant.


GET /v1/usage-metrics

Request

curl "https://api.hippocortex.dev/v1/usage-metrics?period=24h&granularity=hour" \
  -H "Authorization: Bearer hx_live_..."

Query Parameters

ParameterTypeDefaultOptionsDescription
periodstring24h1h, 24h, 7d, 30dTime window
granularitystringhourminute, hour, dayData point resolution

Response

{
  "ok": true,
  "data": {
    "period": {
      "start": "2025-01-14T10:00:00Z",
      "end": "2025-01-15T10:00:00Z",
      "granularity": "hour"
    },
    "usage": {
      "events": {
        "total": 1250,
        "ingested": 1200,
        "duplicates": 45,
        "errors": 5,
        "byType": {
          "message": 450,
          "tool_call": 320,
          "tool_result": 280,
          "outcome": 95,
          "error": 55
        }
      },
      "compilations": {
        "total": 3,
        "artifactsCreated": 12,
        "artifactsUpdated": 8
      },
      "syntheses": {
        "total": 89,
        "avgTokensUsed": 3200,
        "avgCompressionRatio": 2.8
      }
    },
    "quota": {
      "plan": "developer",
      "eventsLimit": 50000,
      "eventsUsed": 12500,
      "eventsRemaining": 37500,
      "resetDate": "2025-02-01T00:00:00Z"
    }
  }
}

Response Fields

Period

FieldTypeDescription
startstringPeriod start (ISO 8601)
endstringPeriod end (ISO 8601)
granularitystringData point resolution

Usage - Events

FieldTypeDescription
totalnumberTotal events received
ingestednumberSuccessfully ingested events
duplicatesnumberDeduplicated events
errorsnumberEvents that failed processing
byTypeobjectEvent count by type

Usage - Compilations

FieldTypeDescription
totalnumberCompilation runs in period
artifactsCreatednumberNew artifacts created
artifactsUpdatednumberExisting artifacts updated

Usage - Syntheses

FieldTypeDescription
totalnumberSynthesis requests in period
avgTokensUsednumberAverage tokens used per synthesis
avgCompressionRationumberAverage compression ratio

Quota

FieldTypeDescription
planstringCurrent plan name
eventsLimitnumberMonthly event limit
eventsUsednumberEvents used in current billing period
eventsRemainingnumberRemaining events
resetDatestringWhen the quota resets (ISO 8601)

Plan Quotas

PlanMonthly EventsRate Limit
Free1,00060/min
Developer50,000600/min
Pro500,0003,000/min
EnterpriseUnlimitedUnlimited

SDK Examples

TypeScript

const metrics = await hx.getMetrics({ period: '24h' });

console.log(`Events: ${metrics.usage.events.total}`);
console.log(`Quota: ${metrics.quota.eventsUsed}/${metrics.quota.eventsLimit}`);
console.log(`Remaining: ${metrics.quota.eventsRemaining}`);

Python

metrics = await hx.get_metrics(period="7d")

print(f"Events this week: {metrics.usage.events.total}")
print(f"Artifacts created: {metrics.usage.compilations.artifacts_created}")