High severity beginner · Fix: 2-5 min

OpenAIError

openai.OpenAIError (Model not found)

What this error means
This error occurs when the specified fine-tuned model ID does not exist or is not accessible in your OpenAI account.

Stack trace

traceback
openai.OpenAIError: The model `ft:your-org:your-model-id` does not exist or is not accessible.
    at openai.api_requestor.APIRequestor._handle_error_response (/path/to/openai/sdk)
    at openai.api_requestor.APIRequestor.request (/path/to/openai/sdk)
    at openai.client.chat.completions.create (/path/to/openai/sdk)
    at main.py:15
QUICK FIX
Double-check and use the exact fine-tuned model ID string from your OpenAI dashboard in your API call.

Why it happens

This error happens because the fine-tuned model ID provided in the API call is incorrect, deleted, or belongs to a different organization. The OpenAI API cannot find or access the model resource under your credentials.

Detection

Check for OpenAIError exceptions when calling chat completions with a fine-tuned model ID, and log the model ID used to verify correctness before retrying.

Causes & fixes

1

The fine-tuned model ID is misspelled or incorrect in the API call.

✓ Fix

Verify and correct the fine-tuned model ID string exactly as shown in your OpenAI dashboard or fine-tuning logs.

2

The fine-tuned model was deleted or is no longer available.

✓ Fix

Check your OpenAI account dashboard to confirm the model exists; if deleted, retrain or restore the fine-tuned model.

3

Your API key belongs to a different organization than the fine-tuned model's owner.

✓ Fix

Use an API key from the organization that owns the fine-tuned model or request access to that model.

Code: broken vs fixed

Broken - triggers the error
python
import os
from openai import OpenAI
client = OpenAI()

response = client.chat.completions.create(
    model="ft:wrong-org:nonexistent-model",
    messages=[{"role": "user", "content": "Hello"}]
)  # This line triggers the model not found error
Fixed - works correctly
python
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# Corrected model ID from your OpenAI fine-tuning dashboard
correct_model_id = os.environ.get("OPENAI_FINE_TUNED_MODEL")

response = client.chat.completions.create(
    model=correct_model_id,  # Fixed: use correct fine-tuned model ID from env
    messages=[{"role": "user", "content": "Hello"}]
)
print(response)
Replaced the incorrect hardcoded model ID with a correct environment variable holding the fine-tuned model ID to ensure the model exists and is accessible.

Workaround

Catch the OpenAIError exception, log the model ID used, and fallback to a base model like 'gpt-4o-mini' temporarily until the fine-tuned model issue is resolved.

Prevention

Always store and retrieve fine-tuned model IDs from a centralized config or environment variable, and verify model existence via the OpenAI dashboard before deployment.

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

Community Notes

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