MonoRelay tracks usage statistics in two layers: a fast in-memory counter that persists toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Excurs1ons/MonoRelay/llms.txt
Use this file to discover all available pages before exploring further.
data/stats.json on every update, and a SQLite-backed log database that enables richer historical queries. The stats API surfaces both layers in a single response and also exposes per-client usage tracking from the dedicated usage tracker.
Authentication
All stats endpoints require a valid JWT token:Endpoints
GET /api/stats
The primary stats endpoint. Returns a composite object combining in-memory global counters, persistent database aggregates, per-key statistics, and per-model detail breakdowns.In-memory stats accumulated since the last restart or reset:
total_requests— total number of proxied requeststotal_errors— number of requests that returned an errorerror_rate—total_errors / total_requeststotal_tokens_in— cumulative input tokenstotal_tokens_out— cumulative output tokenstotal_cache_hit_tokens— tokens served from upstream prompt cachetotal_tokens— combined input and output tokensestimated_total_cost— estimated USD spendrequests_by_provider—{"openrouter": 142, "anthropic": 58}requests_by_model—{"claude-opus-4-5": 34, ...}errors_by_provider— error counts by provider name
Aggregates computed from the SQLite request log:
total_requests— all logged requests (survives restarts)total_cost— total estimated cost from log recordsavg_latency_ms— average end-to-end latencyinput_tokens— total input tokens across all log entriesoutput_tokens— total output tokenscache_hit_tokens— total cache-hit tokens from log entries
Per-provider, per-key health data from the key manager: request counts, failure counts, cooldown state, and quota usage.
Per-model detail from the stats tracker. Each key is a model name:
requests— total requests using that modelerrors— error count for that modeltotal_tokens_in/total_tokens_out— token totalstotal_cache_hit_tokens— cache-hit tokens for that modelavg_first_token_ms— exponential-decay weighted average TTFT in msavg_speed_tps— exponential-decay weighted average output tokens per secondstreaming_requests— number of streaming requests
GET /api/stats/enhanced
Returns an expanded stats object that includes per-provider breakdowns enriched with provider configuration (cost rates, key counts) and a flat key health inventory useful for dashboards.One entry per enabled provider:
enabled— provider enabled statetotal_requests— requests routed to this providertotal_errors— errors from this providerkeys.total/keys.enabled— key inventory countscost_per_m_input/cost_per_m_output— configured pricing rates
Flat list of all keys across all providers, each entry containing
provider, label, enabled, total_requests, total_failures, is_available, cooldown_until, quota_limit, quota_used, rate_limit_rps, and expires_at.GET /api/stats/file
Return the rawstats.json file content as a string. Useful for backup or cross-instance synchronization.
PUT /api/stats/file
Replace thestats.json file content and immediately reload the in-memory stats from the new content.
JSON string to write as the new stats file content.
POST /api/stats/reset
Clear all in-memory and persisted statistics. Also deletes thestats.json file and clears the SQLite request log.
This operation is irreversible. Both the stats file and the full request log database will be cleared. Export or back up data before calling this endpoint.
Per-client usage stats
GET /api/usage/stats
Return usage statistics broken down by client identity (the username or access-key prefix that made each request). Passclient_id as a query parameter to retrieve stats for a single client.
POST /api/usage/clear
Reset per-client usage counters. Passclient_id to clear only that client’s data, or omit it to clear all clients.
Analytics endpoints
GET /api/analytics/overview
Aggregate cost and usage by provider and model over a date range. Defaults to the last 7 days.| Query param | Description |
|---|---|
start_date | Start date in YYYY-MM-DD format |
end_date | End date in YYYY-MM-DD format |
Total requests in the date range.
Estimated total cost in USD.
{"input": 84200, "output": 31500} — token totals for the period.Per-provider request counts and costs.
Per-model request counts, costs, and token totals.
GET /api/analytics/slow-queries
List requests that exceeded a latency threshold, ordered by first-token latency descending.| Query param | Default | Description |
|---|---|---|
threshold_ms | 2000 | Minimum first-token latency in ms |
start_date | 7 days ago | Start of date range |
end_date | today | End of date range |
limit | 100 | Maximum results |
GET /api/analytics/cost-distribution
Return cost broken down by provider and by model as percentage shares, useful for pie-chart visualizations in dashboards.Dashboard integration
The MonoRelay dashboard reads all of these endpoints automatically. The stats overview panel usesGET /api/stats, the model breakdown table uses data.models, and the real-time activity feed uses GET /api/logs/stream. You can build your own monitoring dashboards using the same API surface that the built-in UI relies on.