High severity beginner · Fix: 2-5 min

OpenAIError

openai.OpenAIError (fine-tuning job failure)

What this error means
OpenAI fine-tuning job fails because the training dataset contains too few examples to start the job.

Stack trace

traceback
openai.OpenAIError: Fine-tuning job failed: insufficient training examples provided. Minimum required examples not met.
QUICK FIX
Increase your training dataset size to meet OpenAI's minimum example requirement before submitting the fine-tuning job.

Why it happens

OpenAI fine-tuning requires a minimum number of labeled training examples to create a reliable model. If the uploaded dataset contains fewer examples than the minimum threshold, the fine-tuning job is rejected with this error.

Detection

Check the number of training examples in your fine-tuning dataset before submitting the job; log the dataset size and validate it meets OpenAI's minimum requirements.

Causes & fixes

1

Training dataset contains fewer examples than OpenAI's minimum required for fine-tuning.

✓ Fix

Add more labeled examples to your training dataset to meet or exceed the minimum example count specified by OpenAI.

2

Dataset file uploaded to OpenAI is empty or corrupted, resulting in zero usable examples.

✓ Fix

Verify the dataset file content and format before upload; ensure it is not empty and follows OpenAI's JSONL fine-tuning format.

3

Incorrect file uploaded (e.g., validation or test set instead of training set).

✓ Fix

Confirm you are uploading the correct training dataset file for fine-tuning, not validation or test data.

Code: broken vs fixed

Broken - triggers the error
python
from openai import OpenAI
import os

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# This dataset has too few examples, causing the error
training_file_id = "file-abc123"

response = client.fine_tunes.create(training_file=training_file_id)  # Triggers insufficient examples error
print(response)
Fixed - works correctly
python
from openai import OpenAI
import os

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# Use a training file with sufficient examples
training_file_id = "file-valid123"

response = client.fine_tunes.create(training_file=training_file_id)  # Fixed: dataset has enough examples
print(response)
Replaced the training file with one containing enough examples to satisfy OpenAI's minimum fine-tuning requirements.

Workaround

If you cannot immediately add more examples, consider using a smaller base model or pre-trained model without fine-tuning until you gather sufficient training data.

Prevention

Always validate your training dataset size and format before uploading to OpenAI; automate checks to ensure minimum example counts are met to avoid job failures.

Python 3.9+ · openai >=1.0.0 · tested on 1.5.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.