The Models API provides endpoints for creating, managing, and using machine learning models on the Plexe Platform.

Models Endpoints

List Models

GET /models/list

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token

Retrieves a list of all models in your account.

Query Parameters

ParameterTypeRequiredDescription
limitintegerNoMaximum number of models to return (default: 20, max: 100)
offsetintegerNoNumber of models to skip (default: 0)
statusstringNoFilter by status: DRAFT, BUILDING, READY, ERROR
sort_bystringNoField to sort by: created_at, name (default: created_at)
sort_dirstringNoSort direction: asc or desc (default: desc)

Response

{
  "models": [
    {
      "model_id": "mdl_abc123def456",
      "name": "Customer Churn Predictor",
      "intent": "Predict customer churn based on usage patterns",
      "status": "READY",
      "deployment_status": "DEPLOYED",
      "created_at": "2023-06-15T08:15:45Z",
      "updated_at": "2023-06-15T10:30:12Z"
    },
    {
      "model_id": "mdl_ghi789jkl012",
      "name": "Product Recommendation Engine",
      "intent": "Recommend products based on purchase history",
      "status": "BUILDING",
      "deployment_status": null,
      "created_at": "2023-06-16T14:22:33Z",
      "updated_at": "2023-06-16T14:22:33Z"
    }
  ],
  "pagination": {
    "total": 15,
    "limit": 20,
    "offset": 0,
    "has_more": false
  }
}

Get Model

GET /models/{model_id}

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token

Retrieves detailed information about a specific model.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to get

Response

{
  "model_id": "mdl_abc123def456",
  "name": "Customer Churn Predictor",
  "intent": "Predict customer churn based on usage patterns",
  "description": "Model predicts likelihood of customer churn in the next 30 days",
  "status": "READY",
  "deployment_status": "DEPLOYED",
  "endpoint": "https://api.plexe.ai/predict/dep_mno345pqr678",
  "metrics": {
    "accuracy": 0.92,
    "precision": 0.88,
    "recall": 0.85,
    "f1_score": 0.86
  },
  "dataset_id": "ds_stu901vwx234",
  "input_schema": {
    "usage_minutes": "float",
    "subscription_months": "integer",
    "support_tickets": "integer",
    "plan_type": "string"
  },
  "output_schema": {
    "churn_probability": "float"
  },
  "created_at": "2023-06-15T08:15:45Z",
  "updated_at": "2023-06-15T10:30:12Z",
  "created_by": "user_yza567bcd890",
  "tags": ["production", "customer-retention"]
}

Create Model

POST /models/build

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token
Content-Typeapplication/jsonRequired

Initiates the process of building a new model. This is an asynchronous operation that returns a job ID for tracking progress.

Request Body

{
  "intent": "Predict customer churn based on usage patterns",
  "name": "Customer Churn Predictor",
  "description": "Model predicts likelihood of customer churn in the next 30 days",
  "dataset_id": "ds_stu901vwx234",
  "input_schema": {
    "usage_minutes": "float",
    "subscription_months": "integer",
    "support_tickets": "integer",
    "plan_type": "string"
  },
  "output_schema": {
    "churn_probability": "float"
  },
  "tags": ["production", "customer-retention"]
}
FieldTypeRequiredDescription
intentstringYesNatural language description of the model purpose
namestringNoDisplay name for the model (default: generated)
descriptionstringNoDetailed description of the model
dataset_idstringYesID of the dataset to use for training
input_schemaobjectNoSchema of input fields (inferred if not provided)
output_schemaobjectNoSchema of output fields (inferred if not provided)
tagsarrayNoList of tags for organizing models

Response

{
  "job_id": "job_def456ghi789",
  "status": "PENDING",
  "model_id": "mdl_jkl012mno345",
  "created_at": "2023-06-16T15:00:00Z"
}

Deploy Model

POST /models/{model_id}/deploy

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token
Content-Typeapplication/jsonRequired

Deploys a model, making it available for predictions. This is an asynchronous operation.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to deploy

Request Body

{
  "environment": "production",
  "replicas": 2,
  "auto_scale": true
}
FieldTypeRequiredDescription
environmentstringNoDeployment environment (default: production)
replicasintegerNoNumber of replicas to deploy (default: 1)
auto_scalebooleanNoWhether to enable auto-scaling (default: true)

Response

{
  "deployment_id": "dep_pqr678stu901",
  "model_id": "mdl_jkl012mno345",
  "status": "DEPLOYING",
  "endpoint": "https://api.plexe.ai/predict/dep_pqr678stu901",
  "environment": "production",
  "replicas": 2,
  "auto_scale": true,
  "created_at": "2023-06-16T15:10:00Z"
}

Make Prediction

POST /models/predict/{deployment_id}

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token
Content-Typeapplication/jsonRequired

Makes a prediction using a deployed model.

Path Parameters

ParameterTypeRequiredDescription
deployment_idstringYesID of the deployed model to use

Request Body

Input data matching the model’s input schema. Example:

{
  "usage_minutes": 120.5,
  "subscription_months": 8,
  "support_tickets": 2,
  "plan_type": "premium"
}

Response

Output data matching the model’s output schema. Example:

{
  "request_id": "req_vwx234yza567",
  "result": {
    "churn_probability": 0.27
  },
  "model_id": "mdl_jkl012mno345",
  "created_at": "2023-06-16T15:15:00Z"
}

Update Model

PATCH /models/{model_id}

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token
Content-Typeapplication/jsonRequired

Updates metadata for an existing model.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to update

Request Body

{
  "name": "Enhanced Customer Churn Predictor",
  "description": "Updated model with improved accuracy",
  "tags": ["production", "customer-retention", "v2"]
}
FieldTypeRequiredDescription
namestringNoNew display name for the model
descriptionstringNoNew description of the model
tagsarrayNoUpdated list of tags

Response

{
  "model_id": "mdl_jkl012mno345",
  "name": "Enhanced Customer Churn Predictor",
  "description": "Updated model with improved accuracy",
  "tags": ["production", "customer-retention", "v2"],
  "updated_at": "2023-06-16T16:00:00Z"
}

Delete Model

DELETE /models/{model_id}

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token

Deletes a model and its deployments.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to delete

Response

{
  "model_id": "mdl_jkl012mno345",
  "status": "DELETED",
  "deleted_at": "2023-06-16T17:00:00Z"
}

Model Versions

List Model Versions

GET /models/{model_id}/versions

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token

Lists all versions of a specific model.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to list versions for

Response

{
  "model_id": "mdl_jkl012mno345",
  "versions": [
    {
      "version_id": "ver_bcd890efg123",
      "version": 3,
      "status": "READY",
      "metrics": {
        "accuracy": 0.94,
        "precision": 0.92,
        "recall": 0.90,
        "f1_score": 0.91
      },
      "created_at": "2023-06-20T09:00:00Z"
    },
    {
      "version_id": "ver_hij456klm789",
      "version": 2,
      "status": "READY",
      "metrics": {
        "accuracy": 0.92,
        "precision": 0.88,
        "recall": 0.85,
        "f1_score": 0.86
      },
      "created_at": "2023-06-17T14:00:00Z"
    },
    {
      "version_id": "ver_nop012qrs345",
      "version": 1,
      "status": "READY",
      "metrics": {
        "accuracy": 0.89,
        "precision": 0.85,
        "recall": 0.82,
        "f1_score": 0.83
      },
      "created_at": "2023-06-16T15:00:00Z"
    }
  ]
}

Create Model Version

POST /models/{model_id}/versions

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token
Content-Typeapplication/jsonRequired

Creates a new version of an existing model. This is useful for iterative model improvement.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to create version for

Request Body

{
  "dataset_id": "ds_tuv678wxy901",
  "intent": "Predict customer churn with added seasonality factor",
  "input_schema": {
    "usage_minutes": "float",
    "subscription_months": "integer",
    "support_tickets": "integer",
    "plan_type": "string",
    "season": "string"
  }
}
FieldTypeRequiredDescription
dataset_idstringYesID of the dataset to use for training
intentstringNoUpdated intent (defaults to original if omitted)
input_schemaobjectNoUpdated input schema (defaults to original)
output_schemaobjectNoUpdated output schema (defaults to original)

Response

{
  "job_id": "job_zab234cde567",
  "status": "PENDING",
  "model_id": "mdl_jkl012mno345",
  "version_id": "ver_fgh890ijk123",
  "version": 4,
  "created_at": "2023-06-21T10:00:00Z"
}

Model Deployments

List Deployments

GET /models/{model_id}/deployments

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token

Lists all active deployments for a model.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to list deployments for

Response

{
  "model_id": "mdl_jkl012mno345",
  "deployments": [
    {
      "deployment_id": "dep_lmn456opq789",
      "environment": "production",
      "status": "ACTIVE",
      "version_id": "ver_bcd890efg123",
      "version": 3,
      "endpoint": "https://api.plexe.ai/predict/dep_lmn456opq789",
      "replicas": 2,
      "auto_scale": true,
      "created_at": "2023-06-20T10:00:00Z"
    },
    {
      "deployment_id": "dep_rst012uvw345",
      "environment": "staging",
      "status": "ACTIVE",
      "version_id": "ver_hij456klm789",
      "version": 2,
      "endpoint": "https://api.plexe.ai/predict/dep_rst012uvw345",
      "replicas": 1,
      "auto_scale": false,
      "created_at": "2023-06-19T16:00:00Z"
    }
  ]
}

Undeploy Model

DELETE /models/{model_id}/deployments/{deployment_id}

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token

Removes a specific deployment of a model.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model
deployment_idstringYesID of the deployment to remove

Response

{
  "model_id": "mdl_jkl012mno345",
  "deployment_id": "dep_rst012uvw345",
  "status": "UNDEPLOYING",
  "undeployed_at": "2023-06-21T11:00:00Z"
}

Batch Predictions

Create Batch Prediction Job

POST /models/{model_id}/batch-predict

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token
Content-Typeapplication/jsonRequired

Creates a batch prediction job for processing multiple inputs at once.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model to use for prediction

Request Body

{
  "dataset_id": "ds_xyz678abc901",
  "output_format": "json",
  "include_explanations": true
}
FieldTypeRequiredDescription
dataset_idstringYesID of the dataset containing inputs
output_formatstringNoFormat for results: json or csv (default: json)
include_explanationsbooleanNoWhether to include prediction explanations

Response

{
  "batch_job_id": "bjob_bcd234efg567",
  "model_id": "mdl_jkl012mno345",
  "dataset_id": "ds_xyz678abc901",
  "status": "PENDING",
  "progress": 0,
  "estimated_completion": "2023-06-21T12:30:00Z",
  "created_at": "2023-06-21T12:00:00Z"
}

Get Batch Prediction Results

GET /models/{model_id}/batch-predict/{batch_job_id}

Headers

HeaderValueDescription
AuthorizationBearer TOKENRequired. Your API access token

Retrieves the status and results of a batch prediction job.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesID of the model used for prediction
batch_job_idstringYesID of the batch prediction job

Response

{
  "batch_job_id": "bjob_bcd234efg567",
  "model_id": "mdl_jkl012mno345",
  "dataset_id": "ds_xyz678abc901",
  "status": "COMPLETED",
  "progress": 100,
  "row_count": 5000,
  "completed_at": "2023-06-21T12:25:00Z",
  "results_url": "https://api.plexe.ai/download/bjob_bcd234efg567.json",
  "expires_at": "2023-06-28T12:25:00Z"
}

Error Codes

HTTP StatusError CodeDescription
400invalid_requestMalformed request or missing parameters
401unauthorizedMissing or invalid API key
403forbiddenInsufficient permissions for operation
404not_foundModel, deployment, or resource not found
409conflictResource conflict (e.g., duplicate name)
422validation_errorInvalid input data or schema
429rate_limit_exceededAPI rate limit exceeded
500internal_errorServer-side error
503service_unavailableService temporarily unavailable

For all API errors, the response will include details about the error and, where appropriate, suggestions for resolution.