> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.labric.co/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.labric.co/_mcp/server.

# Run predictions

POST https://platform.labric.co/api/v1/ml-models/predict
Content-Type: application/json

Run predictions with a trained ML model.

Identify the model by ml_model_id, or by ml_model_name (the name of a
non-archived model). Each row in data maps the model's feature columns to
values -- use the ml-models tool to discover models and the columns each
expects. Returns one prediction per input row, plus per-class
probabilities for classifiers.

Requires an API key with the `read` scope.

Reference: https://docs.labric.co/api-reference/labric-api/models/predict

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an object.

- `data` (list of map from string to any, required)
- `ml_model_id` (string, optional, nullable)
- `ml_model_name` (string, optional, nullable)

## Response

### 200

OK

- `predictions` (list of any, required)
- `model_id` (string, required)
- `model_name` (string, required)
- `probabilities` (list of map from string to any, optional, nullable)
- `annotations` (list of object, optional, nullable)
  - `file_id` (string, required)
  - `label` (string, required)
  - `mask` (string, required)
  - `width` (integer, required)
  - `height` (integer, required)
  - `foreground_fraction` (double, required)

## Errors

### 400 Bad Request Error

Bad Request

- `detail` (string, required)

### 401 Unauthorized Error

Unauthorized

- `detail` (string, required)

### 403 Forbidden Error

Forbidden

- `detail` (string, required)

### 404 Not Found Error

Not Found

- `detail` (string, required)

### 422 Unprocessable Entity Error

Unprocessable Content

- `detail` (list of map from string to any, required)

### 429 Too Many Requests Error

Too Many Requests

- `detail` (string, required)

### 500 Internal Server Error

Internal Server Error

- `detail` (string, required)

### 502 Bad Gateway Error

Bad Gateway

- `detail` (string, required)

## Examples

### Tabular classification

**Request**

```json
{
  "data": [
    {
      "cure_temperature_c": 180,
      "cure_time_min": 30,
      "primer_thickness_um": 25,
      "substrate_roughness_um": 1.2
    },
    {
      "cure_temperature_c": 140,
      "cure_time_min": 15,
      "primer_thickness_um": 10,
      "substrate_roughness_um": 0.4
    }
  ],
  "ml_model_name": "Coating adhesion classifier"
}
```

**Response**

```json
{
  "predictions": [
    "pass",
    "fail"
  ],
  "model_id": "6b1e4c2a-9d3f-4a7b-8c5e-1f2a3b4c5d6e",
  "model_name": "Coating adhesion classifier",
  "probabilities": [
    {
      "fail": 0.09,
      "pass": 0.91
    },
    {
      "fail": 0.78,
      "pass": 0.22
    }
  ],
  "annotations": null
}
```

**SDK Code**

```python Tabular classification
from labric import Labric

client = Labric(
    api_key="YOUR_TOKEN_HERE",
)

client.models.predict(
    ml_model_name="Coating adhesion classifier",
    data=[
        {
            "cure_temperature_c": 180,
            "cure_time_min": 30,
            "primer_thickness_um": 25,
            "substrate_roughness_um": 1.2
        },
        {
            "cure_temperature_c": 140,
            "cure_time_min": 15,
            "primer_thickness_um": 10,
            "substrate_roughness_um": 0.4
        }
    ],
)

```

### Image segmentation

**Request**

```json
{
  "data": [
    {
      "micrograph": "5d4c3b2a-1f0e-4d9c-8b7a-6f5e4d3c2b1a"
    }
  ],
  "ml_model_id": "3a2b1c0d-9e8f-4a7b-b6c5-d4e3f2a1b0c9"
}
```

**Response**

```json
{
  "predictions": [
    null
  ],
  "model_id": "3a2b1c0d-9e8f-4a7b-b6c5-d4e3f2a1b0c9",
  "model_name": "Grain boundary segmentation",
  "probabilities": null,
  "annotations": [
    {
      "file_id": "5d4c3b2a-1f0e-4d9c-8b7a-6f5e4d3c2b1a",
      "label": "grain_boundary",
      "mask": "R0lGODlhAQABAIAAAAUEBA==",
      "width": 2048,
      "height": 1536,
      "foreground_fraction": 0.12
    }
  ]
}
```

**SDK Code**

```python Image segmentation
from labric import Labric

client = Labric(
    api_key="YOUR_TOKEN_HERE",
)

client.models.predict(
    ml_model_id="3a2b1c0d-9e8f-4a7b-b6c5-d4e3f2a1b0c9",
    data=[
        {
            "micrograph": "5d4c3b2a-1f0e-4d9c-8b7a-6f5e4d3c2b1a"
        }
    ],
)

```