Translation Task API
Translation text
Translate text and synchronously return translation results.
- Complete Address
- https://deploy-demo.otranslator.com/api/v1/translation/translateTexts
- Authentication
- API Key needs to be passed in the Authorization request header
- Content-Type
- application/json
- Error Format
- { "error": "Invalid API key." }
Notes
This endpoint temporarily saves the input text as a JSON document and processes it synchronously, suitable for real-time translation of small batches of text.
Account credit balance must be at least 2 credits. If the actual cost exceeds the balance, the API will return taskId and price, and prompt insufficient balance.
Example
1curl -X POST 'https://deploy-demo.otranslator.com/api/v1/translation/translateTexts' \
2--header 'Authorization: [yourSecretKey]' \
3--header 'Content-Type: application/json' \
4--data '{
5 "texts": [
6 "string"
7 ],
8 "fromLang": "[string]",
9 "toLang": "[string]"
10}'Request Parameters
| Parameters | Type | Default | Description | Example |
|---|---|---|---|---|
| Required: texts | String[] | - | Text to be translated | - |
| Required: fromLang | String | - |
| - |
| Required: toLang | String | - |
| - |
| model | String | - |
| - |
| fileDescription | String | - | Document description: Enhance translation quality by providing additional information, such as document background context and other translation requirements | - |
Response
| Parameters | Type | Default | Description | Example |
|---|---|---|---|---|
| taskId | String | - | Task ID | - |
| translatedTexts | String[] | - | Translated text | - |
| price | Integer | - | Total credits required for translation | - |
| usedCredits | Integer | - | Number of credits used by translation task | - |
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 translate the texts.
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 Missing required parameter: texts.
Provide a non-empty texts array.
400 Failed to translate texts.
The text translation task could not be processed.