You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Python SDK调用Azure文档智能2024-02-29-preview版本?

如何通过Azure AI Document Intelligence Python SDK指定API版本2024-02-29-preview

要指定目标API版本,不能在begin_analyze_document_from_url方法中添加api_version参数,正确的做法是在初始化DocumentAnalysisClient时传入该参数。

修正后的代码示例

from azure.core.credentials import AzureKeyCredential
from azure.ai.formrecognizer import DocumentAnalysisClient

# 初始化客户端时指定API版本
document_analysis_client = DocumentAnalysisClient(
    endpoint=endpoint,
    credential=AzureKeyCredential(key),
    api_version="2024-02-29-preview"
)

poller = document_analysis_client.begin_analyze_document_from_url('prebuilt-layout', formUrl, locale='de')
result = poller.result()

print(result.api_version)  # 输出应为2024-02-29-preview

关键说明

  1. Azure Python SDK的API版本是在客户端实例化时确定的,而非单个方法调用时指定。之前在方法中添加api_version参数属于无效传参,会导致请求路径错误,触发404报错。
  2. 确保你的azure-ai-formrecognizer SDK包是最新版本,旧版本可能不支持2024-02-29-preview这个预览版API,可通过以下命令更新:
pip install --upgrade azure-ai-formrecognizer

内容的提问来源于stack exchange,提问作者Felix T.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 05:22:36