Document Directory

Translation Task API

Create Translation Task

POST/v1/translation/create

Create a new translation task for document/file translation.

Complete address
https://otranslator.com/api/v1/translation/create
Authentication
API Key needs to be passed in the Authorization request header
Content-Type
multipart/form-data
Invalid format
{ "error": "Invalid API key." }

Precautions

Creating a task immediately enters the waiting queue and returns a taskId. Progress, cost, and download link can subsequently be obtained by querying the task interface.

Account credit balance must be at least 2 credits to create a task. When preview is true, only preview is generated and preview credits are paid.

The glossary parameter matches by glossary name, and multiple same-name fields can be repeatedly passed to specify multiple glossaries.

Example

curl
1curl -X POST 'https://otranslator.com/api/v1/translation/create' \
2--header 'Authorization: [yourSecretKey]' \
3--form 'file=@bitcoin.pdf' \
4--form 'fromLang=English' \
5--form 'toLang=Simplified Chinese' \
6--form 'outputFormat=MD' \
7--form 'bilingualMode=Horizontal' 

Request Parameters

ParametersTypeDefaultDescriptionExample
*filebinary-
  • Files to be translated
  • Supported file types: Query
bitcoin.pdf
*fromLangString-
  • Source language; the source language cannot be the same as the target language
  • Supported languages: Query
English
*toLangString-
  • Target language; the target language cannot be the same as the source language
  • Supported languages: Query
Simplified Chinese
modelString-
  • AI model for translation
  • Supported models: Query
-
fileDescriptionString-

Document description. Improve translation quality by providing additional information, such as extra document background information and other translation requirements.

-
glossaryString-

Terminology glossary name used for translation

-
previewBooleanfalse

Generate preview only. When generating preview only, spend 2 credits to generate a document translation preview

-
shouldTranslateImageBooleanfalse
  • Enable image translation within documents
  • Supports PDF / DOCX / PPTX / EPUB / ODS / ODT / ODF formats only
-
forceOCRBooleanfalse

Force OCR for document content recognition. When enabled, image translation will also be enabled.

-
shouldTranslateFileNameBooleantrue

Translate file names

-
strictSourceLanguageCheckBooleanfalse

Whether to only translate text identified as the source language. When enabled, non-source language content will be filtered more strictly, and a stricter coefficient will be used for cost calculation.

-
outputFormatString-

Output format. When MD is provided, it will attempt to generate Markdown translation.

MD
bilingualModeStringHorizontal

Bilingual file layout direction. Horizontal indicates side-by-side layout, Vertical indicates top-to-bottom layout.

Horizontal
passwordString-

Password for opening PDF files

-
ignoreCommentsBooleanfalse

Ignore comments in DOCX, PPTX, and XLSX files

-
ignoreNotesBooleanfalse

Ignore speaker notes in PPTX files

-
ignoreHeadersAndFootersBooleanfalse

Ignore headers and footers in DOCX files

-
ignoreHiddenBooleanfalse

Ignore hidden slides in PPTX files

-
ignoreMastersBooleanfalse

Ignore master slide text in PPTX files

-
ignoreSheetNamesBooleanfalse

Whether to skip translating XLSX sheet names

-
extractTextRegExpPatternString-
  • Only translate content matching regular expressions and replace with translations
  • Supports txmsg format only
-
extractTextRegExpFlagsString-
  • Regular expression flags: g, s, m, u, y
  • Supports txmsg format only
-
allowFlipBooleantrue

Whether to allow flipping page layout for right-to-left languages. Passing false will also disable image flipping.

-
allowFlipImageBooleantrue

Whether to allow flipping image content for right-to-left languages.

-
webhookUrlString-

Callback URL for status updates. Callback content includes: {taskId, progress, status}

-

Response

ParametersTypeDefaultDescriptionExample
taskIdString-

Task ID

-

Common Errors

401 Missing API key.

The Authorization request header is required.

401 Invalid API key.

The API key does not exist, has been deleted, or is no longer valid.

402 Insufficient credits balance.

The account does not have enough credits to create the task.

400 Missing required parameter: fromLang.

Provide fromLang using a language returned by /api/v1/languages.

400 Missing required parameter: toLang.

Provide toLang using a language returned by /api/v1/languages.

400 Invalid fromLang: [language]. Use a language returned by /api/v1/languages.

The provided source language is not supported.

400 Invalid toLang: [language]. Use a language returned by /api/v1/languages.

The provided target language is not supported.

400 Missing required file upload: file.

Upload the source document in the file form field.

404 Glossary "[name]" not found.

The specified glossary does not exist or does not belong to the current API account.

Introduction
Become a Developer
Translation Task API
Query translation tasks