> ## Documentation Index
> Fetch the complete documentation index at: https://docs.platform.toloka.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# client.trainings.getRunMetricHistory()

> Get training metric history.

Use a value from `metrics[].key` returned by `GET /api/v2-beta/training-runs/{trainingRunId}/metrics` as `metricKey`. Set `resolution` to choose the number of sampled history points; the default is 200. Returns 404 if the run or metric is unavailable.

## Signature

Method signature on `client.trainings`:

```ts theme={null}
getRunMetricHistory(args: {
  trainingRunId: string;
  metricKey: string;
  resolution?: number;
}): Promise<TrainingRunMetricHistory>;
```

## Parameters

**trainingRunId** `string` *required*

ID of the training run, with prefix `trn.`.

**metricKey** `string` *required*

Metric key from `metrics[].key` returned by the latest-metrics endpoint.

**resolution** `number` (default: 200)

Requested number of sampled history points, from 2 to 500; defaults to 200.

## Returns

`Promise<TrainingRunMetricHistory>`

The history of one training run metric, sampled to the requested resolution.

**key** `string` *required*

Metric key accepted by the metric-history endpoint.

**metric** `"training_loss" | "validation_loss" | "learning_rate" | "training_token_accuracy" | "validation_token_accuracy" | null` *required*

Normalized metric name, or null when this key has no recognized metric name.

**points** `object[]` *required*

Metric values sampled to the requested resolution.

**Fields**

**step** `number` *required*

Training step at which this metric value was recorded.

**timestamp** `number` *required*

Time the metric was recorded, in milliseconds since January 1, 1970, 00:00:00 UTC.

**value** `number | null` *required*

Numeric metric value, or null when the recorded value is not finite.

**nonFinite** `"nan" | "positive_infinity" | "negative_infinity" | null` *required*

Non-finite value kind: `nan`, `positive_infinity`, or `negative_infinity`; null for a finite numeric value.

**truncated** `boolean` *required*

Whether metric points were omitted from this response.

## Errors

HTTP errors throw [`PotatoApiError`](https://docs.platform.toloka.ai/docs/sdk/errors). The endpoint documents these error responses:

| Status | Description |
| - | - |
| 404 | Training Run or metric not found |
| 429 | Rate limit exceeded |

HTTP endpoint: [`GET /training-runs/{trainingRunId}/metrics/{metricKey}`](https://docs.platform.toloka.ai/docs/api-reference/trainings/get-training-run-metric-history).

```ts getRunMetricHistory() theme={null}
import assert from "node:assert/strict";
import { createClient } from "@toloka-platform/sdk";

const client = createClient({
  baseUrl: "https://platform.toloka.ai",
  apiKey: process.env.TOLOKA_API_KEY!,
});

const trainingRunId = "trn.019a0000-0000-7000-8000-000000000001";
const { metrics } = await client.trainings.getRunMetrics({ trainingRunId });
const metric = metrics[0];
assert(metric, "This run has no metrics yet.");

const metricHistory = await client.trainings.getRunMetricHistory({
  trainingRunId: trainingRunId,
  metricKey: metric.key
});
console.log(metricHistory);
```

```json getRunMetricHistory() theme={null}
{
  "key": "<string>",
  "metric": null,
  "points": [
    {
      "step": 0,
      "timestamp": 0,
      "value": null,
      "nonFinite": null
    }
  ],
  "truncated": false
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.