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

# Analyze training metrics and detect reward hacking

> Retrieve post-training metric analysis for a job including reward statistics, spike detection, and risk flags for reward hacking.

Use this endpoint to analyze the full training metric history of a job. The analysis detects reward spikes that may indicate reward hacking and computes summary statistics over the entire run. This is useful for auditing RL jobs before accepting a model into production.

## Method + Path

```http theme={null}
GET /v1/jobs/:id/analysis
```

## Authentication

Include your PIN API token or JWT in the `Authorization` header as a Bearer token.

```http theme={null}
Authorization: Bearer <token>
```

## Path parameters

<ParamField path="id" type="string" required>
  The job identifier (e.g., `jb_abc123def456`).
</ParamField>

## Request example

<CodeGroup>
  ```bash curl theme={null}
  curl -s "https://api.ariacompute.com/v1/jobs/jb_abc123def456/analysis" \
    -H "Authorization: Bearer $PIN_API_TOKEN"
  ```
</CodeGroup>

## Response

Returns a standard PIN success envelope with the analysis result.

<ResponseField name="code" type="integer" required>
  `0` on success, nonzero on error.
</ResponseField>

<ResponseField name="data" type="object" required>
  <Expandable title="analysis object">
    <ResponseField name="reward" type="object">
      Reward statistics.

      <Expandable title="properties">
        <ResponseField name="mean" type="number">
          Mean reward across all steps.
        </ResponseField>

        <ResponseField name="std" type="number">
          Standard deviation of reward.
        </ResponseField>

        <ResponseField name="spike_steps" type="array">
          Step numbers where reward spiked (>= 2x the preceding 10-step baseline).
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="risk" type="string">
      Risk assessment: `ok` or `suspected_reward_hacking`.
    </ResponseField>

    <ResponseField name="evidence" type="array">
      List of human-readable evidence strings.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable message (empty on success).
</ResponseField>

### Example response

```json theme={null}
{
  "code": 0,
  "data": {
    "reward": {
      "mean": 0.7421,
      "std": 0.3124,
      "spike_steps": [1240, 1890]
    },
    "risk": "suspected_reward_hacking",
    "evidence": [
      "reward spiked multiple times (>=2x baseline)",
      "second-half reward mean is >50% above first-half"
    ]
  },
  "message": ""
}
```

## Detection logic

The analyzer applies the following checks over the full step history:

1. **Reward spike detection**: For each step after the first 10, if the reward is at least 2x the mean of the preceding 10 steps, that step is flagged as a spike.
2. **Second-half comparison**: If the mean reward in the second half of training is more than 50% higher than the first half, evidence is added.
3. **Risk flag**: Two or more spike steps trigger `suspected_reward_hacking`. Otherwise the risk is `ok`.
4. **High variance warning**: If no spikes are found but standard deviation exceeds 0.3, a manual review recommendation is appended.

Non-RL jobs (SFT, OPD) that do not report reward are skipped for reward-specific checks.

## Errors

| Code | HTTP | Meaning                                                        |
| ---- | ---- | -------------------------------------------------------------- |
| 401  | 401  | Missing or invalid Bearer token.                               |
| 404  | 404  | Job not found or does not belong to you.                       |
| 422  | 422  | Job has no metrics yet (training not started or not reported). |
| 500  | 500  | Internal server error.                                         |


## Related topics

- [Configure automatic intervention guardrails for training jobs](/api-reference/pin/jobs/auto-intervention.md)
- [Report Training Metrics and Status - Node Agent](/api-reference/pin/node-agent/metrics.md)
- [Retrieve full training job detail with checkpoints and metrics](/api-reference/pin/jobs/get.md)
- [Router Cost Aggregation API](/api-reference/router/cost.md)
- [International and China sites, and how to choose](/concepts/sites-regions.md)
