Translation Task API
Create translation task
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
| Parameters | Type | Default | Description | Example |
|---|---|---|---|---|
| Required: file | binary | - |
| bitcoin.pdf |
| Required: fromLang | String | - |
| English |
| Required: toLang | String | - |
| Simplified Chinese |
| model | String | - |
| - |
| fileDescription | String | - | Document description: Enhance translation quality by providing additional information, such as document background context and other translation requirements | - |
| glossary | String | - | Glossary name used during translation | - |
| preview | Boolean | false | Generate preview only Preview generation: Pay 2 credits to generate document translation preview | - |
| shouldTranslateImage | Boolean | false |
| - |
| forceOCR | Boolean | false | Whether to force use of OCR to recognize document content. When enabled, image translation will also be activated. | - |
| shouldTranslateFileName | Boolean | true | Whether to translate file names | - |
| strictSourceLanguageCheck | Boolean | false | 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. | - |
| outputFormat | String | - | Output format. When MD is passed in, it will attempt to generate Markdown translation. | MD |
| bilingualMode | String | Horizontal | Bilingual file layout direction. Horizontal means side-by-side comparison, Vertical means top-to-bottom comparison. | Horizontal |
| password | String | - | PDF file opening password | - |
| ignoreComments | Boolean | false | Ignore comments in DOCX, PPTX, and XLSX files | - |
| ignoreNotes | Boolean | false | Whether to ignore PPTX notes | - |
| ignoreHeadersAndFooters | Boolean | false | Ignore headers and footers in DOCX files | - |
| ignoreHidden | Boolean | false | Whether to ignore PPTX hidden slides | - |
| ignoreMasters | Boolean | false | Whether to ignore PPTX master text | - |
| ignoreSheetNames | Boolean | false | Skip translation of XLSX sheet names | - |
| extractTextRegExpPattern | String | - |
| - |
| extractTextRegExpFlags | String | - |
| - |
| allowFlip | Boolean | true | Whether to allow flipping page layout for right-to-left languages. Passing false will also disable image flipping. | - |
| allowFlipImage | Boolean | true | Whether to allow flipping image content for right-to-left languages. | - |
| webhookUrl | String | - | Callback URL for status updates, the callback content includes: {taskId, progress, status} | - |
Response
| Parameters | Type | Default | Description | Example |
|---|---|---|---|---|
| taskId | String | - | 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.