DeepLXTranslationResult object.
Response Structure
The response object contains the following fields:HTTP status code indicating the result of the translation request. Returns
200 for successful translations.Unique identifier for the translation request. This ID is randomly generated for each request and can be used for tracking purposes.
The primary translated text. This is the main translation result returned by DeepL.
An array of alternative translations. DeepL may provide up to 3 alternative translations for the same input text, offering different phrasings or word choices.
The detected or specified source language code in ISO 639-1 format (e.g., “EN”, “DE”, “FR”). If the request specified
auto or an empty source language, this field contains the automatically detected language.The target language code in ISO 639-1 format (e.g., “EN”, “DE”, “FR”). This matches the language specified in the translation request.
Indicates the translation method used. Possible values:
"Free"- Translation performed using the free DeepL API method"Pro"- Translation performed using a DeepL Pro account withdl_sessioncookie
Error or status message. This field is only present when an error occurs or when additional information needs to be conveyed. It is omitted in successful responses.
Success Response Example
Alternatives Array
Thealternatives array provides additional translation options:
DeepLX requests up to 3 alternatives from the DeepL API by setting
requestAlternatives: 3 in the translation request. The actual number of alternatives returned may vary depending on the input text and language pair.How alternatives are populated
How alternatives are populated
The alternatives are extracted from the DeepL API response structure:
- The API response contains a
textsarray with translation results - Each text object has an
alternativesarray field - DeepLX extracts the
textfield from each alternative object - Only non-empty alternative texts are included in the final response
[].Language Detection
When automatic language detection is used (by specifying
"auto" or an empty string for source_lang in the request), DeepLX uses the whatlanggo library to detect the input language.The detected language is then:- Used in the translation request to DeepL
- May be overridden by DeepL’s own language detection
- Returned in the response’s
source_langfield
Method Field
Themethod field indicates which translation endpoint was used:
| Method | Description | Endpoint |
|---|---|---|
Free | Uses the free DeepL translation service without authentication | /translate, /v2/translate |
Pro | Uses DeepL Pro account with dl_session cookie for enhanced features | /v1/translate |
The method is determined by checking if a
dl_session value was provided in the request. From translate/translate.go:201: