API Reference / serving /

schemas.py

Pydantic Schemas - Request and response models for the REST API.

Defines the data structures for API requests and responses, providing validation and automatic documentation.

Classes

PredictRequest

class serving.schemas.PredictRequest(BaseModel)

Request schema for predictions.

Attributes

features
List[List[Union[float, int]]]
2D array of input features. Shape: (n_samples, n_features)

PredictResponse

class serving.schemas.PredictResponse(BaseModel)

Response schema for predictions.

Attributes

predictions
List[Any]
Model predictions for each input sample
model_id
str
Identifier of the model used
model_class
Optional[str] = None
Class name of the model

PredictProbaResponse

class serving.schemas.PredictProbaResponse(BaseModel)

Response schema for probability predictions.

Attributes

probabilities
List[List[float]]
Class probabilities. Shape: (n_samples, n_classes)
classes
Optional[List[Any]] = None
Class labels corresponding to probability columns
model_id
str
Identifier of the model used

LoadModelRequest

class serving.schemas.LoadModelRequest(BaseModel)

Request schema for loading a model.

Attributes

model_id
str
Unique identifier for the model
path
str
Path to the saved model file
metadata
Optional[Dict[str, Any]] = None
Additional metadata to associate with the model

ModelInfoResponse

class serving.schemas.ModelInfoResponse(BaseModel)

Response schema for model information.

Attributes

model_id
str
Model identifier
model_class
Optional[str] = None
Model class name
model_module
Optional[str] = None
Model module path
params
Dict[str, Any] = {}
Model parameters
path
Optional[str] = None
Path to model file
loaded_at
Optional[str] = None
Timestamp when loaded
prediction_count
int = 0
Number of predictions made
metadata
Dict[str, Any] = {}
Custom metadata

ModelListResponse

class serving.schemas.ModelListResponse(BaseModel)

Response schema for listing models.

Attributes

models
List[str]
List of loaded model identifiers
count
int
Number of loaded models

HealthResponse

class serving.schemas.HealthResponse(BaseModel)

Response schema for health check.

Attributes

status
str = 'healthy'
Server health status
version
str
TuiML version
models_loaded
int
Number of models in memory

StatsResponse

class serving.schemas.StatsResponse(BaseModel)

Response schema for server statistics.

Attributes

loaded_models
int
Number of loaded models
max_models
int
Maximum models capacity
total_predictions
int
Total predictions served
models
List[Dict[str, Any]]
Per-model statistics

ErrorResponse

class serving.schemas.ErrorResponse(BaseModel)

Response schema for errors.

Attributes

error
str
Error message
detail
Optional[str] = None
Detailed error information
model_id
Optional[str] = None
Related model ID if applicable

BatchPredictRequest

class serving.schemas.BatchPredictRequest(BaseModel)

Request schema for batch predictions across multiple models.

Attributes

requests
List[Dict[str, Any]]
List of prediction requests with model_id and features

BatchPredictResponse

class serving.schemas.BatchPredictResponse(BaseModel)

Response schema for batch predictions.

Attributes

results
List[Dict[str, Any]]
List of prediction results or errors
successful
int
Number of successful predictions
failed
int
Number of failed predictions