Document Directory

Translation Task API

Translation text

POST/v1/translation/translateTexts

Translate text and return translation results synchronously.

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

Precautions

This API temporarily saves the input text as a JSON document and processes it synchronously, suitable for immediate translation of small batches of text.

Account credit balance must be at least 2 credits. If actual cost exceeds balance, the API will return taskId and price, and prompt insufficient balance.

Example

curl
1curl -X POST 'https://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

ParametersTypeDefaultDescriptionExample
*textsString[]-

Text to be translated

-
*fromLangString-
  • Source language; the source language cannot be the same as the target language
  • Supported languages: Query
-
*toLangString-
  • Target language; the target language cannot be the same as the source language
  • Supported languages: Query
-
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.

-

Response

ParametersTypeDefaultDescriptionExample
taskIdString-

Task ID

-
translatedTextsString[]-

Translated text

-
priceInteger-

Total Credits required for the complete translation

-
usedCreditsInteger-

Number of credits used by the 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.

Translation Task API
Restart translation task