# Fine-tuning API

OpenAI-compatible fine-tuning jobs (ADR 0121). Jobs run at the provider of the alias first target; ownership, file copies and every read are scoped to the key team by the gateway.

## GET /api/v1/admin/fine-tuning/jobs

`GET /api/v1/admin/fine-tuning/jobs` · operation `listFineTuningJobsAdmin`

Ownership records with the last state the provider reported (team, key, alias, provider connection, upstream model, status, fine-tuned model, trained tokens). No provider call. Requires fine_tuning and fine_tuning:read; team roles see their teams.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `after` | query | string |  |
| `limit` | query | integer, default `100`, min 1, max 100 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Jobs and has_more | — |
| `400` | Invalid input | — |
| `404` | Feature disabled | — |


## POST /api/v1/admin/fine-tuning/jobs/{id}/cancel

`POST /api/v1/admin/fine-tuning/jobs/{id}/cancel` · operation `cancelFineTuningJobAdmin`

Cancels the job at its provider. Requires fine_tuning:manage (admin, or team_admin of the job team).

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Cancelled | — |
| `400` | Provider refusal passed through | — |
| `404` | Feature disabled or not visible | — |


## GET /v1/fine_tuning/jobs

`GET /v1/fine_tuning/jobs` · operation `listFineTuningJobs`

Jobs of the key team, newest first, paginated by the gateway from its ownership records (never the provider account list). Jobs that may still change are refreshed from the provider. Requires fine_tuning and key scope route:fine_tuning.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `after` | query | string |  |
| `limit` | query | integer, default `20`, min 1, max 100 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | List with has_more | — |
| `400` | Invalid input | — |
| `404` | Feature disabled | — |


## POST /v1/fine_tuning/jobs

`POST /v1/fine_tuning/jobs` · operation `createFineTuningJob`

Creates a job at the provider of the alias first target (OpenAI protocol, capability fine_tuning). training_file and validation_file are gateway files of the key team with purpose fine-tune; the gateway copies them to the provider and deletes the copies when the job ends. model is the alias; the response shows the alias and the gateway file IDs. integrations are refused. Provider errors are returned as they came. Requires fine_tuning and key scope route:fine_tuning; jobs belong to the key team.

**Authentication:** `bearerAuth`

**Request body** (required)

- `application/json`: object
  - `model` (string, required)
  - `training_file` (string, required)
  - `validation_file` (string or null)
  - `hyperparameters` (object)
  - `suffix` (string)
  - `seed` (integer)
  - `method` (object)
  - `metadata` (object)
    - any other key: string

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | fine_tuning.job object | — |
| `400` | Invalid input, or the provider refusal passed through | — |
| `403` | scope_forbidden, team_required or model_forbidden | — |
| `404` | Feature disabled, unknown model, or a file not visible to the key team | — |
| `422` | The alias lacks fine_tuning or an OpenAI-protocol first target | — |
| `503` | Storage unavailable | — |


## GET /v1/fine_tuning/jobs/{id}

`GET /v1/fine_tuning/jobs/{id}` · operation `getFineTuningJob`

The job as the provider reports it, with the alias and gateway file IDs. A job of another team, unknown or forged, is 404 and never reaches the provider. Requires fine_tuning and key scope route:fine_tuning.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | OK | — |
| `404` | Feature disabled or not visible to the key team | — |


## POST /v1/fine_tuning/jobs/{id}/cancel

`POST /v1/fine_tuning/jobs/{id}/cancel` · operation `cancelFineTuningJob`

Cancels the job at its provider; a finished job gets the provider refusal as it came. Requires fine_tuning and key scope route:fine_tuning.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | OK | — |
| `400` | Provider refusal passed through | — |
| `404` | Feature disabled or not visible to the key team | — |


## POST /v1/fine_tuning/jobs/{id}/pause

`POST /v1/fine_tuning/jobs/{id}/pause` · operation `pauseFineTuningJob`

Pauses a running job at its provider. Requires fine_tuning and key scope route:fine_tuning.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | OK | — |
| `400` | Provider refusal passed through | — |
| `404` | Feature disabled or not visible to the key team | — |


## POST /v1/fine_tuning/jobs/{id}/resume

`POST /v1/fine_tuning/jobs/{id}/resume` · operation `resumeFineTuningJob`

Resumes a paused job at its provider. Requires fine_tuning and key scope route:fine_tuning.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | OK | — |
| `400` | Provider refusal passed through | — |
| `404` | Feature disabled or not visible to the key team | — |


## GET /v1/fine_tuning/jobs/{id}/events

`GET /v1/fine_tuning/jobs/{id}/events` · operation `listFineTuningJobEvents`

Provider events of an owned job; only after and limit are forwarded. Requires fine_tuning and key scope route:fine_tuning.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `after` | query | string |  |
| `limit` | query | integer, min 1, max 100 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | OK | — |
| `400` | Invalid input | — |
| `404` | Feature disabled or not visible to the key team | — |


## GET /v1/fine_tuning/jobs/{id}/checkpoints

`GET /v1/fine_tuning/jobs/{id}/checkpoints` · operation `listFineTuningJobCheckpoints`

Provider checkpoints of an owned job; only after and limit are forwarded. Requires fine_tuning and key scope route:fine_tuning.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `after` | query | string |  |
| `limit` | query | integer, min 1, max 100 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | OK | — |
| `400` | Invalid input | — |
| `404` | Feature disabled or not visible to the key team | — |

