Base URL
All ML endpoints are prefixed with/v1/ml and typically accessed through the API gateway:
Authentication
All endpoints require authentication via JWT token or internal service key.
JWT Token (External Clients)
Internal Service Key
Endpoints
Health Check
Basic health check endpoint without authentication.
Request
Response
Predict Demand
Generate demand forecast for a specific vehicle segment.
sgivu.ml.predict or internal service key
Request Schema
Request Parameters
Vehicle category:
CAR or MOTORCYCLEVehicle manufacturer (e.g., TOYOTA, HONDA, FORD)
Vehicle model name (e.g., COROLLA, CIVIC, F-150)
Specific vehicle trim/version (e.g., “XEI 2.0”, “EX-L”, “LARIAT”)
Number of months to forecast ahead (1-24)
- Minimum: 1
- Maximum: 24
- Default: 6
Confidence level for prediction intervals (0.5-0.99)
- Minimum: 0.50 (50%)
- Maximum: 0.99 (99%)
- Default: 0.95 (95%)
- Common values: 0.80, 0.90, 0.95, 0.99
Response Schema
Response Fields
Array of monthly forecast points
Timestamp-based version identifier of the model used (format:
YYYYMMDD_HHMMSS)Performance metrics from model training
rmse: Root Mean Squared Errormae: Mean Absolute Errormape: Mean Absolute Percentage Errorr2: R-squared (coefficient of determination)residual_std: Standard deviation of residuals (used for CI calculation)
Example Request
Predict with History
Generate forecast and return historical sales data for visualization.
sgivu.ml.predict or internal service key
This endpoint is ideal for building charts that show both historical trends and future predictions.
Request Schema
Identical to/predict endpoint (see above).
Response Schema
Additional Response Fields
Array of historical monthly sales data
Normalized segment identifiers used for the prediction
vehicle_type: Canonicalized vehicle typebrand: Canonicalized brand namemodel: Canonicalized model nameline: Canonicalized line/trim
ISO 8601 timestamp when the model was trained
Example Request
Retrain Model
Trigger model retraining with fresh data from the database.
sgivu.ml.retrain or internal service key
Request Schema
Request Parameters
Start date for training data (ISO 8601 format: YYYY-MM-DD)If omitted, uses all available historical data.
End date for training data (ISO 8601 format: YYYY-MM-DD)If omitted, uses data up to the current date.
Response Schema
Response Fields
Unique version identifier for the new model (timestamp-based)
Performance metrics from model evaluation
rmse: Lower is better (same units as target variable)mae: Mean absolute errormape: Percentage error (0.072 = 7.2%)r2: Closer to 1.0 is betterresidual_std: Used for confidence interval calculations
ISO 8601 timestamp when training completed
Dataset split information
train: Number of samples used for trainingtest: Number of samples used for evaluationtotal: Total samples in dataset
Example Requests
Get Latest Model
Retrieve metadata for the currently active model.
sgivu.ml.models or internal service key
Request
Response Schema
Response Fields
Model version identifier
Training completion timestamp
Target variable name (typically
sales_count)List of feature names used by the model
Performance metrics of the selected best model
Comparison of all evaluated models during trainingShows which algorithm performed best and by how much.
Number of samples in training set
Number of samples in test set
Total dataset size
Example
Error Responses
All endpoints follow consistent error response format:Common Error Codes
400 Bad Request
Invalid input parameters or missing required fields
401 Unauthorized
Missing or invalid authentication token
403 Forbidden
Insufficient permissions for the requested operation
404 Not Found
Requested resource doesn’t exist
422 Unprocessable Entity
Validation error in request payload
500 Internal Server Error
Unexpected server error (check logs)
Rate Limiting
Rate limiting is typically handled at the API gateway level. Check gateway documentation for specific limits.
OpenAPI Specification
The complete OpenAPI 3.0 specification is available at:SDK Examples
For more comprehensive examples and client library usage, see:- Training Process - Feature engineering and model training details
- Model Management - Versioning and lifecycle management
- Frontend Integration - Building client applications
Next Steps
Try the API
Test endpoints using the interactive docs at
/docsUnderstanding Predictions
Learn how forecasts are generated
Model Versioning
Manage and compare model versions
Authentication
Configure JWT and permissions