Text-to-Text quickstart
Overview
Learn how to translate text between Indic languages using the BHASHINI Inference API.
Getting started
- Get an inference API key – Create one in the dashboard
- Choose a translation service ID – e.g.,
ai4bharat/indictrans-v2-all-gpu--t4 - Send a request – Use the pipeline endpoint with your service ID and language pair
- Parse the response – Extract translated text from the JSON response
Key concepts
- Source language: Language of the input text (e.g.,
hifor Hindi) - Target language: Desired output language (e.g.,
gufor Gujarati) - Service ID: Identifier for the translation model pipeline
- Pipeline tasks: Array of tasks to execute (here:
translation)
Interactive playground
Try Translation
hi → gu by default; update service ID and languages
Request
Select model
हिन्दी | Hindi
ગુજરાતી | Gujarati
Add an inference API key to run.
curl
Response
Send a request to see the live response here.
Code examples
const url = 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline';
const headers = {
'Accept': '*/*',
'Authorization': '<YOUR_INFERENCE_API_KEY>',
'Content-Type': 'application/json'
};
const payload = {
pipelineTasks: [
{
taskType: 'translation',
config: {
language: {
sourceLanguage: 'hi',
targetLanguage: 'gu'
},
serviceId: 'ai4bharat/indictrans-v2-all-gpu--t4'
}
}
],
inputData: {
input: [
{ source: 'नमस्ते दुनिया' }
]
}
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));