Skip to Content
Management APIUsage & Analytics

Usage & Analytics

Query usage events, aggregations, and materialized analytics views.

Usage Events

OperationGraphQL
List events (paginated)usage_events(where: {application_id: {_eq: $appId}, created_at: {_gte: $start, _lte: $end}}, limit: $limit, offset: $offset, order_by: {created_at: desc})
Aggregate by modelusage_events_aggregate(where: {application_id: {_eq: $appId}}) { aggregate { count, sum { cost_pusd, tokens_in, tokens_out }, avg { cost_pusd, latency_ms } } }
Aggregate by providerusage_events_aggregate(where: {application_id: {_eq: $appId}, created_at: {_gte: $start, _lte: $end}})
Aggregate by statususage_events_aggregate(where: {application_id: {_eq: $appId}, created_at: {_gte: $start, _lte: $end}})

Materialized Views

OperationGraphQL
Daily summarydaily_usage_summary(where: {application_id: {_eq: $appId}}, order_by: {day: desc})
Model performancemodel_performance_summary(where: {application_id: {_eq: $appId}}, order_by: {time_bucket: desc})
Cost analysiscost_analysis_by_app(where: {application_id: {_eq: $appId}}, order_by: {date: desc}, limit: $days)
Error analysiserror_analysis(where: {application_id: {_eq: $appId}}, order_by: {time_bucket: desc}, limit: $hours)
Token usage trendstoken_usage_trends(where: {application_id: {_eq: $appId}}, order_by: {date: desc}, limit: $days)
Endpoint summary (30d)usage_endpoint_summary_30d(where: {application_id: {_eq: $appId}}, order_by: {total_cost_pusd: desc_nulls_last})
Pricing historypricing_rates_history_by_pk(pricing_history_id: $id)

Revenue

OperationGraphQL
Revenue aggregationbilling_ledger_aggregate(where: {type: {_eq: "subscription_fee"}, metadata: {_contains: {application_id: $appId}}, created_at: {_gte: $start}})
Revenue by planbilling_ledger(where: {type: {_eq: "subscription_fee"}, metadata: {_contains: {application_id: $appId}}})
Last updated on