Skip to content

5.8.2.3 Models

The Models domain of ai-model-platform. The model registry: models, their versions trained by a run, which version is deployed and the batch scorings that write predictions back to farm. A retired version refuses calls. Follows Model, ModelVersion and ScoringBatch of the data model (req 74 to 76, added with D7). It is one API, with its own contract and its own version.

5.8.2.3.1 Versions

Version Status Prod URL Contract
v1 Proposed https://ai-model-platform.moonitoring.com/models/v1 models/v1/openapi.yaml

The resources follow the data model. Follows Model, ModelVersion and ScoringBatch (req 74 to 76), added to the data model with D7 on 2026-10-30 because ai-model-platform.models.manage (req 1006.25) spoke of a registry the model did not describe.

5.8.2.3.2 Operations

Every operation names who calls it and the capability it checks (x-moonitoring-audience, x-moonitoring-capability in the contract); every capability is in the catalog of the data model (req 1002, 1006). Lists are paged by cursor, writes that create something carry an Idempotency-Key, errors are Problem Details.

Operation Request Who Capability
List models GET /models Staff ai-model-platform.models.read
Register a model POST /models Staff ai-model-platform.models.manage
Read a model GET /models/{model_id} Staff ai-model-platform.models.read
Retire a model POST /models/{model_id}/retire Staff ai-model-platform.models.manage
List a model's versions GET /models/{model_id}/versions Staff ai-model-platform.models.read
Register a version POST /models/{model_id}/versions Staff ai-model-platform.models.manage
Deploy a version POST /model-versions/{version_id}/deploy Staff ai-model-platform.models.manage
Retire a version POST /model-versions/{version_id}/retire Staff ai-model-platform.models.manage
List scoring batches GET /scoring-batches Staff ai-model-platform.models.read
Start a scoring batch POST /scoring-batches Staff ai-model-platform.models.manage
Read a scoring batch GET /scoring-batches/{batch_id} Staff ai-model-platform.models.read

5.8.2.3.3 gRPC

farm lists the deployed models for the Organization Dashboard and asks for on-demand predictions behind farm.models.use and the model's entitlement feature.

Service RPC Callers
ModelsService ListModels farm
ModelsService Predict farm

The contract is models.proto, package moonitoring.ai_model_platform.models.v1:

// Proposed contract, version 1. Status: proposal for review, not confirmed design.
//
// The model APIs other systems call. A prediction reads canonical inputs at a write number and is recorded as a
// ModelRun; the caller stores the outputs as computed records.
// Callers: farm (ListModels for the Organization Dashboard's catalog; Predict for on-demand predictions behind
// farm.models.use and the model's entitlement feature; req 62, 1002.24, 1006.25).
// Deadline: ListModels 2 s, Predict 30 s.
// The callers listed are authentication only (decided 2026-11-11): each RPC below names who may call it and what
// it sees, and refuses anyone else with PERMISSION_DENIED.
// x-moonitoring-callers: farm
// x-moonitoring-requirements: 62, 1002.24, 1006.25
syntax = "proto3";

package moonitoring.ai_model_platform.models.v1;

service ModelsService {
  // The models with a deployed version, with the feature that gates each one.
  // Callers: farm only. Sees: the catalog of deployed models, no farm data.
  rpc ListModels(ListModelsRequest) returns (ListModelsResponse);
  // Predictions for animals of one farm with the deployed version of a model.
  // Callers: farm only, after it checked farm.models.use and the model's entitlement. Sees: the predictions for
  // the farm and the animals of the request.
  rpc Predict(PredictRequest) returns (PredictResponse);
}

message ListModelsRequest {}

message ListModelsResponse {
  repeated Model models = 1;
}

message Model {
  string id = 1;
  string name = 2;
  string description = 3;
  // e.g. farm.models.mastitis.
  string feature = 4;
  OutputKind output_kind = 5;
  string output_observation_type_id = 6;
  string output_event_type = 7;
  string deployed_version = 8;
}

enum OutputKind {
  OUTPUT_KIND_UNSPECIFIED = 0;
  OUTPUT_KIND_OBSERVATION = 1;
  OUTPUT_KIND_EVENT = 2;
}

message PredictRequest {
  string request_id = 1;
  string model_name = 2;
  string farm_id = 3;
  repeated string animal_ids = 4;
  // The write number to read inputs at; 0 means the watermark.
  int64 data_seq = 5;
}

message PredictResponse {
  // The ModelRun recorded for this prediction.
  string model_run_id = 1;
  string model_version_id = 2;
  // The OriginVersion that identifies the model and its version as a ComputedSourceOrigin.
  string origin_version_id = 3;
  repeated Prediction predictions = 4;
}

message Prediction {
  string animal_id = 1;
  // ObservationValue as JSON.
  string value_json = 2;
  // Exact input revisions, for the derivation.
  repeated string input_revision_ids = 3;
}

5.8.2.3.4 Contract v1

Proposed version

v1 is a proposal for review: its endpoints, errors and capabilities were designed from the requirements and the flows and are not confirmed. It leaves proposal with its first release; from then on it changes only as described in Every API Is Versioned.