Translation Pipeline

Use the Dhruva Pipeline API to translate text from Hindi to Gujarati. Below is a ready-to-run curl example, followed by an interactive Try it panel.

Code examples

const url = 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline';


const res = await fetch(url, {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_INFERENCE_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    pipelineTasks: [{
      taskType: 'translation',
      config: {
        language: { sourceLanguage: 'hi', targetLanguage: 'gu' },
        serviceId: 'ai4bharat/indictrans-v2-all-gpu--t4'
      }
    }],
    inputData: { input: [{ source: 'मेरा नाम विहिर है और मैं भाषाावर्ष यूज कर रहा हूँ' }] }
  })
});


const data = await res.json();
console.log(data);

Try it (browser)

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.

Troubleshooting

  • CORS: If you see a CORS or network error in the browser, run the curl command or use Thunder Client/Postman instead.
  • Auth: Ensure the inference API key is current and has permission for the selected service.
  • Service: Check serviceId is valid for the chosen language pair.