提交存储在Azure Blob 存储中的一个或多个文档以进行异步翻译。 该服务返回一个 operation-location 标头,其中包含用于轮询状态的作业 ID。 批处理中的每个目标容器必须是唯一的;将文档提交到已转换输出的目标容器会导致文件冲突错误。 对 targetUrl 特定容器(而不是共享目标)使用。
HTTP 方法: POST API 版本: 2026-03-01
请求
POST {endpoint}/translator/document/batches?api-version=2026-03-01
| 标题 |
必需 |
Description |
Ocp-Apim-Subscription-Key |
是的 |
Azure门户中的翻译器资源密钥。 |
Ocp-Apim-Subscription-Region |
条件 |
如果使用区域资源,则为必需。 |
Content-Type |
是的 |
application/json |
请求主体
| 领域 |
必需 |
Description |
inputs |
是的 |
批处理输入对象的数组。 每个对象定义一个源和一个或多个翻译目标。 |
inputs[].source |
是的 |
源文档位置。 |
inputs[].source.sourceUrl |
是的 |
源Blob 存储容器或文件的 SAS URL。 |
inputs[].source.language |
No |
源代码(例如, en)。 如果省略,服务会自动检测语言。 |
inputs[].source.filter |
No |
包含文件 prefix 筛选器对象和 suffix 字段以限制包含的源文件。 |
inputs[].targets |
是的 |
翻译目标的数组。 |
inputs[].targets[].targetUrl |
是的 |
目标Blob 存储容器的 SAS URL。 在请求中的所有输入中必须是唯一的。 |
inputs[].targets[].language |
是的 |
目标语言代码(例如, fr)。 |
inputs[].targets[].glossaries |
No |
术语表对象的数组。 每个术语表都需要 glossaryUrl (SAS URL) 和 format (例如, TSV)。 |
inputs[].storageType |
No |
存储源类型。 支持的值: Folder (默认值), File。 |
translateWithinImage |
No |
布尔值。 设置为 true 翻译图像中的 .docx 文本和 .pptx 文件中的文本。 |
示例请求
基于 NMT 的翻译
curl -X POST "{endpoint}/translator/document/batches?api-version=2026-03-01" \
-H "Ocp-Apim-Subscription-Key: {key}" \
-H "Content-Type: application/json" \
-d '{
"inputs": [
{
"source": {
"sourceUrl": "https://{storage}.blob.core.chinacloudapi.cn/source?{sas}"
},
"targets": [
{
"targetUrl": "https://{storage}.blob.core.chinacloudapi.cn/target-fr?{sas}",
"language": "fr"
}
]
}
]
}'
多个目标语言
curl -X POST "{endpoint}/translator/document/batches?api-version=2026-03-01" \
-H "Ocp-Apim-Subscription-Key: {key}" \
-H "Content-Type: application/json" \
-d '{
"inputs": [
{
"source": {
"sourceUrl": "https://{storage}.blob.core.chinacloudapi.cn/source?{sas}"
},
"targets": [
{
"targetUrl": "https://{storage}.blob.core.chinacloudapi.cn/target-es?{sas}",
"language": "es"
},
{
"targetUrl": "https://{storage}.blob.core.chinacloudapi.cn/target-ja?{sas}",
"language": "ja"
}
]
}
]
}'
使用术语表进行翻译
curl -X POST "{endpoint}/translator/document/batches?api-version=2026-03-01" \
-H "Ocp-Apim-Subscription-Key: {key}" \
-H "Content-Type: application/json" \
-d '{
"inputs": [
{
"source": {
"sourceUrl": "https://{storage}.blob.core.chinacloudapi.cn/source?{sas}"
},
"targets": [
{
"targetUrl": "https://{storage}.blob.core.chinacloudapi.cn/target-pt?{sas}",
"language": "pt",
"glossaries": [
{
"glossaryUrl": "https://{storage}.blob.core.chinacloudapi.cn/glossaries/terms.tsv?{sas}",
"format": "TSV"
}
]
}
]
}
]
}'
翻译Word和PowerPoint文档中的图像
curl -X POST "{endpoint}/translator/document/batches?api-version=2026-03-01" \
-H "Ocp-Apim-Subscription-Key: {key}" \
-H "Content-Type: application/json" \
-d '{
"inputs": [
{
"source": {
"sourceUrl": "https://{storage}.blob.core.chinacloudapi.cn/source?{sas}"
},
"targets": [
{
"targetUrl": "https://{storage}.blob.core.chinacloudapi.cn/target-ko?{sas}",
"language": "ko"
}
],
"translateWithinImage": true
}
]
}'
响应
响应状态代码
| 状态代码 |
Description |
202 |
Accepted. 批处理作业已成功排队。 |
400 |
错误的请求。 检查请求正文中是否存在缺失或无效的字段。 |
401 |
身份验证失败。 检查订阅密钥。 |
429 |
请求过多。 减少请求频率。 |
500 |
内部服务器错误。 |
| 标题 |
Description |
operation-location |
包含用于轮询的作业 ID 的 URL。 格式: {endpoint}/translator/document/batches/{jobId}?api-version=2026-03-01. |
相关内容