Overview
synth-ai train --type sft
orchestrates three REST endpoints exposed by the Synth learning service:
POST /learning/files
– upload training (and optional validation) datasets in JSONL format.POST /learning/jobs
– create an offline SFT job that references the uploaded file IDs.POST /learning/jobs/{job_id}/start
– trigger the created job.
--backend
(defaults to http://localhost:8000/api
) and uses the bearer token stored in SYNTH_API_KEY
.
Upload Dataset — POST /learning/files
Send a multipart upload for every dataset you intend to train or validate against. The response returns a file ID that you must include in the job payload.
metadata.effective_config.data.validation_files
when creating the job.
Create Job — POST /learning/jobs
Once uploads are complete, the CLI builds the job payload (synth_ai/api/train/builders.py
) and calls the job creation endpoint.
Start Job — POST /learning/jobs/{job_id}/start
Immediately start the job after creation. This call is issued inside handle_sft()
once the job has been provisioned.
Polling Status
SFTJobPoller
(synth_ai/api/train/pollers.py
) polls GET /learning/jobs/{job_id}
until the status is terminal (succeeded
, failed
, or cancelled
). Poll responses surface progress updates, checkpoint metadata, and the produced model ID (ft:…
).
Error Handling
400
/422
: Payload or dataset schema invalid. The CLI performs local validation (validate_sft_jsonl
), but backend schema drifts appear here.409
: Duplicate creation. Use--idempotency
to supply anIdempotency-Key
header when you need dedupe semantics.5xx
: Backend issue. Inspect logs and retry once the service is healthy.
Related CLI Source
synth_ai/api/train/cli.py
:handle_sft()
coordinates dataset discovery, uploads, job creation, start, and polling.synth_ai/api/train/builders.py
: constructs the payload used in job creation.