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.
Caution
Do not publish your real API token in docs. Use a temporary token during testing. The interactive Try it may be blocked by CORS in some environments; if that happens, use curl or a REST client.
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
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
serviceIdis valid for the chosen language pair.