從 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" } }
所有狀態碼請參閱限制與錯誤。音譯、字典查詢和斷句端點無法使用。