Azure OpenAI DeploymentNotFound — deployment name vs model ID
Every developer coming from openai.com hits this within their first hour on Azure. The SDK looks identical but the model parameter means something completely different.
Quick fix (TL;DR)
model parameter is not the model ID (gpt-4o) — it is the deployment name you chose when you deployed the model in the Azure portal or via az cognitiveservices. Use the AzureOpenAI client (not OpenAI) and pass your deployment name to model= or azure_deployment=. The fix is a two-line change to the client instantiation.Real error messages you'll see
These are the exact strings returned by the Azure OpenAI service and its SDKs when this error occurs. Copy-paste-searching any of them should land on this page.
openai.NotFoundError: Error code: 404 - {'error': {'code': 'DeploymentNotFound', 'message': 'The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.'}}HTTP/1.1 404 Not Found
apim-request-id: 8f42a1b3-9c7e-4d5f-b8a1-3c8e7f9d2b4c
Content-Type: application/json
{
"error": {
"code": "DeploymentNotFound",
"message": "The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again."
}
}RestError: The API deployment for this resource does not exist. (code: 'DeploymentNotFound', statusCode: 404)
Reference
openai.com vs Azure OpenAI — what the parameters actually mean
Same SDK signature, different semantics. The model field is polymorphic: on the OpenAI platform it identifies a foundation model; on Azure it identifies your deployment (which happens to wrap a model).
| Concept | openai.com | Azure OpenAI |
|---|---|---|
| Client class | OpenAI() | AzureOpenAI() |
| Auth parameter | api_key | api_key + azure_endpoint + api_version |
Value of model= | Model ID, e.g. gpt-4o | Deployment name you chose, e.g. gpt4o-prod |
| Alt parameter | n/a | azure_deployment= on client init |
| URL shape | api.openai.com/v1/chat/completions | {resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version=... |
| Discover names | GET /v1/models | Azure portal → your resource → Deployments; or az cognitiveservices account deployment list |
Where the deployment name comes from
The name is user-defined at deployment creation time and is independent of the underlying model.
| Underlying model | Typical deployment names in the wild | What developers wrongly pass |
|---|---|---|
| gpt-4o (2024-08-06) | gpt4o-prod, gpt-4o, chat-prod | gpt-4o (may or may not exist) |
| gpt-4o-mini | gpt4o-mini, cheap-chat | gpt-4o-mini |
| text-embedding-3-large | embed-large, text-embedding-3-large | text-embedding-3-large |
| gpt-4.1 | gpt41, gpt-4.1-prod | gpt-4.1 |
| o3-mini | o3-mini, reasoning-prod | o3-mini |
Root causes, ranked by frequency
Based on developer reports across Azure OpenAI SDK forums, GitHub issues, and Microsoft Q&A during 2025–2026.
- 55%Passing the OpenAI model ID (
gpt-4o) instead of your Azure deployment name. This is the #1 cause. The deployment name is arbitrary — whatever the team who provisioned the resource picked. The two only match when someone deliberately named the deployment after the model. - 18%Using the
OpenAIclient instead ofAzureOpenAI. Even with a valid deployment name, hittingapi.openai.comwith an Azure API key produces auth or 404 errors —AzureOpenAIroutes to{resource}.openai.azure.com/openai/deployments/<name>/…. - 11%Deployment exists in a different region or resource. Development uses East US, production hits West Europe — deployments are per-resource, not shared. The name being identical is a coincidence, not a guarantee.
- 7%Deployment was created < 5 minutes ago. Azure sometimes needs propagation time; the error message says so explicitly. Retry after 60–120 seconds.
- 5%Case mismatch or typo. Deployment names are case-sensitive in the URL path:
GPT4o-Prodandgpt4o-prodare different deployments. - 3%Deployment was deleted or renamed and code still references the old name. Common after infra migrations or Terraform re-deploys.
- 1%Wrong
api_version. Some deployments (e.g.o3-mini, embeddings v3) require newer API versions; older versions return 404 instead of a clear "API version not supported" error.
Fixes — copy-paste solutions
Use AzureOpenAI client and pass your deployment name
Swap the OpenAI client for AzureOpenAI, provide the endpoint and API version, and pass your deployment name as the model argument. Nothing else in your code changes.
import os from openai import AzureOpenAI # CORRECT: AzureOpenAI client, not OpenAI client = AzureOpenAI( api_key=os.environ["AZURE_OPENAI_API_KEY"], azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"], # https://myresource.openai.azure.com api_version="2024-10-21", # or a newer GA version ) # CORRECT: model= is your DEPLOYMENT NAME, not "gpt-4o" response = client.chat.completions.create( model="gpt4o-prod", # <-- your deployment name messages=[ {"role": "user", "content": "Hello Azure!"}, ], max_tokens=200, ) print(response.choices[0].message.content)
# Fill these three. The deployment name is what you set in Azure Portal # under: your Azure OpenAI resource -> Deployments -> Deployment name column. AZURE_OPENAI_API_KEY=your-key-here AZURE_OPENAI_ENDPOINT=https://myresource.openai.azure.com AZURE_OPENAI_DEPLOYMENT=gpt4o-prod
gpt-4o literally so the code looks the same. It only works because someone chose that name. Never assume — always confirm the deployment name from the portal or CLI before shipping.List deployments programmatically to discover the correct name
The Azure OpenAI data plane does not expose a deployment listing endpoint; you use the Azure Cognitive Services management API instead. This snippet lists every deployment and its underlying model so you can pick the right name at runtime.
import os from azure.identity import DefaultAzureCredential from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient # Uses az login or workload identity — no static keys needed credential = DefaultAzureCredential() subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] resource_group = os.environ["AZURE_RESOURCE_GROUP"] account_name = os.environ["AZURE_OPENAI_RESOURCE"] # the resource name, not endpoint client = CognitiveServicesManagementClient(credential, subscription_id) print(f"Deployments in {account_name}:") print(f"{'Deployment name':<30} {'Model':<25} {'Version':<15} {'SKU':<15}") print("-" * 85) for deployment in client.deployments.list(resource_group, account_name): props = deployment.properties model = props.model sku = deployment.sku.name if deployment.sku else "-" print(f"{deployment.name:<30} {model.name:<25} {model.version:<15} {sku:<15}")
# Prereqs pip install azure-identity azure-mgmt-cognitiveservices # Login (interactive) — for CI use a service principal or workload identity az login # Set context export AZURE_SUBSCRIPTION_ID=$(az account show --query id -o tsv) export AZURE_RESOURCE_GROUP=my-rg export AZURE_OPENAI_RESOURCE=my-aoai-resource python list_deployments.py
az cognitiveservices account deployment list --name $AZURE_OPENAI_RESOURCE --resource-group $AZURE_RESOURCE_GROUP -o table.Guard the client with a deployment-existence check on startup
Wrap your client factory so that startup fails immediately with a clear error if the deployment does not exist, and retries with backoff when the error indicates recent creation. This turns a runtime 404 into a boot-time assertion.
import os import time import logging from typing import Optional from openai import AzureOpenAI, NotFoundError log = logging.getLogger(__name__) class DeploymentMissingError(RuntimeError): """Raised when the configured Azure OpenAI deployment does not exist.""" def build_azure_client( deployment: str, api_version: str = "2024-10-21", warmup: bool = True, max_retries: int = 3, ) -> AzureOpenAI: """Build an AzureOpenAI client and verify the deployment is reachable.""" client = AzureOpenAI( api_key=os.environ["AZURE_OPENAI_API_KEY"], azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"], api_version=api_version, ) if not warmup: return client # Cheap probe: 1-token completion. Costs a fraction of a cent. for attempt in range(1, max_retries + 1): try: client.chat.completions.create( model=deployment, messages=[{"role": "user", "content": "ok"}], max_tokens=1, ) log.info("Deployment %s reachable", deployment) return client except NotFoundError as e: body = str(e).lower() recently_created = "last 5 minutes" in body or "please wait" in body if recently_created and attempt < max_retries: wait = 30 * attempt log.warning("Deployment %s not ready — retry in %ss", deployment, wait) time.sleep(wait) continue raise DeploymentMissingError( f"Azure OpenAI deployment '{deployment}' does not exist on " f"{os.environ['AZURE_OPENAI_ENDPOINT']}. " f"Check portal -> Deployments, or run: az cognitiveservices " f"account deployment list --name <resource> -g <rg>" ) from e # Usage in app startup if __name__ == "__main__": client = build_azure_client(deployment=os.environ["AZURE_OPENAI_DEPLOYMENT"])
Prevention checklist
Ship these seven safeguards once and this error stops appearing in your logs.
- Always instantiate
AzureOpenAI(notOpenAI) when your endpoint is*.openai.azure.com. Add a lint rule or import-check in CI. - Store the deployment name in an environment variable (e.g.
AZURE_OPENAI_DEPLOYMENT) rather than hardcoding — this is the value that varies per environment. - Document the mapping deployment name → underlying model → API version in your infra README. Include what to do when Azure deprecates a model version.
- On startup, probe the deployment with a 1-token request and fail fast if it returns 404 — cheaper than discovering it under production load.
- When onboarding a new environment, run
az cognitiveservices account deployment listbefore writing any code — never assume names carry across resources. - Pin
api_versionto a GA version (e.g.2024-10-21) and bump it deliberately when adopting new features. Preview versions can disappear. - If you use Terraform or Bicep, output the deployment name as a stack output and consume it from your app config — never let humans retype it.
Frequently asked questions
gpt-4o. Your code then works verbatim on both platforms. The trade-off is that you lose the ability to run multiple deployments of the same model (for A/B testing, blue-green, or different content filter policies). For simple single-tenant apps this is fine; for platforms serving multiple clients it forces you to prefix deployment names anyway.DeploymentNotFound when the deployment does not exist on your specific resource — even if the underlying model is generally available. The Azure error is scoped per-resource, per-region, per-tenant; the OpenAI error is global.- Case-sensitivity — the deployment name in the URL is case-sensitive,
GPT4oandgpt4oare different. - Endpoint mismatch — verify
azure_endpointpoints to the same resource that hosts the deployment, not a sibling resource in the same subscription. - API version — some newer models require
api_version2024-10-21or later, and older versions surface as 404 instead of a clearer error.
Related errors & hubs
Get the weekly AI-error digest
New fixes, provider status recaps, and one deep tutorial — every Tuesday. 8,400+ engineers.