Text to Text Translation
Use this endpoint to translate text between supported Indic languages.
Caution
Keep your inference API key secret — never commit one to a repository. The interactive Try it may be blocked by CORS in some environments; if that happens, copy the request below and run it locally.
Text-to-Text • Translation
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
| Field | Type | Required | Description |
|---|---|---|---|
pipelineTasks[].taskType | string | Yes | Must be "translation". |
config.language.sourceLanguage | string | Yes | ISO 639-1 code of input text (e.g. "hi", "en"). |
config.language.targetLanguage | string | Yes | ISO 639-1 code of translated output (e.g. "gu", "ta"). |
config.serviceId | string | Yes | Model service ID (e.g. ai4bharat/indictrans-v2-all-gpu--t4). |
inputData.input[].source | string | Yes | The text content to be translated. |
Response Structure
{
"pipelineResponse": [
{
"taskType": "translation",
"output": [
{ "target": "<translated text>" }
]
}
]
}