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":"abcd264f0-07b8-113s-aef7-3856358aadca",
   "code":200,
   "project_id":54321,
   "user_id":123456,
   "created_on":"2023-06-15T20:11:26.436Z",
   "status":[
      {
         "status":{
            "code":"0",
            "message":"SUCCESS"
         },
         "response":{
            "input":{
               "id":"abcd264f0-07b8-113s-aef7-3856358aadca",
               "created_on":"2023-06-15T20:11:25.007Z",
               "user_id":123456,
               "project_id":654321,
               "charge":1.234,
               "model":"pytorch_translation_600m_2022_11_release",
               "model_version":1,
               "model_type":"TEXT_TRANSLATION",
               "inference_client_version":"version",
               "args":{
                  "output_language":"ES",
                  "input_language":"EN"
               },
               "text":"To be or not to be, that is the question."
            },
            "output":[
               {
                  "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 FieldDescription
input_languageThe two character ID for the input/source text language; submitted with the translation request
output_languageThe two character ID for the language of the translated output text; submitted with the translation request
text (input)Raw text content to be translated
text (output)The text obtained by translating the input text into the output language

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