> 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.

# Read a training log

GET https://platform.labric.co/api/v1/ml-models/{ml_model_id}/training-log

Read the output of an ML model's training job, oldest line first.

Reads the newest version unless version_number names another. Returns the
last tail lines that match streams and search, with the version's status and
training_log_summary, which is null until the job ends. To find problems in a
long log, filter to the warning and error streams or search for a term
first. A running job uploads its output about every 30 seconds. The log keeps
the job's last 5,000 lines. It is empty before the job starts, and for
versions trained before training logs were saved.

Requires an API key with the `read` scope.

Reference: https://docs.labric.co/api-reference/labric-api/models/get-training-log

## Authentication

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

## Request

### Path parameters

- `ml_model_id` (string, required)

### Query parameters

- `version_number` (integer, optional, nullable) — The version to read. Defaults to the newest version.
- `tail` (integer, optional, default: 200) — How many of the last matching lines to return.
- `streams` (list of enum, optional) — Keep only lines from these streams, e.g. warning and error.
  - Allowed values: `stdout`, `stderr`, `warning`, `error`
- `search` (string, optional, default: ) — Keep only lines that contain this text, ignoring case.

## Response

### 200

OK

- `version_number` (integer, required)
- `status` (string, required)
- `lines` (list of TrainingLogLineSchema, required)
- `total_lines` (integer, required)
- `matching_lines` (integer, required)
- `training_log_summary` (TrainingLogSummarySchema, optional, nullable) — A summary of a training job's output, built by the training runner from every line the job printed. exit_signal names the signal that stopped the job. SIGKILL most often means the job ran out of memory. facts holds dataset figures the job reported, such as row counts and the holdout size. error and traceback come from the last exception the job logged or printed. warnings groups warnings by text, most frequent first.

## 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)

### 500 Internal Server Error

Internal Server Error

- `detail` (string, required)

## Types

### TrainingLogLineSchema

- `number` (integer, required)
- `timestamp` (string, required)
- `line` (string, required)
- `stream` (enum, required)
  - Allowed values: `stdout`, `stderr`, `warning`, `error`

### TrainingLogSummarySchema

A summary of a training job's output, built by the training runner from every line the job printed. exit_signal names the signal that stopped the job. SIGKILL most often means the job ran out of memory. facts holds dataset figures the job reported, such as row counts and the holdout size. error and traceback come from the last exception the job logged or printed. warnings groups warnings by text, most frequent first.

- `exit_code` (integer, optional, nullable)
- `exit_signal` (string, optional, nullable)
- `duration_seconds` (double, optional, nullable)
- `peak_memory_mb` (integer, optional, nullable)
- `phases` (list of TrainingPhaseSchema, optional, default: [])
- `facts` (map from string to any, optional, default: {})
- `error` (string, optional, nullable)
- `traceback` (list of string, optional, default: [])
- `warning_count` (integer, optional, default: 0)
- `warnings` (list of TrainingWarningSchema, optional, default: [])
- `line_counts` (map from string to integer, optional, default: {})

### TrainingPhaseSchema

- `name` (string, required)
- `duration_seconds` (double, optional, nullable)

### TrainingWarningSchema

- `message` (string, required)
- `count` (integer, required)

## Examples

**Response**

```json
{
  "version_number": 1,
  "status": "string",
  "lines": [
    {
      "number": 1,
      "timestamp": "string",
      "line": "string",
      "stream": "stdout"
    }
  ],
  "total_lines": 1,
  "matching_lines": 1,
  "training_log_summary": {
    "exit_code": 1,
    "exit_signal": "string",
    "duration_seconds": 1.1,
    "peak_memory_mb": 1,
    "phases": [
      {
        "name": "string",
        "duration_seconds": 1.1
      }
    ],
    "facts": {},
    "error": "string",
    "traceback": [
      "string"
    ],
    "warning_count": 0,
    "warnings": [
      {
        "message": "string",
        "count": 1
      }
    ],
    "line_counts": {}
  }
}
```

**SDK Code**

```python
import requests

url = "https://platform.labric.co/api/v1/ml-models/ml_model_id/training-log"

headers = {"Authorization": "Bearer <api_key>"}

response = requests.get(url, headers=headers)

print(response.json())
```