Text to Text Translation

Use this endpoint to translate text between supported Indic languages.

Text-to-Text • Translation

Inference API key
Service ID *
Source language
25 of 37 languages — limited by the selected model. Clear Service ID to see all.
Target language
24 of 38 languages — limited by the selected model. Clear Service ID to see all.
Text to translate
curl --location 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline' \
--header 'Accept: */*' \
--header 'User-Agent: BHASHINI Docs TryIt' \
--header 'Authorization: YOUR_INFERENCE_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"pipelineTasks": [
{
"taskType": "translation",
"config": {
"language": {
"sourceLanguage": "hi",
"targetLanguage": "gu"
},
"serviceId": "ai4bharat/indictrans-v2-all-gpu--t4"
}
}
],
"inputData": {
"input": [
{
"source": "मेरा नाम विहिर है और मैं भाषाावर्ष यूज कर रहा हूँ"
}
]
}
}'
Response
Send a request to see the live response here.

Example Requests

const res = await fetch('https://dhruva-api.bhashini.gov.in/services/inference/pipeline', {
method: 'POST',
headers: {
'Accept': '*/*',
'Content-Type': 'application/json',
'Authorization': process.env.BHASHINI_INFERENCE_API_KEY, // store securely
},
body: JSON.stringify({
pipelineTasks: [{
taskType: 'translation',
config: {
language: { sourceLanguage: 'hi', targetLanguage: 'gu' },
serviceId: 'ai4bharat/indictrans-v2-all-gpu--t4',
},
}],
inputData: { input: [{ source: 'मेरा नाम विहिर है और मैं भाषाावर्ष यूज कर रहा हूँ' }] },
}),
});
const json = await res.json();
console.log(json);

Schema Specifications

FieldTypeRequiredDescription
pipelineTasks[].taskTypestringYesMust be "translation".
config.language.sourceLanguagestringYesISO 639-1 code of input text (e.g. "hi", "en").
config.language.targetLanguagestringYesISO 639-1 code of translated output (e.g. "gu", "ta").
config.serviceIdstringYesModel service ID (e.g. ai4bharat/indictrans-v2-all-gpu--t4).
inputData.input[].sourcestringYesThe text content to be translated.

Response Structure

{
  "pipelineResponse": [
    {
      "taskType": "translation",
      "output": [
        { "target": "<translated text>" }
      ]
    }
  ]
}