OpenAIError
openai.OpenAIError (base model not supported for fine-tuning)
Stack trace
openai.OpenAIError: The base model 'gpt-4o' is not supported for fine-tuning. Please select a supported base model such as 'gpt-3.5-turbo' or 'gpt-4o-mini'.
Why it happens
OpenAI restricts fine-tuning to specific base models that are designed to support it. Attempting to fine-tune a base model that is not enabled for fine-tuning triggers this error. This prevents unsupported or incompatible models from being fine-tuned, ensuring stability and performance.
Detection
Check the base model parameter before starting fine-tuning. Validate against OpenAI's list of supported fine-tuning base models to catch unsupported models early.
Causes & fixes
Using a base model that is not enabled for fine-tuning, such as 'gpt-4o' or other unsupported variants.
Switch to a supported fine-tuning base model like 'gpt-3.5-turbo' or 'gpt-4o-mini' as documented by OpenAI.
Passing an incorrect or misspelled model name that defaults to an unsupported model.
Verify the exact model name string matches a supported fine-tuning base model and correct any typos.
Using outdated OpenAI SDK or API version that does not recognize newer supported fine-tuning models.
Upgrade the OpenAI SDK to the latest version to ensure compatibility with current fine-tuning base models.
Code: broken vs fixed
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])
response = client.fine_tunes.create(
training_file='file-abc123',
model='gpt-4o', # This model is not supported for fine-tuning
)
print(response) import os
from openai import OpenAI
client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])
response = client.fine_tunes.create(
training_file='file-abc123',
model='gpt-4o-mini', # Changed to a supported fine-tuning base model
)
print(response) # This will succeed if the model supports fine-tuning Workaround
If you cannot switch models immediately, catch the OpenAIError exception and notify users or fallback to a supported model programmatically.
Prevention
Always consult OpenAI's official fine-tuning documentation to use only supported base models and keep your SDK updated to avoid compatibility issues.