Document Directory

Translation Task API

Create translation task

POST/v1/translation/create

Create a new translation task for document/file translation.

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

Notes

Creating a task immediately enters the waiting queue and returns a taskId. Subsequently, progress, cost, and download link can be obtained through the query task interface.

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

The glossary parameter matches by glossary name and can be passed in repeatedly with multiple fields of the same name to specify multiple glossaries.

Example

1curl -X POST 'https://deploy-demo.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
Required: filebinary-
  • Files to be translated
  • Supported file types: Query
bitcoin.pdf
Required: fromLangString-
  • Source language; the source language cannot be the same as the target language
  • Supported languages: Query
English
Required: 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: Enhance translation quality by providing additional information, such as document background context and other translation requirements

-
glossaryString-

Glossary name used during translation

-
previewBooleanfalse

Generate preview only Preview generation: Pay 2 credits to generate document translation preview

-
shouldTranslateImageBooleanfalse
  • Whether to translate images in the document
  • Only supports PDF / DOCX / PPTX / EPUB / ODS / ODT / ODF
-
forceOCRBooleanfalse

Whether to force use of OCR to recognize document content. When enabled, image translation will also be activated.

-
shouldTranslateFileNameBooleantrue

Whether to translate file names

-
strictSourceLanguageCheckBooleanfalse

Whether to translate only text recognized 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 passed in, it will attempt to generate Markdown translation.

MD
bilingualModeStringHorizontal

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

Horizontal
passwordString-

PDF file opening password

-
ignoreCommentsBooleanfalse

Ignore comments in DOCX, PPTX, and XLSX files

-
ignoreNotesBooleanfalse

Whether to ignore PPTX notes

-
ignoreHeadersAndFootersBooleanfalse

Ignore headers and footers in DOCX files

-
ignoreHiddenBooleanfalse

Whether to ignore PPTX hidden slides

-
ignoreMastersBooleanfalse

Whether to ignore PPTX master text

-
ignoreSheetNamesBooleanfalse

Skip translation of XLSX sheet names

-
extractTextRegExpPatternString-
  • Only translate content matching the regular expression and replace it with the translation
  • Only supports txmsg
-
extractTextRegExpFlagsString-
  • Regular expression Flags: g, s, m, u, y
  • Only supports txmsg
-
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, the 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