Skip to main content
POST
Train a Reflex

Overview

Creates a fine-tuning job that trains a custom Reflex from labeled examples. The resulting fine_tuned_model id is usable in POST /v1/reflex/predict when the job succeeds. Track progress with job events.

Authorizations

Authorization
string
header
required

Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.

Body

application/json

The training set (or the instructions to build one) plus the name to serve it under.

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.

Example:

"guardrail"

suffix
string

Names the served model. Becomes fine_tuned_model on success.

Example:

"support-classifier"

labels
string[]

The classes. 2+ required for generate and label_data; inferred from training_data if omitted.

One class name.

Example:
webhook_url
string

An https URL that receives a signed webhook when the job reaches succeeded, failed, or cancelled.

Example:

"https://example.com/webhooks/morph"

auto_train
boolean
default:true

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.

Example:

true

training_data
object[]

Labeled rows you supply (input mode 1).

Example:
generate
object

Input mode 2: synthesize training data from a description.

Example:
label_data
object

Input mode 3: sort your unlabeled text into your classes.

Example:

Response

The created job.

An OpenAI-compatible fine_tuning.job, with additive Reflex fields (labels, trained_examples, result, suffix).

id
string
required

Job id, prefixed ftjob-.

Example:

"ftjob-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d"

object
string
required

Always fine_tuning.job.

Example:

"fine_tuning.job"

model
string
required

What the job trained from: the reflex you warm-started from, or the from-scratch base for a cold start.

Example:

"guardrail"

created_at
integer
required

Unix timestamp (seconds) at creation.

Example:

1780107000

finished_at
integer | null
required

Unix timestamp at a terminal state, else null.

Example:

1780107148

fine_tuned_model
string | null
required

Served model name once succeeded (the suffix, or the job id if none).

Example:

"support-classifier"

status
enum<string>
required

validating_files is the data-prep phase for generate/label_data jobs.

Available options:
queued,
validating_files,
running,
succeeded,
failed,
cancelled
Example:

"succeeded"

labels
string[]
required

The classes this job trained on.

One class the model predicts.

Example:
trained_examples
integer
required

Number of training examples.

Example:

10

hyperparameters
object
required

Fully managed.

Example:
result
object | null
required

{accuracy, f1_score} when succeeded, else null. Each value may be null.

Example:
error
object | null
required

{code, message, param} when failed, else null.

Example:
suffix
string | null
required

The suffix supplied at creation, else null.

Example:

"support-classifier"