GET /api/models
List all active AI models
GET
Authentication
Required: JWT Bearer tokenResponse
Array of active model objects
Side Effects
Database Reads (Lines 29-33):ai_modelstable
WHERE status = 'active'ORDER BY created_at DESC
Authorization
Authentication: Required (JWT Bearer) Who Can Read:- Any authenticated user
- Global model list (not user-specific)
- All users see same models
Permissions
No User Filtering: All authenticated users see same data No Privacy Controls: All active model data visible to authenticated usersResponse Structure
Ordering (Line 32):- Ordered by
created_at DESC(newest models first) - Hardcoded in query, not configurable
- Only
status = 'active'models returned - Inactive models excluded
- No additional filtering parameters
- Returns ALL active models
- Performance depends on number of active models
Edge Cases
- No active models: Returns
{"items": []}(empty array, Line 35) - Model missing description: displayName falls back to modelName (Line 39)
- Null fields: Converted to null in JSON response (Lines 37-42)
- Very large result set: No pagination, could be slow
Error Conditions
| Code | HTTP | Cause | Controller Line |
|---|---|---|---|
| N/A | 401 | JWT missing or invalid | Middleware |
MODELS_ERROR | 500 | Database query failure | 47-55 |
MODELS_ERROR | 500 | Supabase connection error | 47-55 |
- All exceptions return 500
- Exception message exposed to client
Field Mapping
Column → Response Mapping (Lines 35-43):Behavioral Guarantees
Data Staleness: Not specified by API contract- Caching behavior not enforced by server contract
- Real-time database query (no caching documented in controller)
- Models added/removed during request processing may not be reflected
- Partial results not enforced by server contract
Performance Characteristics
Query Complexity: Simple SELECT with WHERE and ORDER BY Index Requirements:ai_models.statusshould be indexedai_models.created_atshould be indexed for sorting
Use Cases
Model Selection:- Populate model dropdown in UI
GetRandomModelAsyncservice queries this dataGetTwoRandomModelsAsyncfor dual-chat
- Determine available providers
- Get API endpoints for model routing
- Show model names and descriptions to users
Status Values
Filtered Value:"active" (Line 32)
Other Possible Values (not returned):
"inactive": Models disabled/deprecated"testing": Models in beta- Behavior not enforced by server contract (database schema-dependent)
Provider Information
apiUrl Field (Line 41):- Full provider API endpoint
- Used by chat providers for routing
- Exposed to authenticated clients