Optical Character Recognition Call
Optical Character Recognition (OCR) extracts and digitizes text present in images across Indian languages, supporting printed documents, scenic text, and handwriting.
POST https://dhruva-api.bhashini.gov.in/services/inference/pipelineUnderstand base64 image encoding, language configuration, and serviceId parameters.
Inspect extracted text, line/word bounding boxes, and recognition confidence.
Supported OCR Modalities
Depending on the visual characteristics of the input image, Bhashini OCR models cater to three distinct modalities:
Optimized for reports, books, scanned records, and structured printed typography on plain backgrounds.
Printed OCR SampleInterprets text in natural/artificial scenes, billboards, advertisements, and product packaging.
Scenic OCR SampleRecognizes cursive, uneven spacing, handwritten forms, and historical documents in Indic scripts.
Handwritten OCR Sample1-Minute Quick Call
Extract text from an image by providing a base64-encoded image string:
const url = "https://dhruva-api.bhashini.gov.in/services/inference/pipeline";
const headers = {
"Content-Type": "application/json",
"Accept": "*/*",
"Authorization": "<YOUR_INFERENCE_API_KEY>"
};
const payload = {
pipelineTasks: [
{
taskType: "ocr",
config: {
language: {
sourceLanguage: "hi"
},
serviceId: "bhashini/iitmandi/ocr",
modelId: "ocr_printed_hi"
}
}
],
inputData: {
image: [
{
imageContent: "<BASE64_ENCODED_IMAGE_STRING>"
}
]
}
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
const data = await response.json();
console.log(data);Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
Content-Type | string | Required | Must be set to application/json. |
Accept | string | Required | Expected response content type (*/*). |
Authorization | string | Required | Raw inference API key from your Bhashini profile. |