> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt.
> For full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Translate a PDF to Hindi (or any Indic language)

> Step-by-step guide to translate a PDF with the Document Translation API — create a job, upload the file, poll progress, and download a layout-preserving translated PDF.

This guide walks through translating a **PDF** from English into Hindi using the [Document Translation API](/api/api-guides-tutorials/doc-translation/overview). The same flow works for Word, Excel, PowerPoint, and HTML — only the upload `Content-Type` changes.

Need to translate a **sentence or paragraph** instead of a file? Use the [Text Translation API](/api/api-guides-tutorials/text-processing/translation).

## Prerequisites

* A Sarvam API key from [Key Management](https://dashboard.sarvam.ai/key-management)
* Python 3.10+ with `pip install sarvamai httpx`
* A PDF file on disk (example: `report.pdf`)

**Billing:** ₹20 per 10,000 billable characters per target language (after parsing). See [Pricing](/api/getting-started/pricing#document-translation).

## Steps

#### Create the job

Call `document_translation.create` with source language, target language(s), and the original filename. You receive a `job_id` and a signed `upload_url`.

#### Upload the PDF

`PUT` the file bytes to `upload_url` with `Content-Type: application/pdf` and `x-ms-blob-type: BlockBlob`. The SDK does not upload for you yet.

#### Start translation

`POST` start (via `client.document_translation.start(job_id=...)`). The pipeline parses the PDF, runs OCR where needed, and translates each target language.

#### Poll until complete

Poll `get_live_status` every 10–15 seconds until each target language's `state` is `Completed`. See [Poll and export](/api/api-guides-tutorials/doc-translation/how-to/poll-and-export).

#### Export and download

For each target language, call `export`, poll `export/status`, then download from `download_url`. You get a translated PDF in the same layout as the source.

## Example (create, upload, start)

```python
import os
from pathlib import Path

import httpx
from sarvamai import SarvamAI
from sarvamai.core.api_error import ApiError

api_key = os.getenv("SARVAM_API_KEY")
if not api_key:
    raise ValueError("Set SARVAM_API_KEY before running this example.")

client = SarvamAI(api_subscription_key=api_key)
pdf = Path("report.pdf")

try:
    job = client.document_translation.create(
        source_language_code="en-IN",
        target_language_codes=["hi-IN"],
        original_filename=pdf.name,
    )

    with pdf.open("rb") as f:
        upload = httpx.put(
            job.upload_url,
            content=f.read(),
            headers={
                "Content-Type": "application/pdf",
                "x-ms-blob-type": "BlockBlob",
            },
            timeout=120.0,
        )
        upload.raise_for_status()

    client.document_translation.start(job_id=job.job_id)
    print("Job started:", job.job_id)
except ApiError as e:
    print(f"API error {e.status_code}: {e.body}")
except httpx.HTTPError as e:
    print(f"Upload failed: {e}")
```

Continue with the polling and export loop in [Poll and export](/api/api-guides-tutorials/doc-translation/how-to/poll-and-export).

## Related guides

* [Poll and export](/api/api-guides-tutorials/doc-translation/how-to/poll-and-export) — Word, PowerPoint, and multi-language export
* [Document Translation overview](/api/api-guides-tutorials/doc-translation/overview)
* [Pricing](/api/getting-started/pricing) · [Rate limits](/api/getting-started/ratelimits)