Document Translation API Overview
The Document Translation API takes a source document and returns it translated into one or more Indian languages, in its original file format. The layout, formatting, and structure of the source file are preserved.
Authentication: send your API key in the api-subscription-key header. Generate a key from Key Management in the dashboard.
What you get from one job
A single job translates into up to 12 target languages (out of 23 total supported) from one uploaded document. You upload once, and each target language is translated independently and exported separately.
How it works
Document translation is asynchronous by design: you create a job, upload the file, start the pipeline, poll it, and then export each language’s result, rather than getting a translated file back from a single request. Every integration follows the same five steps:
Create the job
POST /translate/document/jobs with your source/target languages and the original filename. Returns a job_id and a short-lived signed upload_url, with status 201 Created.
Upload the document
PUT the file bytes to upload_url. This step is required; the create call only accepts metadata, not the file itself.
Start the pipeline
POST /translate/document/jobs/{job_id}/start, no request body. Runs file validation, then parsing (OCR for PDFs, structural extraction for Office and web formats), then translation, one independent branch per target language. Idempotent: calling start again on the same job returns the current job state instead of erroring.
Export is per language, not one call for the whole job. Loop over your target_language_codes and call export once for each, only after that language’s own state in live-status is Completed. Calling export before that returns 409 Conflict.
Quickstart
Install the SDK (pip install sarvamai or npm install sarvamai), set SARVAM_API_KEY, and point document at a local PDF or Office file. The client uses https://api.sarvam.ai by default, so your API key is the only configuration it needs.
Document translation does not include an SDK upload helper yet. After create, PUT the file bytes to upload_url with Content-Type and x-ms-blob-type: BlockBlob, then call start. See Poll and Export for the polling and download loop.
That job is now running. See Poll and Export for the polling loop and per-language download flow.
Page-granular vs document-granular responses
The response format depends on the uploaded file type:
- PDFs are tracked per page.
- Word, spreadsheets, and presentations are tracked per text segment (roughly a paragraph).
Both response formats share the same base fields. Only the progress-related fields differ.
Response shapes at a glance
Shared fields (both response types)
job_id job_state job_name source_language_code progress translations[] created_at updated_at
Job states
Terminal states are Completed, PartiallyCompleted, and Failed.
Each language in translations[] has its own state (Pending, Running, Completed, Failed), independent of the others. A language is exportable as soon as its own entry reads Completed, even while other languages in the same job are still Running. Treat PartiallyCompleted as a terminal state alongside Completed, and check each language’s own state before deciding what to export.
Request parameters
Required:
Optional:
Supported file formats
Supported languages
23 languages: English plus 22 Indic languages.
Response examples
POST /translate/document/jobs returns 201 Created:
GET /translate/document/jobs/{job_id}/live-status returns:
GET /translate/document/jobs/{job_id}/export/status returns, once the export is Completed:
Errors
Best Practices
Poll live-status every 10-15 seconds from a background worker, not an HTTP request handler. Cap total wait time and handle timeouts gracefully.
Export is per language, not one call for the whole job. Loop over your target_language_codes and call export once for each, only after that language’s own state is Completed.
Don’t gate the export loop on job_state alone. A job at PartiallyCompleted can still have individual languages ready to export. Check each language’s own state in translations[].
Use genre to tune the translation prompt for your content type. LEGAL for contracts, CHILDREN_FICTION for children’s books, ACADEMIC for research papers.
Limits
Next Steps
Complete code examples for polling and exporting in Python, JavaScript, and curl.
How to use genre and model_type for different content types.
Endpoint-level schemas for every request and response field.
Need help scoping a document translation integration? Reach out on Discord.