Azure Form Recognizer Python SDK报错:指定模型未找到或未就绪
问题描述
我在Form Recognizer Studio中创建的表单识别模型已测试成功,但通过Python API提交文档时,抛出模型找不到的错误。
代码示例
from azure.core.credentials import AzureKeyCredential from azure.ai.formrecognizer import FormRecognizerClient endpoint = "https://eastus.api.cognitive.microsoft.com/" credential = AzureKeyCredential("xxxxxxxxxxxxxxxxxxxxxxxx") form_recognizer_client = FormRecognizerClient(endpoint, credential) path = r"3FE5A953-22D4-4197-B262-E195C3A2CE9F.pdf" with open(path, 'rb') as f: blob = f.read() poller = form_recognizer_client.begin_recognize_custom_forms(model_id='mymodel', form=blob) result = poller.result()
报错信息
azure.core.exceptions.HttpResponseError: (1001) Specified model not found or not ready, Model Id: mymodel Code: 1001 Message: Specified model not found or not ready, Model Id: mymodel
已尝试的排查动作
- 用多个API版本重新创建模型:2021-9-30-preview、2022-1-30-preview、2020-6-30-preview
- 更换多个SDK版本:3.1.2、3.1.0、3.2.0b5
问题仍未解决。
解决建议
- 核对Model ID正确性:代码中使用的
mymodel是模型的显示名称,而非系统生成的唯一ID。前往Form Recognizer Studio的模型详情页,复制系统分配的Model ID(格式类似xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)替换代码中的mymodel。 - 确认资源匹配:检查代码里的endpoint和密钥,是否与创建模型的Form Recognizer资源完全一致。跨资源调用会导致模型找不到。
- 验证地域一致性:确保模型是在
eastus区域的资源下创建的,代码中的endpoint地域必须和模型所在地域一致。 - 检查模型状态:确认模型处于“已训练完成”状态,排除训练中或失败的情况。
- 匹配SDK与API版本:SDK版本和API版本需对应,避免不兼容:
- SDK 3.1.x 对应 API 2021-09-30-preview
- SDK 3.2.x 对应 API 2022-01-30-preview
内容的提问来源于stack exchange,提问作者Mike
相关产品推荐
相关产品推荐

