Send labeled examples, get back a text classifier. Create a job, poll until it finishes, then classify text against it. A small Reflex trains in about 30 seconds. See the Reflexes overview for what a Reflex is. Jobs use the OpenAI fine-tuning API, so the official SDKs work unchanged, with two differences:Documentation Index
Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
Use this file to discover all available pages before exploring further.
- Inline training data. Pass
training_datain the body. No Files API, notraining_file. - Fully managed. No hyperparameters. One base model,
morph-reflex-v1.
| Base model | morph-reflex-v1 (default, optional on create) |
| Minimums | 2 distinct labels, 5 examples per label |
| Concurrency | 3 jobs run at once per key; the rest queue |
Quick Start
Four steps: get a key, create a job, wait for it, classify text.training_data is a Morph extension. The OpenAI Python SDK rejects unknown arguments, so pass it through extra_body=.Get an API key
Grab one from the dashboard.
Create a training job
Send labeled examples. No data? Use
generate or label_data instead.Create a Job
training_data, generate, or label_data (see Input modes).
| Field | Type | Required | Description |
|---|---|---|---|
model | string | No | morph-reflex-v1 (default and only value). |
suffix | string | No | Names the served model. Becomes fine_tuned_model on success. |
labels | array | * | The classes. 2+ required for generate and label_data; inferred from training_data if omitted. |
Input modes
Pick one. The training set, however it is produced, must have 2+ labels and 5+ examples per label, else the job fails.generate and label_data synthesize or label data through the OpenAI Batch API, so the job spends a few minutes on data before training. status stays running the whole time. Poll as usual.training_data: labeled rows you supply.
| Field | Type | Required | Description |
|---|---|---|---|
training_data | array | Yes | { "text": string, "label": string } rows. |
generate: no data; synthesize it from a description.
| Field | Type | Required | Description |
|---|---|---|---|
generate.description | string | Yes | What the classifier is for. |
generate.examples_per_label | integer | No | Examples to synthesize per label. Default 25, max 100. |
labels | array | Yes | The classes to generate for. 2+. |
label_data: your unlabeled text, sorted into your classes.
| Field | Type | Required | Description |
|---|---|---|---|
label_data.texts | array | Yes | 10 to 20,000 unlabeled strings. |
label_data.description | string | No | Context for more accurate labeling. |
labels | array | Yes | The classes to sort into. 2+. |
Retrieve a Job
status is succeeded, failed, or cancelled.
List Jobs
| Query param | Type | Description |
|---|---|---|
limit | integer | Jobs per page. Default 20, max 100. |
after | string | Job id cursor. Returns jobs created before it. |
Cancel a Job
status becomes cancelled.
Training Events
?stream=true for a live Server-Sent Events stream.
Predict
POST. The model must be ready, else 409 (model_not_ready).
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | A fine_tuned_model name or job id. |
text | string | Yes | The text to classify. |
all_scores is the per-class probabilities, ordered by the model’s labels.
Classify against multiple models
predict takes one model per request. To run several of your classifiers over the same text, make one call per model and fire them in parallel.
Delete a Job
Delete a Model
fine_tuned_model value or job id). Same effect as deleting the job; OpenAI Models-API parity.
Reference
Job object
Job object
| Field | Type | Description |
|---|---|---|
id | string | Job id, prefixed ftjob-. |
object | string | Always fine_tuning.job. |
model | string | Always morph-reflex-v1. |
created_at | integer | Unix timestamp (seconds) at creation. |
finished_at | integer / null | Unix timestamp at terminal state, else null. |
fine_tuned_model | string / null | Served model name once succeeded. The suffix, or the job id if none. |
status | string | queued, running, succeeded, failed, or cancelled. |
labels | array | The label set used for training. |
trained_examples | integer | Number of training examples. |
result | object / null | { "accuracy", "f1_score" } when succeeded, else null. Each value may be null. |
error | object / null | { "message" } when failed, else null. |
suffix | string / null | The suffix supplied at creation, or null. |
Event object
Event object
| Field | Type | Description |
|---|---|---|
id | string | Event id, prefixed ftevent-. |
object | string | Always fine_tuning.job.event. |
created_at | integer | Unix timestamp (seconds). |
level | string | info, warn, or error. |
message | string | Human-readable message. |
type | string | metrics for per-step loss, message for the terminal event. |
data | object | { "epoch", "step", "train_loss" }. |
Errors
Errors
OpenAI-shaped:
{ "error": { "message", "type", "param", "code" } }.| Status | type | When |
|---|---|---|
401 | authentication_error | Invalid or missing API key. |
400 | invalid_request_error | Validation failed. param names the offending field. |
404 | invalid_request_error | Not found. code is job_not_found or model_not_found. |
409 | invalid_request_error | Model not ready. code is model_not_ready. |