从 Azure Translator 迁移
只需更改端点和订阅密钥,即可将 Azure Translator v3 集成迁移到 VibeQL。
VibeQL 提供 Azure Translator v3 文本格式和同步文档翻译端点。更改端点和密钥,保留您的请求代码即可。
| Azure | VibeQL | |
|---|---|---|
| 文本端点 | https://api.cognitive.microsofttranslator.com |
https://vibeql.com |
| 文档端点 | https://<resource>.cognitiveservices.azure.com |
https://vibeql.com |
| 密钥 | Ocp-Apim-Subscription-Key Azure 密钥 |
Ocp-Apim-Subscription-Key VibeQL 密钥 |
VibeQL 不使用 Ocp-Apim-Subscription-Region 请求头。保留或删除都可以。
翻译
POST https://vibeql.com/translate?api-version=3.0&to=de
| 查询参数 | 是否必填 | 说明 |
|---|---|---|
api-version |
支持 | 3.0 |
to |
支持 | 目标语言。最多可重复 10 种语言。 |
from |
不支持 | 源语言。省略时由 API 自动识别。 |
请求体是一个 JSON 数组,最多包含 50 个带 Text 字段的条目。
curl "https://vibeql.com/translate?api-version=3.0&to=de&to=ja" \
-H "Ocp-Apim-Subscription-Key: $VIBEQL_API_KEY" \
-H "Content-Type: application/json" \
-d '[{"Text": "The meeting starts at nine."}]'
[
{
"detectedLanguage": { "language": "en", "score": 1 },
"translations": [
{ "text": "Das Meeting beginnt um neun.", "to": "de" },
{ "text": "会議は9時に始まります。", "to": "ja" }
]
}
]
detectedLanguage 仅当您省略 from 时才会出现。用量会针对每个 to 语言各统计一次源字符数。其他 Azure 选项(例如 textType 或 profanityAction)会被忽略。
检测语言
POST https://vibeql.com/detect?api-version=3.0
curl "https://vibeql.com/detect?api-version=3.0" \
-H "Ocp-Apim-Subscription-Key: $VIBEQL_API_KEY" \
-H "Content-Type: application/json" \
-d '[{"Text": "Hola, ¿cómo estás?"}]'
[{ "language": "es", "score": 1, "isTranslationSupported": true, "isTransliterationSupported": false }]
列出语言
GET https://vibeql.com/languages?api-version=3.0 返回 translation 权限范围。与 Azure 不同,此端点需要密钥。
curl "https://vibeql.com/languages?api-version=3.0" \
-H "Ocp-Apim-Subscription-Key: $VIBEQL_API_KEY"
{ "translation": { "de": { "name": "German", "nativeName": "German", "dir": "ltr" } } }
翻译文档
POST https://vibeql.com/translator/document:translate 翻译单个文件并在响应中返回。将文件作为 multipart 字段 document 发送。
| 查询参数 | 是否必填 | 说明 |
|---|---|---|
api-version |
支持 | 2024-05-01 |
targetLanguage |
支持 | 目标语言。 |
sourceLanguage |
不支持 | 源语言。 |
curl "https://vibeql.com/translator/document:translate?targetLanguage=fr&api-version=2024-05-01" \
-H "Ocp-Apim-Subscription-Key: $VIBEQL_API_KEY" \
-F "document=@contract.docx" \
-o contract.fr.docx
请求最多等待 90 秒。如果翻译耗时更长,API 会返回 504。对于大文件,请使用DeepL 文档流程,它对单个请求没有时间限制。支持的格式:DOCX、PPTX、PDF 和 TXT。
glossary 字段和批量文档翻译 API 均不可用。
语言代码
VibeQL 支持 34 种目标语言,比 Azure 少。VibeQL 不支持的语言代码会返回 400。请参阅语言。
zh-Hans和zh-Hant的用法与 Azure 相同。en对应美式英语。英式英语请发送en-GB。- 语言代码不区分大小写。
错误
错误采用 Azure 格式,包含一个以 HTTP 状态码开头的六位数字代码:
{ "error": { "code": 403000, "message": "Authorization failure, check auth_key" } }
所有状态码请参阅限制与错误。音译、词典查询和断句端点均不可用。