Sarvam AI

Document Translation API

Translate the whole file, not just the words inside it

A document translation API for 22 Indian languages and English. Upload a PDF, Word, Excel, PowerPoint or web file and get it back in up to 12 languages, in the same format, layout intact.

Translated PDFs and documents with the layout intact

Real documents, translated with their layout intact. Pick a language to compare it with the original, or click an image to zoom.

A textbook page, translated with its layout intact

An NCERT textbook page with speech bubbles, illustrations and a side margin. Each language keeps the same page structure.

Original (English)
Translated

Translate PDF, DOCX, XLSX and PPTX files and keep the format

A PDF exports as a PDF and a DOCX exports as a DOCX. Parsing runs OCR on PDFs, structural extraction on Office and web files and chunking on Markdown and plain text.

  • PDF

    .pdf

    Parsed with OCR, tracked per page.

  • Word

    .doc, .docx, .odt

    Structural extraction, tracked per text segment.

  • Spreadsheets

    .xls, .xlsx, .ods

    Structural extraction, tracked per text segment.

  • Presentations

    .ppt, .pptx, .odp

    Structural extraction, tracked per text segment.

  • Web pages

    .html, .xhtml, .mhtml

    Structural extraction, with the layout preserved.

  • Markdown and plain text

    .md, .markdown, .txt

    UTF-8 only, 2 MB per upload, up to 500 chunks per job.

Document translation API: five calls from upload to export

Document translation is asynchronous by design. You create the job, upload the bytes, start the pipeline, poll it, then export each language.

01

Create the job

Send the source language, up to 12 target languages and the original filename. The response carries a job_id and a signed upload_url that stays valid for 24 hours.

POST/translate/document/jobs
import os, time
from pathlib import Path

import httpx
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key=os.environ["SARVAM_API_KEY"])
document = Path("handbook.pdf")

# 1. Create the job
job = client.document_translation.create(
    job_name="handbook",
    source_language_code="en-IN",
    target_language_codes=["hi-IN", "ta-IN"],
    original_filename=document.name,
    genre="NON_FICTION",
)

# 2. Upload the bytes to the signed URL
httpx.put(
    job.upload_url,
    content=document.read_bytes(),
    headers={
        "Content-Type": "application/pdf",
        "x-ms-blob-type": "BlockBlob",
    },
    timeout=120.0,
).raise_for_status()

# 3. Start the pipeline
client.document_translation.start(job_id=job.job_id)

# 4. Poll until the job reaches a terminal state
TERMINAL = {"Completed", "PartiallyCompleted", "Failed"}
while True:
    status = client.document_translation.get_live_status(job_id=job.job_id)
    if status.job_state in TERMINAL:
        break
    time.sleep(12)

# 5. Export every language that finished, then poll export/status until
#    export_state is Completed and download from download_url
for translation in status.translations:
    if translation.state == "Completed":
        client.document_translation.export(
            job_id=job.job_id,
            lang=translation.target_language_code,
        )

Create takes metadata only, so the upload is its own PUT to a signed URL. After start, each target language translates on its own branch and becomes exportable the moment its own state reads Completed, even while the others are still running.

  • AcceptedCreated and queued
  • RunningParsing or translating
  • CompletedEvery language succeeded
  • PartiallyCompletedSome languages succeeded. Terminal and still exportable
  • FailedAll languages failed, or a job-level error

Set the translation genre with one parameter

genre tunes the translation prompt. Pick the one that fits the document, such as LEGAL for contracts, CHILDREN_FICTION for children’s books or ACADEMIC for research papers.

Six content types. Select one to see what it does to the request.

Document translation across 22
Indian languages and English

List up to 12 targets on a single job. One translated document comes back per language.

हिन्दीHindi · hi-IN
বাংলাBengali · bn-IN
தமிழ்Tamil · ta-IN
తెలుగుTelugu · te-IN
मराठीMarathi · mr-IN
ગુજરાતીGujarati · gu-IN
ಕನ್ನಡKannada · kn-IN
മലയാളംMalayalam · ml-IN
ਪੰਜਾਬੀPunjabi · pa-IN
ଓଡ଼ିଆOdia · or-IN
অসমীয়াAssamese · as-IN
اردوUrdu · ur-IN
हिन्दीHindi · hi-IN
বাংলাBengali · bn-IN
தமிழ்Tamil · ta-IN
తెలుగుTelugu · te-IN
मराठीMarathi · mr-IN
ગુજરાતીGujarati · gu-IN
ಕನ್ನಡKannada · kn-IN
മലയാളംMalayalam · ml-IN
ਪੰਜਾਬੀPunjabi · pa-IN
ଓଡ଼ିଆOdia · or-IN
অসমীয়াAssamese · as-IN
اردوUrdu · ur-IN
संस्कृतम्Sanskrit · sa-IN
नेपालीNepali · ne-IN
मैथिलीMaithili · mai-IN
कोंकणीKonkani · kok-IN
डोगरीDogri · doi-IN
बड़ोBodo · brx-IN
سنڌيSindhi · sd-IN
کٲشُرKashmiri · ks-IN
মৈতৈলোন্Manipuri · mni-IN
ᱥᱟᱱᱛᱟᱲᱤSantali · sat-IN
EnglishEnglish · en-IN
संस्कृतम्Sanskrit · sa-IN
नेपालीNepali · ne-IN
मैथिलीMaithili · mai-IN
कोंकणीKonkani · kok-IN
डोगरीDogri · doi-IN
बड़ोBodo · brx-IN
سنڌيSindhi · sd-IN
کٲشُرKashmiri · ks-IN
মৈতৈলোন্Manipuri · mni-IN
ᱥᱟᱱᱛᱟᱲᱤSantali · sat-IN
EnglishEnglish · en-IN

Document translation API pricing: ₹5 per 1,000 characters

Billing follows the parsed document rather than the file size and each target language is charged once.

1,00,000
3
Estimated cost₹1,5001,00,000 characters × 3 languages₹5 per 1,000 billable characters, per target language
  • Characters are counted after parsing, not from the raw file size.
  • Charges round up, with a minimum of ₹1 when the document has billable text.
  • Each target language is billed at the same rate.
target languages per job
1 to 12
per Markdown or text file
2 MB
Markdown and text chunks per job
500
validity of upload and download links
24 hours
  • SCORM 1.2
  • SCORM 2004

Translating an e-learning course?

Open its SCORM package in our viewer first. See the outline and what is inside, then bring the course content in for translation.

Open the SCORM viewer

Document translation API FAQ

Which file formats can I translate?

PDF, Word (.doc, .docx, .odt), spreadsheets (.xls, .xlsx, .ods), presentations (.ppt, .pptx, .odp), web pages (.html, .xhtml, .mhtml) and Markdown or plain text (.md, .markdown, .txt). Each language exports in the uploaded file format by default, so a PDF comes back as a PDF.

Which languages does document translation support?

Twenty-three languages: English plus Assamese, Bengali, Bodo, Dogri, Gujarati, Hindi, Kannada, Kashmiri, Konkani, Maithili, Malayalam, Manipuri, Marathi, Nepali, Odia, Punjabi, Sanskrit, Santali, Sindhi, Tamil, Telugu and Urdu. A single job can list between one and 12 target languages.

Is the original layout preserved?

Yes. Each translated file comes back in the original file format with the layout preserved. The pipeline parses first, with OCR for PDFs and structural extraction for Office and web files, then translates each target language on its own branch.

Why is the API asynchronous instead of a single call?

A document job runs parsing and one translation branch per target language, which takes longer than an HTTP request should wait. You create the job, upload the file, start it, poll live-status every 10 to 15 seconds from a background worker, then export each language when its own state reads Completed.

What happens if one language fails?

The job reaches PartiallyCompleted, which is a terminal state. Every language carries its own state, so the languages that finished are still exportable. Check each entry in translations rather than gating your export loop on the job state alone.

Can I control terminology and tone?

Set genre to one of NON_FICTION, ADULT_FICTION, CHILDREN_FICTION, RELIGIOUS, LEGAL or ACADEMIC to tune the translation prompt. For house style, pass up to around 4,000 characters of style_guidelines, with language_specific_guidelines for per-language overrides.

How is document translation billed?

At ₹5 per 1,000 billable characters per target language. Characters are counted after the document is parsed rather than from the file size, charges round up and the minimum is ₹1 when a document contains billable text.

How is this different from Parse?

Parse returns the content of a document as HTML or Markdown in its original language, for when you need the text as data. Document Translation returns a translated file in the source format, for when someone has to read, print or sign it.

When should I use the Text Translation API instead?

Use Text Translation for a sentence, paragraph or chat message. It answers in one synchronous call with no upload and no polling. Use Document Translation when the deliverable is a file.

What errors can the API return?

A 400 means an invalid request, language code, genre, filename or export format. A 401 means a missing or invalid api-subscription-key and a 402 means insufficient credits. A 404 means no job or export was found. A 409 means an export is already in progress for that language and format, or the translation is not yet Completed. A 503 means the export could not be queued, so retry it.

How long do the upload and download links last?

The signed upload URL from the create call is valid for 24 hours and so is the signed download URL from export/status. Call export/status again to get a fresh download link.

Is there a no-code way to translate documents?

Yes. Doc Agents has a Translate workspace where you upload a document, pick the languages and genre and review each translation in a side-by-side editor with Bulk Translate, AI Assistance and Learned Rules before exporting.

How do I translate a PDF to Hindi with an API?

Create a job with source_language_code en-IN, target_language_codes ["hi-IN"] and the original filename, upload the PDF to the signed URL, start the job and poll its status. The PDF is read with OCR and translated. You export a translated PDF once the language reports Completed.

Can I translate one document into several Indian languages at once?

Yes. List up to 12 target languages on a single job. Each language translates on its own branch and exports as its own file.

How do I authenticate?

Send your key in the api-subscription-key header, not as a bearer token. Generate a key from Key Management in the dashboard.

The handbook you wrote once can onboard in 22 languages. Get an API key and translate your first document into a dozen Indian languages from one upload.