# openai.NotFoundError：未找到资源。部署 '<deployment-name>' 不存在。

- **ID:** `llm/azure-openai-deployment-not-found`
- **领域:** llm
- **类别:** config_error
- **错误码:** `DeploymentNotFound`
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

Azure OpenAI 端点 URL 或部署名称配置错误：部署可能已被删除、重命名，或者端点 URL 中的资源组/区域与实际部署位置不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| openai==1.30.0 | active | — | — |
| azure-identity==1.16.0 | active | — | — |
| azure-ai-openai==1.0.0 | active | — | — |

## 解决方案

1. ```
   Verify the deployment name in Azure Portal: go to Azure OpenAI Studio > Deployments > copy the exact deployment name (case-sensitive). Then set `openai.Deployment('your-deployment-name')`.
   ```
2. ```
   List all deployments programmatically: `from openai import AzureOpenAI; client = AzureOpenAI(api_key=key, api_version='2023-12-01-preview', azure_endpoint=endpoint); deployments = client.deployments.list(); print([d.id for d in deployments])`
   ```
3. ```
   Ensure the `azure_endpoint` includes the full resource URL (e.g., `https://my-resource.openai.azure.com/`) and matches the region where the deployment was created.
   ```

## 无效尝试

- **** — The error is about the deployment name, not the API key; a valid key with a wrong deployment still fails. (90% 失败率)
- **** — The deployment is tied to a specific model; changing the model in code doesn't change the deployment's actual model. (85% 失败率)
- **** — The endpoint URL must match the exact resource; a wrong region or resource name will still cause NotFoundError. (95% 失败率)
