High severity HTTP 404 beginner · Fix: 2-5 min

OpenAIError

openai.OpenAIError (embedding model not found)

What this error means
The OpenAI API returns a model not found error when the specified embedding model name is invalid or deprecated.

Stack trace

traceback
openai.OpenAIError: The model `text-embedding-xyz` does not exist
    at openai.api_requestor.APIRequestor._handle_error_response (/path/to/sdk/requestor.py:123)
    at openai.api_requestor.APIRequestor.request (/path/to/sdk/requestor.py:85)
    at openai.embeddings.Embedding.create (/path/to/sdk/embeddings.py:45)
    at main.py:15
QUICK FIX
Replace the embedding model name with a valid, supported model from OpenAI's latest embedding models list.

Why it happens

This error occurs because the embedding model name provided to the OpenAI embeddings API is incorrect, misspelled, deprecated, or not available in your account's region or subscription. The API cannot find the requested model to generate embeddings.

Detection

Check the API response for a 404 OpenAIError indicating the model name is invalid. Log the model parameter before the API call to verify correctness.

Causes & fixes

1

Using a non-existent or misspelled embedding model name in the API call

✓ Fix

Verify and use a valid embedding model name from the official OpenAI documentation, such as 'text-embedding-3-small' or 'text-embedding-3-large'.

2

Using a deprecated embedding model that OpenAI no longer supports

✓ Fix

Update your code to use a currently supported embedding model listed in the latest OpenAI API docs.

3

Model access restricted due to account permissions or region limitations

✓ Fix

Check your OpenAI account subscription and region availability to ensure you have access to the requested embedding model.

Code: broken vs fixed

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

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

response = client.embeddings.create(
    model='text-embedding-xyz',  # invalid model name triggers error
    input='Hello world'
)
print(response)
Fixed - works correctly
python
import os
from openai import OpenAI

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

response = client.embeddings.create(
    model='text-embedding-3-small',  # fixed to valid model name
    input='Hello world'
)
print(response)  # prints embedding vector
Changed the model parameter to a valid embedding model name recognized by the OpenAI API to avoid the model not found error.

Workaround

Catch the OpenAIError exception, log the invalid model name, and fallback to a default valid embedding model to continue processing.

Prevention

Always validate embedding model names against the official OpenAI API documentation and keep your dependencies and model names updated to supported versions.

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.