Translation Task API
Create Translation Task
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
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
| Parameters | Type | Default | Description | Example |
|---|---|---|---|---|
| *file | binary | - |
| bitcoin.pdf |
| *fromLang | String | - |
| English |
| *toLang | String | - |
| Simplified Chinese |
| model | String | - |
| - |
| fileDescription | String | - | Document description. Improve translation quality by providing additional information, such as extra document background information and other translation requirements. | - |
| glossary | String | - | Terminology glossary name used for translation | - |
| preview | Boolean | false | Generate preview only. When generating preview only, spend 2 credits to generate a document translation preview | - |
| shouldTranslateImage | Boolean | false |
| - |
| forceOCR | Boolean | false | Force OCR for document content recognition. When enabled, image translation will also be enabled. | - |
| shouldTranslateFileName | Boolean | true | Translate file names | - |
| strictSourceLanguageCheck | Boolean | false | 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. | - |
| outputFormat | String | - | Output format. When MD is provided, it will attempt to generate Markdown translation. | MD |
| bilingualMode | String | Horizontal | Bilingual file layout direction. Horizontal indicates side-by-side layout, Vertical indicates top-to-bottom layout. | Horizontal |
| password | String | - | Password for opening PDF files | - |
| ignoreComments | Boolean | false | Ignore comments in DOCX, PPTX, and XLSX files | - |
| ignoreNotes | Boolean | false | Ignore speaker notes in PPTX files | - |
| ignoreHeadersAndFooters | Boolean | false | Ignore headers and footers in DOCX files | - |
| ignoreHidden | Boolean | false | Ignore hidden slides in PPTX files | - |
| ignoreMasters | Boolean | false | Ignore master slide text in PPTX files | - |
| ignoreSheetNames | Boolean | false | Whether to skip translating 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. 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.