The Translation API uses our model to translate text between commonly spoken languages and returns these translations directly in the API response. Our multi-lingual model can translate between any pair of supported languages while preserving meaning and fluency.

The Translation API returns a full JSON response including the input text, translated text, and IDs for the source and target languages specified in the API request. Here's what the response object looks like for an example English-to-Spanish request:

{
    "id": "0f9e6470-db09-11ec-bfd5-495b0e5deda0",
    "code": 200,
    "project_id": 37870,
    "user_id": 3122060,
    "created_on": "2022-05-24T02:27:36.672Z",
    "status": [
        {
            "status": {
                "code": "0",
                "message": "SUCCESS"
            },
            "_version": 2,
            "response": {
                "source_language": "en",
                "source_text": "To be or not to be, that is the question.",
                "target_language": "es",
                "translated_text": "Ser o no ser, esa es la pregunta."
            }
        }
    ],
    "from_cache": false,
    "hsl_options": {
        "input_language": "EN",
        "output_language": "ES"
    }
}

For translation tasks, the most relevant response fields are:

Response Field

Description

source_language

The two character ID for the input/source text language; submitted with the translation request

target_language

The two character ID for the language of the translated output text; submitted with the translation request

source_text

The input string provided in the translation request

translated_text

Translation of the source text into the specified target language

For more details on language support and IDs for supported languages, please see our main Translation guide.