Reference · API

OpenAI fine-tuning & jobs

Last updated

Train a **custom model variant** on your examples — tone, format, domain phrasing — via supervised fine-tuning jobs.

Train a **custom model variant** on your examples — tone, format, domain phrasing — via supervised fine-tuning jobs.

#When to use

  • Stable output style or JSON habits you cannot prompt reliably
  • Domain vocabulary the base model mishandles
  • High-volume calls where a smaller tuned model beats a giant general model
  • Prefer **RAG** when facts change often; fine-tuning does not inject fresh knowledge.

    #Endpoints

    POST https://api.openai.com/v1/fine_tuning/jobs
    GET  https://api.openai.com/v1/fine_tuning/jobs/{job_id}

    #Request shape (sketch)

    {
      "training_file": "file-train123",
      "validation_file": "file-val456",
      "model": "gpt-4o-mini-2024-07-18",
      "hyperparameters": { "n_epochs": 3 }
    }

    Training file: JSONL with `messages` arrays (chat format) or completion pairs per provider docs.

    #Job lifecycle

    upload JSONL → create job → queued → running → succeeded | failed
    → fine_tuned_model id → use in chat/completions like any model name

    #Common pitfalls

    | Pitfall | Fix |

    |---------|-----|

    | Too few / noisy examples | Curate 50–500 high-quality rows first |

    | Leaking PII in training data | Redact before upload |

    | Expecting new facts | Pair with RAG for changing knowledge |

    | No holdout eval | Keep validation split; run golden tasks |