Models

Models

Register, update, version and run models, and manage the reference data they are explained against.

A model is a feature schema, an output definition and an inference configuration, plus whatever you attach to it: reference data, an uploaded structure, logged predictions, explanations and insights. Address a model by id or slug everywhere. Deleting a model deletes everything attached to it.

#The Model object

Returned by every model endpoint. Single-model reads add explain_methods.

Attributes

idstring
mdl_ identifier.
name / slugstring

Display name and URL-safe slug, unique within the organization. Slugs are derived from the name unless given.

versionstring

Version label, "1" by default. Versions of one model share a lineage_id.

taskstring
binary_classification, multiclass_classification or regression.
frameworkstring
sklearn, pytorch, tensorflow, keras, xgboost, lightgbm, catboost, onnx, huggingface, llm or custom. Informational.
featuresarray

The feature schema, normalised.

outputsobject

Labels, positive label, threshold, name, unit, kind. Binary models always have labels, positive_label and threshold filled in.

inferenceobject

How Kaimei runs the model. Header values are returned as ••••••.

statusstring
active or archived.
project_idstring | null

The project the model belongs to.

reference_rowsinteger

Rows of reference data stored.

predictions_count / explanations_countinteger

Running totals.

last_prediction_at / last_analyzed_attimestamp | null

Activity markers.

explain_methodsarray | null

Methods POST /v1/explanations accepts for this model, recommended first. Only on single-model reads.

tags, metadata, description

Yours. metadata is free-form JSON.

created_at / updated_attimestamp

The Model object
{
  "object": "model",
  "id": "mdl_390bd6d9568f626851ef",
  "name": "Credit risk scorer",
  "slug": "credit-risk-v3",
  "version": "3",
  "description": "Consumer-credit decline model with a utilization × debt-to-income interaction.",
  "framework": "sklearn",
  "task": "binary_classification",
  "features": [
    {
      "name": "income",
      "type": "numeric",
      "unit": "USD/yr",
      "baseline": 65000,
      "min": 0,
      "description": "Annual gross income"
    },
    {
      "name": "credit_score",
      "type": "integer",
      "baseline": 690,
      "min": 300,
      "max": 850,
      "description": "Bureau credit score"
    },
    {
      "name": "utilization",
      "type": "numeric",
      "baseline": 0.35,
      "min": 0,
      "max": 1.5
    },
    …,
    {
      "name": "home_ownership",
      "type": "categorical",
      "categories": ["rent", "mortgage", "own"],
      "baseline": "mortgage"
    }
  ],
  "outputs": {
    "labels": ["approve", "decline"],
    "positive_label": "decline",
    "threshold": 0.5,
    "name": "decision"
  },
  "inference": {"type": "builtin", "name": "credit-risk"},
  "tags": ["finance", "tabular"],
  "metadata": {"owner": "risk-platform"},
  "status": "active",
  "project_id": "prj_40c081b2465e96db2cdc",
  "lineage_id": "mdl_390bd6d9568f626851ef",
  "reference_rows": 600,
  "predictions_count": 192,
  "explanations_count": 12,
  "last_prediction_at": "2026-10-31T22:37:25.682045Z",
  "last_analyzed_at": "2026-10-31T22:37:26.872969Z",
  "created_at": "2026-10-31T22:37:25.397790Z",
  "updated_at": "2026-10-31T22:37:26.872969Z",
  "explain_methods": ["shap", "shapley", "lime", "auto"]
}

#List models

GET/v1/modelsAPI key or session

Models in your organization, most recently updated first. Filters combine.

Query parameters

qstringoptional

Case-insensitive match on name or slug.

statusstringoptional
active or archived.
taskstringoptional

One of the three task types.

project_idstringoptional

Only models in this project (id or slug).

unassignedbooleanoptionaldefault false

Only models in no project. Not with project_id.

limitintegeroptionaldefault 50

1 to 200.

offsetintegeroptionaldefault 0

Returns

A page of Model objects.
page = client.models.list(status="active", limit=20)
for model in page.data:
    print(model.slug, model.task, model.reference_rows)

for model in client.models.iterate(project_id="risk-platform"):   # every page
    ...
curl "https://api.kaimei.ai/v1/models?status=active&limit=20" \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "list",
  "data": [
    {
      "object": "model",
      "id": "mdl_390bd6d9568f626851ef",
      "name": "Credit risk scorer",
      "slug": "credit-risk-v3",
      "version": "3",
      "description": "Consumer-credit decline model with a utilization × debt-to-income interaction.",
      "framework": "sklearn",
      "task": "binary_classification",
      "features": …,
      "outputs": {
        "labels": ["approve", "decline"],
        "positive_label": "decline",
        "threshold": 0.5,
        "name": "decision"
      },
      "inference": {"type": "builtin", "name": "credit-risk"},
      "tags": ["finance", "tabular"],
      "metadata": {"owner": "risk-platform"},
      "status": "active",
      "project_id": "prj_40c081b2465e96db2cdc",
      "lineage_id": "mdl_390bd6d9568f626851ef",
      "reference_rows": 600,
      "predictions_count": 192,
      "explanations_count": 12,
      "last_prediction_at": "2026-10-31T22:37:25.682045Z",
      "last_analyzed_at": "2026-10-31T22:37:26.872969Z",
      "created_at": "2026-10-31T22:37:25.397790Z",
      "updated_at": "2026-10-31T22:37:26.872969Z",
      "explain_methods": null
    },
    …
  ],
  "total": 5,
  "limit": 20,
  "offset": 0,
  "has_more": true
}

#Register a model

POST/v1/modelsAPI key or session

Register a model. Give it a feature schema and a task, or a structure spec from which Kaimei infers both, or a builtin inference that supplies them.

Binary models get labels, positive_label and threshold defaults; multiclass models must name their outputs.labels. Remote image settings are validated against the image features.

Body parameters

namestringrequired

1 to 120 characters.

taskstringoptional

Required unless structure or a built-in inference provides it.

featuresarrayoptional

The feature schema. Required unless provided by structure or a built-in.

slugstringoptional

Unique within the organization; 409 slug_taken if not. Derived from name when omitted.

versionstringoptionaldefault "1"

Version label.

descriptionstringoptional

frameworkstringoptionaldefault "custom"

outputsobjectoptional

Labels, positive label, threshold, name, unit, kind.

inferenceobjectoptionaldefault {"type": "none"}
{"type": "remote", "url": …}, {"type": "builtin", "name": …} or {"type": "none"}. See inference.
structureobjectoptional

A kaimei.structure.v1 spec to store with the model, the same document as PUT …/structure.

project_idstringoptional

Project id or slug to file the model under.

tagsarray of stringsoptional

metadataobjectoptional

Free-form.

Returns

The created Model. 201. Counts against the models quota and the 40-per-hour model limit.
model = client.models.create(
    name="Credit risk (docs)",
    slug="credit-risk-docs",
    task="binary_classification",
    framework="sklearn",
    features=[
        {"name": "income", "type": "numeric", "unit": "USD / year", "min": 0},
        {"name": "credit_score", "type": "integer", "min": 300, "max": 850},
        {"name": "utilization", "type": "numeric", "min": 0, "max": 1},
        {"name": "home_ownership", "type": "categorical", "categories": ["rent", "mortgage", "own"]},
    ],
    outputs={"labels": ["approve", "decline"], "positive_label": "decline", "threshold": 0.5, "name": "decision"},
    inference={"type": "remote", "url": "https://scoring.example.com/predict",
               "headers": {"X-Api-Key": "secret"}, "timeout_s": 10},
    tags=["lending", "pd"],
    metadata={"owner": "risk-platform", "git_sha": "a9adc16"},
    project_id="risk-platform",
)
curl -X POST https://api.kaimei.ai/v1/models \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Credit risk (docs)",
    "slug": "credit-risk-docs",
    "task": "binary_classification",
    "framework": "sklearn",
    "features": [
      {"name": "income", "type": "numeric", "unit": "USD / year", "min": 0},
      {"name": "credit_score", "type": "integer", "min": 300, "max": 850},
      {"name": "utilization", "type": "numeric", "min": 0, "max": 1},
      {"name": "home_ownership", "type": "categorical", "categories": ["rent", "mortgage", "own"]}
    ],
    "outputs": {"labels": ["approve", "decline"], "positive_label": "decline", "name": "decision"},
    "inference": {"type": "remote", "url": "https://scoring.example.com/predict",
                  "headers": {"X-Api-Key": "secret"}, "timeout_s": 10},
    "tags": ["lending", "pd"],
    "project_id": "risk-platform"
  }'
201 CreatedResponse
{
  "object": "model",
  "id": "mdl_c48c5582152e44e34e64",
  "name": "Credit risk (docs)",
  "slug": "credit-risk-docs",
  "version": "1",
  "description": null,
  "framework": "sklearn",
  "task": "binary_classification",
  "features": [
    {
      "name": "income",
      "type": "numeric",
      "min": 0.0,
      "unit": "USD / year"
    },
    {
      "name": "credit_score",
      "type": "integer",
      "min": 300.0,
      "max": 850.0
    },
    …
  ],
  "outputs": {
    "labels": ["approve", "decline"],
    "positive_label": "decline",
    "threshold": 0.5,
    "name": "decision"
  },
  "inference": {
    "type": "remote",
    "url": "https://scoring.example.com/predict",
    "headers": {"X-Api-Key": "••••••"},
    "timeout_s": 10.0
  },
  "tags": ["lending", "pd"],
  "metadata": {"owner": "risk-platform", "git_sha": "a9adc16"},
  "status": "active",
  "project_id": "prj_40c081b2465e96db2cdc",
  "lineage_id": "mdl_c48c5582152e44e34e64",
  "reference_rows": 0,
  "predictions_count": 0,
  "explanations_count": 0,
  "last_prediction_at": null,
  "last_analyzed_at": null,
  "created_at": "2026-10-31T22:40:23.015774Z",
  "updated_at": "2026-10-31T22:40:23.016780Z",
  "explain_methods": null
}

#Retrieve a model

GET/v1/models/{model}API key or session

One model by id or slug, with explain_methods.

Path parameters

modelstringrequired

Model id or slug.

Returns

A Model.
model = client.models.retrieve("credit-risk-v3")
print(model.explain_methods)   # ['shap', 'shapley', 'lime', 'auto']
curl https://api.kaimei.ai/v1/models/credit-risk-v3 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "model",
  "id": "mdl_390bd6d9568f626851ef",
  "name": "Credit risk scorer",
  "slug": "credit-risk-v3",
  "version": "3",
  "description": "Consumer-credit decline model with a utilization × debt-to-income interaction.",
  "framework": "sklearn",
  "task": "binary_classification",
  "features": [
    {
      "name": "income",
      "type": "numeric",
      "unit": "USD/yr",
      "baseline": 65000,
      "min": 0,
      "description": "Annual gross income"
    },
    {
      "name": "credit_score",
      "type": "integer",
      "baseline": 690,
      "min": 300,
      "max": 850,
      "description": "Bureau credit score"
    },
    {
      "name": "utilization",
      "type": "numeric",
      "baseline": 0.35,
      "min": 0,
      "max": 1.5
    },
    …,
    {
      "name": "home_ownership",
      "type": "categorical",
      "categories": ["rent", "mortgage", "own"],
      "baseline": "mortgage"
    }
  ],
  "outputs": {
    "labels": ["approve", "decline"],
    "positive_label": "decline",
    "threshold": 0.5,
    "name": "decision"
  },
  "inference": {"type": "builtin", "name": "credit-risk"},
  "tags": ["finance", "tabular"],
  "metadata": {"owner": "risk-platform"},
  "status": "active",
  "project_id": "prj_40c081b2465e96db2cdc",
  "lineage_id": "mdl_390bd6d9568f626851ef",
  "reference_rows": 600,
  "predictions_count": 192,
  "explanations_count": 12,
  "last_prediction_at": "2026-10-31T22:37:25.682045Z",
  "last_analyzed_at": "2026-10-31T22:37:26.872969Z",
  "created_at": "2026-10-31T22:37:25.397790Z",
  "updated_at": "2026-10-31T22:37:26.872969Z",
  "explain_methods": ["shap", "shapley", "lime", "auto"]
}

#Update a model

PATCH/v1/models/{model}API key or session

Change any registration field. Only the fields you send change. Sending inference.headers with the redacted •••••• values keeps the stored secrets.

Changing features re-validates the schema; changing version must not collide with a sibling version (409 version_taken). project_id: null takes the model out of its project.

Path parameters

modelstringrequired

Model id or slug.

Body parameters

name, slug, version, description, framework, taskoptional

featuresarrayoptional

Replaces the schema.

outputsobjectoptional

Replaces the output definition.

inferenceobjectoptional

Replaces the inference configuration.

statusstringoptional
active or archived.
project_idstring | nulloptional

Move into a project, or out of one with null.

tags, metadataoptional

Replace the whole list or object.

Returns

The updated Model.
client.models.update("credit-risk-docs",
                     description="Scores loan applications for the consumer book.",
                     tags=["lending", "pd", "consumer"])
client.models.assign_project("credit-risk-docs", None)      # leave the project
client.models.update("credit-risk-docs", status="archived")
curl -X PATCH https://api.kaimei.ai/v1/models/credit-risk-docs \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"description": "Scores loan applications for the consumer book.", "tags": ["lending", "pd", "consumer"]}'
200 OKResponse
{
  "object": "model",
  "id": "mdl_c48c5582152e44e34e64",
  "name": "Credit risk scorer",
  "slug": "credit-risk-docs",
  "version": "3",
  "description": "Scores loan applications for the consumer book.",
  "framework": "sklearn",
  "task": "binary_classification",
  "features": …,
  "outputs": {
    "labels": ["approve", "decline"],
    "positive_label": "decline",
    "threshold": 0.5,
    "name": "decision"
  },
  "inference": {"type": "builtin", "name": "credit-risk"},
  "tags": ["lending", "pd", "consumer"],
  "metadata": {"owner": "risk-platform"},
  "status": "active",
  "project_id": "prj_40c081b2465e96db2cdc",
  "lineage_id": "mdl_390bd6d9568f626851ef",
  "reference_rows": 600,
  "predictions_count": 192,
  "explanations_count": 12,
  "last_prediction_at": "2026-10-31T22:37:25.682045Z",
  "last_analyzed_at": "2026-10-31T22:37:26.872969Z",
  "created_at": "2026-10-31T22:37:25.397790Z",
  "updated_at": "2026-10-31T22:40:23.026660Z",
  "explain_methods": null
}

#Delete a model

DELETE/v1/models/{model}API key or session

Delete the model and everything attached to it: predictions, explanations, analyses, insights and structure. Other versions in the lineage are untouched. Frees the model's quota slot and its logged predictions.

Path parameters

modelstringrequired

Model id or slug.

Returns

A deletion receipt.
client.models.delete("credit-risk-docs")
curl -X DELETE https://api.kaimei.ai/v1/models/credit-risk-docs \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "id": "mdl_c48c5582152e44e34e64",
  "object": "model",
  "deleted": true
}

#List versions

GET/v1/models/{model}/versionsAPI key or session

Every model in the lineage of this one, oldest first. Each version is a full Model object with its own counts.

Path parameters

modelstringrequired

Any version's id or slug.

Returns

A page holding all versions (limit equals the count).
for version in client.models.versions("credit-risk-v3").data:
    print(version.version, version.slug, version.created_at)
curl https://api.kaimei.ai/v1/models/credit-risk-v3/versions \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "list",
  "data": [
    {
      "object": "model",
      "id": "mdl_390bd6d9568f626851ef",
      "name": "Credit risk scorer",
      "slug": "credit-risk-v3",
      "version": "3",
      "description": "Consumer-credit decline model with a utilization × debt-to-income interaction.",
      "framework": "sklearn",
      "task": "binary_classification",
      "features": …,
      "outputs": {
        "labels": ["approve", "decline"],
        "positive_label": "decline",
        "threshold": 0.5,
        "name": "decision"
      },
      "inference": {"type": "builtin", "name": "credit-risk"},
      "tags": ["finance", "tabular"],
      "metadata": {"owner": "risk-platform"},
      "status": "active",
      "project_id": "prj_40c081b2465e96db2cdc",
      "lineage_id": "mdl_390bd6d9568f626851ef",
      "reference_rows": 600,
      "predictions_count": 192,
      "explanations_count": 12,
      "last_prediction_at": "2026-10-31T22:37:25.682045Z",
      "last_analyzed_at": "2026-10-31T22:37:26.872969Z",
      "created_at": "2026-10-31T22:37:25.397790Z",
      "updated_at": "2026-10-31T22:37:26.872969Z",
      "explain_methods": null
    },
    {
      "object": "model",
      "id": "mdl_431c8cbe592dde2673c7",
      "name": "Credit risk scorer",
      "slug": "credit-risk-v3-4",
      "version": "4",
      "description": "Consumer-credit decline model with a utilization × debt-to-income interaction.",
      "framework": "sklearn",
      "task": "binary_classification",
      "features": …,
      "outputs": {
        "labels": ["approve", "decline"],
        "positive_label": "decline",
        "threshold": 0.5,
        "name": "decision"
      },
      "inference": {"type": "builtin", "name": "credit-risk"},
      "tags": ["finance", "tabular"],
      "metadata": {"owner": "risk-platform"},
      "status": "active",
      "project_id": "prj_40c081b2465e96db2cdc",
      "lineage_id": "mdl_390bd6d9568f626851ef",
      "reference_rows": 600,
      "predictions_count": 0,
      "explanations_count": 0,
      "last_prediction_at": "2026-10-31T22:37:25.682045Z",
      "last_analyzed_at": "2026-10-31T22:37:26.872969Z",
      "created_at": "2026-10-31T22:37:25.397790Z",
      "updated_at": "2026-10-31T22:37:26.872969Z",
      "explain_methods": null
    }
  ],
  "total": 2,
  "limit": 2,
  "offset": 0,
  "has_more": false
}

#Create a version

POST/v1/models/{model}/versionsAPI key or session

Copy this model into a new version: schema, outputs, inference, tags, metadata, reference data and structure all carry over; history (predictions, explanations, insights) stays on the version that produced it. The new slug defaults to {slug}-{version}.

Path parameters

modelstringrequired

Id or slug of any version in the lineage.

Body parameters

versionstringrequired

New version label, unique in the lineage (409 version_taken). No slashes.

namestringoptional

Defaults to the source model's name.

slugstringoptional

Defaults to {slug}-{version}.

descriptionstringoptional

Defaults to the source model's description.

Returns

The new Model. 201. Counts as a model for quota and rate-limit purposes.
v4 = client.models.create_version("credit-risk-v3", version="4",
                                  slug="credit-risk-v4",
                                  description="Adds utilisation trend features.")
print(v4.lineage_id == client.models.retrieve("credit-risk-v3").lineage_id)   # True
curl -X POST https://api.kaimei.ai/v1/models/credit-risk-v3/versions \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"version": "4", "slug": "credit-risk-v4", "description": "Adds utilisation trend features."}'
201 CreatedResponse
{
  "object": "model",
  "id": "mdl_431c8cbe592dde2673c7",
  "name": "Credit risk scorer",
  "slug": "credit-risk-v4",
  "version": "4",
  "description": "Adds utilisation trend features.",
  "framework": "sklearn",
  "task": "binary_classification",
  "features": …,
  "outputs": {
    "labels": ["approve", "decline"],
    "positive_label": "decline",
    "threshold": 0.5,
    "name": "decision"
  },
  "inference": {"type": "builtin", "name": "credit-risk"},
  "tags": ["finance", "tabular"],
  "metadata": {"owner": "risk-platform"},
  "status": "active",
  "project_id": "prj_40c081b2465e96db2cdc",
  "lineage_id": "mdl_390bd6d9568f626851ef",
  "reference_rows": 600,
  "predictions_count": 0,
  "explanations_count": 0,
  "last_prediction_at": null,
  "last_analyzed_at": null,
  "created_at": "2026-10-31T22:40:23.063556Z",
  "updated_at": "2026-10-31T22:40:23.063556Z",
  "explain_methods": null
}

#Delete a version

DELETE/v1/models/{model}/versions/{version}API key or session

Delete one version of a lineage with everything attached to it. version may be the version's id, its slug or its label; an ambiguous label returns 409 version_ambiguous.

Path parameters

modelstringrequired

Any version's id or slug.

versionstringrequired

Id, slug or label of the version to delete.

Returns

A deletion receipt.
client.models.delete_version("credit-risk-v3", "4")
curl -X DELETE https://api.kaimei.ai/v1/models/credit-risk-v3/versions/4 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "id": "mdl_431c8cbe592dde2673c7",
  "object": "model",
  "deleted": true
}

#Upload reference data

PUT/v1/models/{model}/reference-dataAPI key or session

Store the rows explanations compare against and analyses study. Rows are validated against the schema; those that do not fit are skipped and counted in rejected. At most 5,000 rows are kept (fewer for image models), newest last.

With mode: "append" rows are added to the existing set; labels are kept only when both the existing set and the upload have them.

Path parameters

modelstringrequired

Model id or slug.

Body parameters

rowsarray of objectsrequired

Feature rows, keyed by feature name. At least one.

labelsarrayoptional

One label per row, same length as rows. Optional; enables metric-based importance.

modestringoptionaldefault "replace"
replace or append.

Returns

A reference-data summary: row count, whether labels are stored, a sample of the first rows (images shown as a size label), the columns, the rejected count and the limit applied.
client.models.upload_reference_data(
    "credit-risk-v3",
    rows=X_valid.to_dict(orient="records"),
    labels=y_valid.tolist(),
    mode="replace",
)
curl -X PUT https://api.kaimei.ai/v1/models/credit-risk-v3/reference-data \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rows": [
      {"income": 72000, "credit_score": 681, "utilization": 0.41, "home_ownership": "rent"},
      {"income": 125000, "credit_score": 760, "utilization": 0.12, "home_ownership": "own"},
      {"income": 38000, "credit_score": 590, "utilization": 0.88, "home_ownership": "rent"}
    ],
    "labels": ["decline", "approve", "decline"],
    "mode": "replace"
  }'
200 OKResponse
{
  "model_id": "mdl_390bd6d9568f626851ef",
  "rows": 3,
  "has_labels": true,
  "sample": [
    {
      "income": 72000,
      "credit_score": 681,
      "utilization": 0.41,
      "home_ownership": "rent"
    },
    {
      "income": 125000,
      "credit_score": 760,
      "utilization": 0.12,
      "home_ownership": "own"
    },
    …
  ],
  "columns": [
    "income", "credit_score", "utilization", "home_ownership"
  ],
  "rejected": 0,
  "limit": 5000
}

#Retrieve the reference data summary

GET/v1/models/{model}/reference-dataAPI key or session

How many rows are stored and a sample of them. Rows themselves are not returned in bulk.

Path parameters

modelstringrequired

Model id or slug.

Query parameters

sampleintegeroptionaldefault 5

Rows to include in sample, 0 to 100.

Returns

A reference-data summary.
summary = client.models.reference_data("credit-risk-v3", sample=2)
curl https://api.kaimei.ai/v1/models/credit-risk-v3/reference-data?sample=2 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "model_id": "mdl_390bd6d9568f626851ef",
  "rows": 600,
  "has_labels": true,
  "sample": [
    {
      "income": 72000,
      "credit_score": 681,
      "utilization": 0.41,
      "home_ownership": "rent"
    },
    …
  ],
  "columns": [
    "income", "credit_score", "utilization", "debt_to_income",
    "loan_amount", "employment_years", "num_delinquencies",
    "age", "home_ownership"
  ],
  "rejected": 0,
  "limit": null
}

#Clear reference data

DELETE/v1/models/{model}/reference-dataAPI key or session

Remove every stored reference row. Explanations fall back to logged predictions, then baselines.

Path parameters

modelstringrequired

Model id or slug.

Returns

A deletion receipt with object: "reference_data".
client.models.delete_reference_data("credit-risk-v3")
curl -X DELETE https://api.kaimei.ai/v1/models/credit-risk-v3/reference-data \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "id": "mdl_390bd6d9568f626851ef",
  "object": "reference_data",
  "deleted": true
}

#Predict through Kaimei

POST/v1/models/{model}/predictAPI key or session

Run the model through its inference configuration and return the prediction, logged by default with source: "kaimei". The output is normalised the way explanations report it: label, class index, probabilities and the positive-class value for classifiers; value, name and unit for regressions.

Needs a runnable model (remote, built-in or executable structure); otherwise 422 model_not_runnable. Inputs are validated strictly: 400 invalid_input names the problem.

Path parameters

modelstringrequired

Model id or slug.

Body parameters

inputobjectrequired

A feature row. Missing features take their baseline.

logbooleanoptionaldefault true

Store the prediction. Counts against the predictions quota when true.

metadataobjectoptional

Stored on the prediction.

Returns

prediction = client.models.predict("credit-risk-v3", input={
    "income": 72000, "credit_score": 681, "utilization": 0.41, "debt_to_income": 0.38,
    "loan_amount": 18000, "employment_years": 4, "num_delinquencies": 1, "age": 34,
    "home_ownership": "rent",
}, metadata={"channel": "web"})
print(prediction.output["label"], prediction.output["probabilities"])
curl -X POST https://api.kaimei.ai/v1/models/credit-risk-v3/predict \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": {"income": 72000, "credit_score": 681, "utilization": 0.41, "debt_to_income": 0.38,
             "loan_amount": 18000, "employment_years": 4, "num_delinquencies": 1, "age": 34, "home_ownership": "rent"},
   "log": true, "metadata": {"channel": "web"}}'
200 OKResponse
{
  "object": "prediction",
  "id": "pred_9001ef9f6aaa1a9d672f",
  "model_id": "mdl_390bd6d9568f626851ef",
  "input": {
    "income": 72000,
    "credit_score": 681,
    "utilization": 0.41,
    "debt_to_income": 0.38,
    "loan_amount": 18000,
    "employment_years": 4,
    "num_delinquencies": 1,
    "age": 34,
    "home_ownership": "rent"
  },
  "output": {
    "label": "decline",
    "class_index": 1,
    "probability": 0.5947,
    "probabilities": {"approve": 0.4053, "decline": 0.5947},
    "target_label": "decline",
    "target_index": 1,
    "value": 0.5947,
    "name": "decision"
  },
  "latency_ms": 0.41,
  "source": "kaimei",
  "metadata": {"channel": "web"},
  "created_at": "2026-10-31T22:40:23.114275Z"
}

#Model statistics

GET/v1/models/{model}/statsAPI key or session

Usage and behaviour over the last days: counts, average logged latency, a daily series of predictions and explanations, a summary of the last 500 outputs (histogram, positive rate and label counts for classifiers) and the features that drove the last 200 explanations, ranked by mean absolute attribution.

Path parameters

modelstringrequired

Model id or slug.

Query parameters

daysintegeroptionaldefault 30

Window for the series, 1 to 365.

Returns

A statistics object.
stats = client.models.stats("credit-risk-v3", days=7)
print(stats.predictions_count, stats.output_summary["positive_rate"])
for row in stats.top_features[:3]:
    print(row["feature"], row["share"])
curl https://api.kaimei.ai/v1/models/credit-risk-v3/stats?days=7 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "model_id": "mdl_390bd6d9568f626851ef",
  "predictions_count": 193,
  "explanations_count": 12,
  "analyses_count": 1,
  "insights_count": 7,
  "avg_latency_ms": 31.39,
  "last_prediction_at": "2026-10-31T22:40:23.111634Z",
  "last_analyzed_at": "2026-10-31T22:37:26.872969Z",
  "series": [
    {"date": "2026-10-24", "predictions": 1, "explanations": 0},
    {"date": "2026-10-25", "predictions": 18, "explanations": 0},
    …
  ],
  "output_summary": {
    "n": 193,
    "mean": 0.4807,
    "std": 0.3119,
    "min": 0.0024,
    "max": 0.9987,
    "histogram": {
      "counts": [14, 13, …],
      "edges": [0.0024, 0.0522, …]
    },
    "positive_rate": 0.4663,
    "label_counts": {"decline": 90, "approve": 103}
  },
  "top_features": [
    {
      "feature": "credit_score",
      "mean_abs_attribution": 0.178539,
      "mean_attribution": -0.018133,
      "share": 0.2691
    },
    {
      "feature": "income",
      "mean_abs_attribution": 0.10523,
      "mean_attribution": 0.055998,
      "share": 0.1586
    },
    …
  ]
}