Predictions

Predictions

Log the predictions your models make, or read back the ones Kaimei made, for explanation and monitoring.

A prediction is one input and the output a model produced for it. Log the predictions your own stack makes so they can be explained later and monitored for drift, or let Kaimei make them with POST /v1/models/{model}/predict.

#The Prediction object

The output is stored as you sent it: an object is kept as is, a number becomes {"value": n}, a string becomes {"label": s}, a boolean becomes a label and a value, a list becomes {"raw": [...]}. Predictions Kaimei makes carry the normalised output shown under predict.

Attributes

idstring
pred_ identifier, or the prediction_id you supplied (up to 64 characters).
model_idstring

inputobject

The feature row as sent. Image pixels are stored packed and read back as the same lists.

outputobject | null

See above.

latency_msnumber | null

Your model's latency, if you logged it; Kaimei's own when it predicted.

sourcestring
api, sdk (the Python client), or kaimei (made by Kaimei, through predict or when an explanation ran with log_prediction).
metadataobject

Yours.

created_attimestamp

The timestamp you sent, or the time of logging.

The Prediction object
{
  "object": "prediction",
  "id": "pred_8f2a19",
  "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", "probability": 0.81},
  "latency_ms": 12.4,
  "source": "api",
  "metadata": {"request_id": "req_01HZX"},
  "created_at": "2026-10-31T22:40:23.260448Z"
}

#Log a prediction

POST/v1/predictionsAPI key or session

Record one prediction your model made. Counts against the monthly predictions quota and the 600-per-hour limit.

Body parameters

modelstringrequired

Model id or slug.

inputobjectrequired

The feature row.

outputanyoptional

What the model returned: an object, a number, a string label, a boolean or a list.

prediction_idstringoptional

Your own id for the record, up to 64 characters. Defaults to a generated pred_ id.

latency_msnumberoptional

Your model's latency.

timestamptimestampoptional

When the prediction happened, for backfills. Defaults to now.

metadataobjectoptional

Free-form.

Returns

The Prediction. 201.
client.predictions.create(
    model="credit-risk-v3",
    input=row,
    output={"label": "decline", "probability": 0.81},
    prediction_id="pred_8f2a19",
    latency_ms=12.4,
    metadata={"request_id": "req_01HZX"},
)
curl -X POST https://api.kaimei.ai/v1/predictions \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "credit-risk-v3", "prediction_id": "pred_8f2a19", "latency_ms": 12.4,
   "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", "probability": 0.81}, "metadata": {"request_id": "req_01HZX"}}'
201 CreatedResponse
{
  "object": "prediction",
  "id": "pred_8f2a19",
  "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", "probability": 0.81},
  "latency_ms": 12.4,
  "source": "api",
  "metadata": {"request_id": "req_01HZX"},
  "created_at": "2026-10-31T22:40:23.260448Z"
}

#Log many predictions

POST/v1/predictions/batchAPI key or session

Record up to 1,000 predictions in one request. Each item takes the same fields as a single prediction except model. The quota is checked once for the whole batch and the rate limit counts one hit.

Body parameters

modelstringrequired

Model id or slug.

itemsarrayrequired

1 to 1,000 items of {input, output?, prediction_id?, latency_ms?, timestamp?, metadata?}.

Returns

{"object": "list", "data": [...predictions], "count": n}.
client.predictions.create_batch(model="credit-risk-v3", items=[
    {"prediction_id": "pred_8f2a1a", "input": {**row, "income": 54000}, "output": 0.63},
    {"prediction_id": "pred_8f2a1b", "input": {**row, "credit_score": 790, "utilization": 0.08},
     "output": {"label": "approve", "probability": 0.91}},
])
curl -X POST https://api.kaimei.ai/v1/predictions/batch \
  -H "Authorization: Bearer $KAIMEI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "credit-risk-v3", "items": [
     {"prediction_id": "pred_8f2a1a", "input": {"income": 54000, "credit_score": 681, "utilization": 0.41}, "output": 0.63},
     {"prediction_id": "pred_8f2a1b", "input": {"income": 72000, "credit_score": 790, "utilization": 0.08},
      "output": {"label": "approve", "probability": 0.91}}
   ]}'
200 OKResponse
{
  "object": "list",
  "data": [
    {
      "object": "prediction",
      "id": "pred_8f2a1a",
      "model_id": "mdl_390bd6d9568f626851ef",
      "input": {
        "income": 54000,
        "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": {"value": 0.63},
      "latency_ms": null,
      "source": "api",
      "metadata": {},
      "created_at": "2026-10-31T22:40:23.268794Z"
    },
    {
      "object": "prediction",
      "id": "pred_8f2a1b",
      "model_id": "mdl_390bd6d9568f626851ef",
      "input": {
        "income": 72000,
        "credit_score": 790,
        "utilization": 0.08,
        "debt_to_income": 0.38,
        "loan_amount": 18000,
        "employment_years": 4,
        "num_delinquencies": 1,
        "age": 34,
        "home_ownership": "rent"
      },
      "output": {"label": "approve", "probability": 0.91},
      "latency_ms": null,
      "source": "api",
      "metadata": {},
      "created_at": "2026-10-31T22:40:23.268794Z"
    }
  ],
  "count": 2
}

#List predictions

GET/v1/predictionsAPI key or session

Predictions in your organization, newest first.

Query parameters

modelstringoptional

Model id or slug.

sourcestringoptional
api, sdk or kaimei.
limitintegeroptionaldefault 50

1 to 500.

offsetintegeroptionaldefault 0

Returns

A page of Predictions.
page = client.predictions.list(model="credit-risk-v3", source="api", limit=100)
for prediction in client.predictions.iterate(model="credit-risk-v3"):
    ...
curl "https://api.kaimei.ai/v1/predictions?model=credit-risk-v3&limit=2" \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "list",
  "data": [
    {
      "object": "prediction",
      "id": "pred_8f2a1b",
      "model_id": "mdl_390bd6d9568f626851ef",
      "input": …,
      "output": {"label": "approve", "probability": 0.91},
      "latency_ms": null,
      "source": "api",
      "metadata": {},
      "created_at": "2026-10-31T22:40:23.260448Z"
    },
    {
      "object": "prediction",
      "id": "pred_8f2a19",
      "model_id": "mdl_390bd6d9568f626851ef",
      "input": …,
      "output": {"label": "decline", "probability": 0.81},
      "latency_ms": 12.4,
      "source": "api",
      "metadata": {"request_id": "req_01HZX"},
      "created_at": "2026-10-31T22:40:23.260448Z"
    }
  ],
  "total": 196,
  "limit": 2,
  "offset": 0,
  "has_more": true
}

#Retrieve a prediction

GET/v1/predictions/{prediction_id}API key or session

One prediction by id, including an id you supplied yourself.

Path parameters

prediction_idstringrequired

Returns

A Prediction.
prediction = client.predictions.retrieve("pred_8f2a19")
curl https://api.kaimei.ai/v1/predictions/pred_8f2a19 \
  -H "Authorization: Bearer $KAIMEI_API_KEY"
200 OKResponse
{
  "object": "prediction",
  "id": "pred_8f2a19",
  "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", "probability": 0.81},
  "latency_ms": 12.4,
  "source": "api",
  "metadata": {"request_id": "req_01HZX"},
  "created_at": "2026-10-31T22:40:23.260448Z"
}