---
title: "Train a Reflex"
method: POST
path: "/v1/fine_tuning/jobs"
tags: ["Reflex"]
---

# Train a Reflex

`POST /v1/fine_tuning/jobs`

Start a training job. OpenAI fine-tuning-compatible, with two differences: training data is **inline** (`training_data`, no Files API) and there are **no hyperparameters**. `model` selects the base to train from — omit it for a from-scratch cold start, or pass any custom or default reflex to warm-start from its weights. A small Reflex trains in about 30 seconds. Provide exactly one input mode — `training_data`, `generate`, or `label_data`.

## Request body

- CreateFineTuningJobRequest — Provide exactly one input: `training_data`, `generate`, or `label_data`. The training set must end up with 2+ labels and 5+ examples per label.
  - `model` string — What to train from (OpenAI-style). Omit for a from-scratch cold start, or pass a custom or default reflex to warm-start from its weights: a model you trained (its `suffix` or job id) or a built-in reflex name like `guardrail`.
  - `suffix` string — Names the served model. Becomes `fine_tuned_model` on success.
  - `labels` string[] — The classes. 2+ required for `generate` and `label_data`; inferred from `training_data` if omitted.
  - `webhook_url` string — An `https` URL that receives a signed webhook when the job reaches `succeeded`, `failed`, or `cancelled`.
  - `auto_train` boolean — Train as soon as data prep finishes. Set `false` to pause at `prepared` for review, then call `POST /v1/fine_tuning/jobs/{job_id}/train`.
  - `training_data` ReflexTrainingExample[] — Labeled rows you supply (input mode 1).
    - `text` string, required
    - `label` string, required
  - `generate` object — Input mode 2: synthesize training data from a description.
    - `description` string — What the classifier is for.
    - `examples_per_label` integer — Examples to synthesize per label. 5–1000.
  - `label_data` object — Input mode 3: sort your unlabeled text into your classes.
    - `texts` string[] — Unlabeled strings, up to 20,000. Minimum is your label count × 5.
    - `description` string — Context for more accurate labeling.

## Response `200`

The created job.

- FineTuningJob — An OpenAI-compatible `fine_tuning.job`, with additive Reflex fields (`labels`, `trained_examples`, `result`, `suffix`).
  - `id` string — Job id, prefixed `ftjob-`.
  - `object` string
  - `model` string — What the job trained from: the reflex you warm-started from, or the from-scratch base for a cold start.
  - `created_at` integer — Unix timestamp (seconds) at creation.
  - `finished_at` integer, nullable — Unix timestamp at a terminal state, else null.
  - `fine_tuned_model` string, nullable — Served model name once `succeeded` (the `suffix`, or the job id if none).
  - `status` 'queued' | 'validating_files' | 'running' | 'succeeded' | 'failed' | 'cancelled' — `validating_files` is the data-prep phase for `generate`/`label_data` jobs.
  - `labels` string[]
  - `trained_examples` integer — Number of training examples.
  - `hyperparameters` object — Fully managed.
    - `n_epochs` integer
    - `batch_size` string
    - `learning_rate_multiplier` string
  - `result` object, nullable — `{accuracy, f1_score}` when `succeeded`, else null. Each value may be null.
    - `accuracy` number, nullable
    - `f1_score` number, nullable
  - `error` object, nullable — `{code, message, param}` when `failed`, else null.
    - `code` string, nullable
    - `message` string, nullable
    - `param` string, nullable
  - `suffix` string, nullable

## Other responses

- `400` — Validation failed, or the warm-start `model` could not be used (`model_not_found` / `model_incompatible`).
- `401` — Invalid or missing API key.
- `409` — `suffix` already names a model (`model_alias_in_use`), or the warm-start `model` has no trained version yet (`model_not_ready`).

---

[API](https://skmtc.net/morphllm/apis/morph-api.md) · [All operations](https://skmtc.net/morphllm/apis/morph-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/morphllm/morph-api/versions/9e3d888071b5/schema)
