Prepare your training data as a JSONL file where each line is a JSON object with a 'messages' array following the chat format required by the target model.
Upload the file using the Files API: client.files.create(file=open('train.jsonl', 'rb'), purpose='fine-tune') and record the returned file ID.
Create the fine-tuning job: client.fine_tuning.jobs.create(training_file=FILE_ID, model='MODEL_NAME') using a supported base model name.
Poll the job status with client.fine_tuning.jobs.retrieve(JOB_ID) or list events with client.fine_tuning.jobs.list_events(JOB_ID) until the status is 'succeeded'.
Note the fine_tuned_model field in the completed job object; this is the model ID to use for inference.
Test the fine-tuned model by calling the Chat Completions API with model=FINE_TUNED_MODEL_ID.
Known gotchas
Each model has a minimum training example requirement; submitting fewer examples than the minimum will cause the job to be rejected at creation time.
The training JSONL must use the exact message role names ('system', 'user', 'assistant'); invalid role names cause a file validation error before the job starts.
Fine-tuning jobs are asynchronous and can take anywhere from minutes to hours depending on dataset size and queue depth; do not assume immediate completion.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp