Skip to main content
GET
/
api
/
arena
/
model-stats
curl -X GET 'http://localhost:5079/api/arena/model-stats' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN'
{
  "items": [
    {
      "model_id": "model-uuid-1",
      "model_name": "llama-3.3-70b-versatile",
      "display_name": "Llama 3.3 70B",
      "provider": "groq",
      "total_votes": 1523,
      "wins": 892,
      "losses": 431,
      "ties": 200,
      "win_rate": 0.585,
      "elo_rating": 1687,
      "last_voted_at": "2024-01-15T10:30:00.000Z"
    },
    {
      "model_id": "model-uuid-2",
      "model_name": "mixtral-8x7b-32768",
      "display_name": "Mixtral 8x7B",
      "provider": "groq",
      "total_votes": 1201,
      "wins": 645,
      "losses": 398,
      "ties": 158,
      "win_rate": 0.537,
      "elo_rating": 1542,
      "last_voted_at": "2024-01-15T09:15:00.000Z"
    }
  ]
}

Authentication

Required: JWT Bearer token

Response

items
array
Array of model statistics objects
curl -X GET 'http://localhost:5079/api/arena/model-stats' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN'
{
  "items": [
    {
      "model_id": "model-uuid-1",
      "model_name": "llama-3.3-70b-versatile",
      "display_name": "Llama 3.3 70B",
      "provider": "groq",
      "total_votes": 1523,
      "wins": 892,
      "losses": 431,
      "ties": 200,
      "win_rate": 0.585,
      "elo_rating": 1687,
      "last_voted_at": "2024-01-15T10:30:00.000Z"
    },
    {
      "model_id": "model-uuid-2",
      "model_name": "mixtral-8x7b-32768",
      "display_name": "Mixtral 8x7B",
      "provider": "groq",
      "total_votes": 1201,
      "wins": 645,
      "losses": 398,
      "ties": 158,
      "win_rate": 0.537,
      "elo_rating": 1542,
      "last_voted_at": "2024-01-15T09:15:00.000Z"
    }
  ]
}

Side Effects

Database Reads (Line 88):
var stats = await _modelStatsService.GetModelStatsAsync();
Tables Read:
  • ai_models table: Model metadata
  • model_votes table: Aggregated vote counts
  • Potential JOIN with comparisons table (service-level)
No Database Writes: Read-only endpoint Query Characteristics:
  • Aggregation query (COUNT, SUM operations assumed)
  • Potentially expensive for large vote datasets

Authorization

Authentication: Required (JWT Bearer) Who Can Read:
  • Any authenticated user
Data Visibility:
  • 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 users

Response Structure

Ordering: Not specified by API contract (implementation-defined)
  • Ordering algorithm not enforced by server contract
  • No explicit sort parameter in controller
Pagination: Not supported
  • Returns ALL models
  • Could cause performance issues if many models
Filtering: Not supported
  • No query parameters for filtering by provider, win_rate, etc.

Edge Cases

  1. No votes exist: Behavior not enforced by server contract (empty array likely)
  2. Model has zero votes: Inclusion behavior not enforced by server contract
  3. Models without votes: Inclusion behavior not enforced by server contract
  4. Inactive models: Inclusion behavior not enforced by server contract
  5. Very large result set: No pagination, performance not guaranteed

Error Conditions

CodeHTTPCauseController Line
N/A401JWT missing or invalidMiddleware
STATS_ERROR500Service exception92-100
Exception Handling (Lines 92-100):
catch (Exception ex) {
    return StatusCode(500, new { error = ex.Message, code = "STATS_ERROR" });
}
  • 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
Consistency: Not guaranteed
  • Votes in progress may not be reflected
  • Consistency model not enforced by server contract
Completeness: Not specified by API contract

Calculation Methods

Win Rate (service-level):
  • Calculation formula not enforced by server contract
  • Behavior when total_votes = 0 not specified by API contract
Elo Rating (service-level):
  • Calculation algorithm not documented in controller
  • Null handling not enforced by server contract
Ties/Losses Counting (service-level):
  • 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
Index Requirements:
  • model_votes.model_id should be indexed
  • model_votes.created_at for last_voted_at
Response Size: Unbounded (proportional to number of models) Caching: Not enforced by server contract
  • 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
Model Selection:
  • Used by GetTopperAndRandomModelAsync for dual-chat topper mode
  • Selects highest-rated model
Analytics:
  • 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)
Stale Data Risk: Data freshness not enforced by server contract Real-Time Guarantee: Not specified by API contract