GET /api/arena/model-stats
Retrieve model performance statistics
GET
Authentication
Required: JWT Bearer tokenResponse
Array of model statistics objects
Side Effects
Database Reads (Line 88):ai_modelstable: Model metadatamodel_votestable: Aggregated vote counts- Potential JOIN with
comparisonstable (service-level)
- Aggregation query (COUNT, SUM operations assumed)
- Potentially expensive for large vote datasets
Authorization
Authentication: Required (JWT Bearer) Who Can Read:- Any authenticated user
- Global statistics (not user-specific)
- All users see same data
Permissions
No User Filtering: Statistics global across all users No Privacy Controls: All model performance data public to authenticated usersResponse Structure
Ordering: Not specified by API contract (implementation-defined)- Ordering algorithm not enforced by server contract
- No explicit sort parameter in controller
- Returns ALL models
- Could cause performance issues if many models
- No query parameters for filtering by provider, win_rate, etc.
Edge Cases
- No votes exist: Behavior not enforced by server contract (empty array likely)
- Model has zero votes: Inclusion behavior not enforced by server contract
- Models without votes: Inclusion behavior not enforced by server contract
- Inactive models: Inclusion behavior not enforced by server contract
- Very large result set: No pagination, performance not guaranteed
Error Conditions
| Code | HTTP | Cause | Controller Line |
|---|---|---|---|
| N/A | 401 | JWT missing or invalid | Middleware |
STATS_ERROR | 500 | Service exception | 92-100 |
- All service exceptions return 500
- Exception message exposed to client
Behavioral Guarantees
Data Staleness: Not specified by API contract- Cache behavior implementation-defined and not guaranteed
- Real-time vs. cached not enforced by server contract
- Votes in progress may not be reflected
- Consistency model not enforced by server contract
Calculation Methods
Win Rate (service-level):- Calculation formula not enforced by server contract
- Behavior when total_votes = 0 not specified by API contract
- Calculation algorithm not documented in controller
- Null handling not enforced by server contract
- Vote counting logic not enforced by server contract
- Increment semantics implementation-defined and not guaranteed
Performance Characteristics
Query Complexity: Depends on service implementation- Simple aggregation: Fast
- Complex Elo calculation: Slower
model_votes.model_idshould be indexedmodel_votes.created_atfor last_voted_at
- Cache behavior implementation-defined and not guaranteed
- Cache invalidation strategy not specified by API contract
Use Cases
Leaderboard Display:- Sort by win_rate or elo_rating
- Display top N models
- Used by
GetTopperAndRandomModelAsyncfor dual-chat topper mode - Selects highest-rated model
- Track model performance over time
- Compare provider effectiveness
Data Freshness
Update Trigger: Vote submission endpoint- Stats updated when vote recorded
- Update timing not enforced by server contract (immediate vs. batch)