Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mka1.com/llms.txt

Use this file to discover all available pages before exploring further.

Use fine-tuning when you want to adapt a base model to your own training examples and operational style. The fine-tuning endpoints create an asynchronous job from uploaded JSONL files and return a model ID when training succeeds. Fine-tuning endpoints are marked ADMIN ONLY in the generated API reference. Use an API key with the required permissions.

Before you start

Prepare:
InputDescription
Training fileA JSONL file with your training examples. Upload it with purpose: "fine-tune".
Validation fileOptional JSONL validation data. Upload it with purpose: "fine-tune".
Base modelThe model ID you want to fine-tune, for example meetkai:functionary-medium.
Fine-tuning jobs can return these statuses:
validating_files -> queued -> running -> succeeded
                          \-> failed
                          \-> cancelled

Step 1 - Upload your training files

Upload each JSONL file with the Files API and purpose: "fine-tune".
mka1 llm files upload \
  --file ./fine-tuning-train.jsonl \
  --purpose fine-tune \
  -H 'X-On-Behalf-Of: <end-user-id>'

mka1 llm files upload \
  --file ./fine-tuning-validation.jsonl \
  --purpose fine-tune
Store the returned file IDs. You pass them to the Fine-Tuning API in the next step.

Step 2 - Create a fine-tuning job

Call mka1.llm.fineTuning.create with the base model and your uploaded training file ID. Add a validation file, suffix, metadata, and method settings when you need them.
mka1 llm fine-tuning create --body '{
  "model": "meetkai:functionary-medium",
  "training_file": "file_abc123",
  "validation_file": "file_def456",
  "suffix": "support-bot",
  "seed": 42,
  "method": {
    "type": "supervised",
    "supervised": {
      "hyperparameters": {
        "n_epochs": 3
      }
    }
  },
  "metadata": {
    "experiment": "support-bot-v1"
  }
}'

Step 3 - Poll job status

Retrieve the job until it reaches succeeded, failed, or cancelled.
mka1 llm fine-tuning retrieve \
  --fine-tuning-job-id ftjob_aa87e2b1112a455b8deabed784372198
You can also page through all jobs with mka1.llm.fineTuning.list({ limit, after }).

Step 4 - Inspect training events and checkpoints

Use events for training logs and metrics updates. Use checkpoints to inspect intermediate model checkpoints and their metrics.
mka1 llm fine-tuning list-events \
  --fine-tuning-job-id ftjob_aa87e2b1112a455b8deabed784372198 \
  --limit 20

mka1 llm fine-tuning list-checkpoints \
  --fine-tuning-job-id ftjob_aa87e2b1112a455b8deabed784372198 \
  --limit 10
Checkpoint metrics can include train_loss, train_mean_token_accuracy, valid_loss, valid_mean_token_accuracy, full_valid_loss, and full_valid_mean_token_accuracy.

Step 5 - Pause, resume, or cancel a job

Use pause when you need to temporarily stop a running job. Use resume to continue it. Use cancel to stop it permanently.
mka1 llm fine-tuning pause \
  --fine-tuning-job-id ftjob_aa87e2b1112a455b8deabed784372198

mka1 llm fine-tuning resume \
  --fine-tuning-job-id ftjob_aa87e2b1112a455b8deabed784372198

mka1 llm fine-tuning cancel \
  --fine-tuning-job-id ftjob_aa87e2b1112a455b8deabed784372198

Step 6 - Use the fine-tuned model

When the job reaches succeeded, job.fineTunedModel contains the new model ID. Pass that model ID to a Responses request.
mka1 llm responses create \
  --model ft:meetkai:functionary-medium:support-bot \
  --input '"Write a support reply for a delayed shipment."'

API reference

For the full request and response schema, open the Fine-Tuning group in the API Reference.