Usage Tracking
How RelayPlane tracks token usage, costs, and request metrics across all providers.
Telemetry Events
Every request through the proxy generates a telemetry event with the following schema:
1interface TelemetryEvent {2 device_id: string; // Anonymous random ID3 task_type: string; // Inferred from token patterns4 model: string; // Model used (e.g., "claude-sonnet-4-6")5 tokens_in: number; // Input tokens6 tokens_out: number; // Output tokens7 latency_ms: number; // Request latency8 success: boolean; // Whether request succeeded9 cost_usd: number; // Estimated cost in USD10 timestamp: string; // ISO 8601 timestamp11 requested_model?: string; // Original model before routing12 cache_creation_tokens?: number; // Anthropic cache creation tokens13 cache_read_tokens?: number; // Anthropic cache read tokens14}Cost Estimation
Costs are calculated using per-model pricing tables. The proxy knows pricing for all supported models:
| Model | Input (per 1M tokens) | Output (per 1M tokens) |
|---|---|---|
| Claude Opus 4 | $15.00 | $75.00 |
| Claude Sonnet 4 | $3.00 | $15.00 |
| Claude 3.5 Haiku | $0.80 | $4.00 |
| GPT-4o | $2.50 | $10.00 |
| GPT-4o Mini | $0.15 | $0.60 |
| Gemini 2.5 Pro | $1.25 | $10.00 |
| Gemini 2.0 Flash | $0.10 | $0.40 |
Anthropic Cache Token Handling
When Anthropic prompt caching is used, cost estimation accounts for the different pricing tiers:
- Cache creation tokens — 1.25× the base input price
- Cache read tokens — 0.1× the base input price (90% discount)
- Regular input tokens — standard input price
Local Storage
Telemetry events are stored locally in two formats:
~/.relayplane/telemetry.jsonl— Append-only JSONL file of all events~/.relayplane/history.jsonl— Rolling request history (max 10,000 entries, 7-day retention)
Stats Collector
The proxy maintains a rolling 1-hour statistics window with:
- Total, proxied, and direct request counts
- Success/failure counts
- Latency percentiles (p50, p95, p99)
- Circuit breaker state transitions
Access stats via the /status endpoint or the dashboard.
Dashboard Endpoints
The proxy exposes telemetry data via REST endpoints:
GET /v1/telemetry/stats?days=7— Summary stats with model breakdownGET /v1/telemetry/runs?limit=50— Recent request historyGET /v1/telemetry/savings— Cost savings analysisGET /v1/telemetry/health— Per-provider health status
Web Dashboard: Visit
http://localhost:4100/dashboard while the proxy is running for a visual overview of all usage metrics.