Fine-tuning trains an existing OpenAI model on your own dataset to customize its behavior, tone, format, or domain knowledge. It does NOT add new knowledge — it adjusts HOW the model responds.
| Try First | Then Try | Last Resort |
|---|---|---|
| Prompt Engineering | RAG (Retrieval) | Fine-Tuning |
| 90% of use cases | Domain knowledge | Behavior/format changes |
// Training data format (JSONL):
{"messages": [
{"role": "system", "content": "You are a concise legal assistant."},
{"role": "user", "content": "Summarize this contract clause..."},
{"role": "assistant", "content": "Key terms: ..."}
]}
// Create fine-tuning job:
const job = await openai.fineTuning.jobs.create({
training_file: "file-abc123",
model: "gpt-5.4-mini",
hyperparameters: { n_epochs: 3 }
});