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

OpenAIError

openai.OpenAIError (Azure OpenAI deployment not found)

What this error means
Azure OpenAI returns a 404 error when the specified model deployment name is not found or incorrectly configured.

Stack trace

traceback
openai.OpenAIError: The deployment named 'my-model-deployment' was not found. Please verify your Azure OpenAI deployment name and region configuration.
QUICK FIX
Double-check and correct the deployment_name parameter and Azure API base URL in your OpenAI client initialization.

Why it happens

This error occurs because the Azure OpenAI client cannot find the specified model deployment in the configured Azure resource. It usually means the deployment name is misspelled, missing, or the Azure region or resource endpoint is incorrect.

Detection

Check for OpenAIError exceptions with 404 status and error messages mentioning deployment not found. Log the deployment name and Azure endpoint used in the request.

Causes & fixes

1

Incorrect or misspelled deployment name in the client configuration

✓ Fix

Verify and correct the deployment name string to exactly match the Azure OpenAI deployment name.

2

Azure OpenAI resource region or endpoint is misconfigured or missing

✓ Fix

Ensure the Azure OpenAI API base URL and region match the resource where the deployment exists.

3

Deployment was not created or has been deleted in the Azure portal

✓ Fix

Create the deployment in the Azure portal or redeploy the model with the correct name.

Code: broken vs fixed

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

client = OpenAI(
    api_key=os.environ['AZURE_OPENAI_API_KEY'],
    api_base=os.environ['AZURE_OPENAI_API_BASE'],
    api_type='azure',
    api_version='2023-05-15'
)

response = client.chat.completions.create(
    model='my-model-deployment',  # Incorrect or missing deployment name
    messages=[{"role": "user", "content": "Hello"}]
)  # This line triggers the deployment not found error
Fixed - works correctly
python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ['AZURE_OPENAI_API_KEY'],
    api_base=os.environ['AZURE_OPENAI_API_BASE'],
    api_type='azure',
    api_version='2023-05-15'
)

response = client.chat.completions.create(
    model=os.environ['AZURE_OPENAI_DEPLOYMENT_NAME'],  # Fixed: use correct deployment name from env
    messages=[{"role": "user", "content": "Hello"}]
)
print(response)  # Shows successful response
Corrected the model parameter to use the exact Azure deployment name from environment variables, ensuring the client targets a valid deployment.

Workaround

Catch OpenAIError exceptions, log the deployment name and endpoint, and fallback to a default or backup deployment if available.

Prevention

Automate deployment name and Azure endpoint configuration via environment variables or config files, and validate deployment existence during startup.

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.