Document Translation logo

Document Translation

Organization
sarvamai
document-translation

Write correct Sarvam Document Translation code — async create → upload → start → poll → export pipeline for PDF, Word, Excel, PowerPoint, and HTML files. Use this skill when building document-to-document translation features in Python or JS/TS. For short pasted text, use text-translation instead. For live document translation in chat via MCP, use sarvam-mcp instead.

Overview

Publishersarvamai
Repositoryskills
Skill namedocument-translation
Stars
72
Forks
24
Bundled files
1
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by sarvamai on GitHub. Read the source before you install it.

Installation

Install the Document Translation AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/sarvamai/skills/tree/main/translate/document
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/sarvamai/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/translate/document .claude/skills/document-translation
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Document Translation in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Document Translation on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Document Translation is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Document Translation — Sarvam AI

Live in-chat document translation → sarvam-mcp. This skill = SDK code.

Translating short text (a sentence or paragraph)? → text-translation — client.text.translate(), not this API.

[!IMPORTANT] Auth: api-subscription-key header — NOT Authorization: Bearer. Base URL: https://api.sarvam.ai (NOT /v1 — that prefix is only for the OpenAI-compatible chat endpoint)

What this API does

Translates a whole document (PDF, Word, Excel, PowerPoint, HTML) into up to 12 Indian languages per job, preserving layout and formatting. The output is a translated file in the original format — not plain text.

This is an asynchronous API. There is no single-call "translate this file" method. Every integration follows five steps: create → upload → start → poll → export.

Supported file formats

CategoryExtensions
PDF.pdf
Word.doc, .docx, .odt
Spreadsheets.xls, .xlsx, .ods
Presentations.ppt, .pptx, .odp
Web pages.html, .xhtml, .mhtml

Quick Start (Python)

python
import os
from pathlib import Path

import httpx
from sarvamai import SarvamAI

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

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

# 2. Upload to the signed URL (SDK does NOT do this — use httpx/requests)
with document.open("rb") as f:
    httpx.put(
        job.upload_url,
        content=f.read(),
        headers={
            "Content-Type": "application/pdf",
            "x-ms-blob-type": "BlockBlob",
        },
        timeout=120.0,
    )

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

# 4. Poll live-status (every 10-15s) — see references/api-flow.md for full loop
# 5. Export each completed language — see references/api-flow.md
print(job.job_id)

Quick Start (JavaScript/TypeScript)

typescript
import fs from "fs";
import { SarvamAIClient } from "sarvamai";

const client = new SarvamAIClient({
    apiSubscriptionKey: process.env.SARVAM_API_KEY!,
});
const documentPath = "report.pdf";

// 1. Create job
const job = await client.documentTranslation.create({
    source_language_code: "en-IN",
    target_language_codes: ["hi-IN", "ta-IN"],
    original_filename: documentPath,
});

// 2. Upload to the signed URL (SDK does NOT do this — use fetch)
await fetch(job.upload_url, {
    method: "PUT",
    headers: {
        "Content-Type": "application/pdf",
        "x-ms-blob-type": "BlockBlob",
    },
    body: fs.readFileSync(documentPath),
});

// 3. Start the pipeline
await client.documentTranslation.start(job.job_id);

// 4. Poll live-status (every 10-15s) — see references/api-flow.md for full loop
// 5. Export each completed language — see references/api-flow.md
console.log(job.job_id);

SDK method reference

StepPythonJavaScript/TypeScript
Create jobclient.document_translation.create(...)client.documentTranslation.create({...})
Startclient.document_translation.start(job_id=...)client.documentTranslation.start(jobId)
Poll statusclient.document_translation.get_live_status(job_id=...)client.documentTranslation.getLiveStatus(jobId)
Trigger exportclient.document_translation.trigger_export(job_id=..., lang=...)client.documentTranslation.triggerExport(jobId, { lang })
Poll exportclient.document_translation.get_export_status(job_id=..., export_id=...)client.documentTranslation.getExportStatus(jobId, { exportId })

Gotchas

GotchaDetail
Upload is manualThe SDK create() returns upload_url but does not PUT the file. You must upload separately with httpx/fetch/curl, including x-ms-blob-type: BlockBlob and a correct Content-Type header. Forgetting this leaves the job stuck — start will fail validation.
Export is per-languagetrigger_export handles one target language per call. Loop over target_language_codes and call export once for each. There is no "export all" method.
Export before Completed → 409Calling trigger_export for a language whose state is not yet Completed returns 409 Conflict. Gate on translations[].state, not job_state — languages finish independently.
job_state vs per-language stateA job at PartiallyCompleted can still have individual languages ready to export. Always check each language's own state in translations[] before exporting.
Terminal job statesCompleted, PartiallyCompleted, Failed — stop polling when job_state reaches one of these. But still check per-language state for the export decision.
Odia language codeor-IN in document translation — NOT od-IN (which is the text translation code). The two APIs use different codes for Odia.
original_filename must matchThe filename in create() must match the file you upload, including extension. Mismatch causes validation failure at start.
Office formats export in original format onlyPDF uploads can optionally export as pdf, docx, html, txt, or epub. Word/Excel/PowerPoint uploads always export in the original format — format is ignored.
Signed URLs expireBoth upload_url and download_url expire in 24 hours (expires_in_hours). If a download link expires, call export/status again for a fresh one.
Poll intervalEvery 10-15 seconds against live-status. Faster polling wastes credits; slower delays exports.
Method namespacePython: client.document_translation.* (snake_case). JS: client.documentTranslation.* (camelCase). NOT client.translate.* or client.text.* — those are the text translation API.
Credits per languageBilled at ₹5 per 1,000 billable characters per target language, counted after parsing (not raw file size). Each language in target_language_codes is billed separately.

Full Docs

Fetch supported formats, genre options, style guidelines, and language codes from:

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Document Translation AI skill do?

Write correct Sarvam Document Translation code — async create → upload → start → poll → export pipeline for PDF, Word, Excel, PowerPoint, and HTML files. Use this skill when building document-to-document translation features in Python or JS/TS. For short pasted text, use text-translation instead. For live document translation in chat via MCP, use sarvam-mcp instead.

Why use Document Translation on TypingMind?

Because you install it once and use it with any model. Document Translation is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Document Translation in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/sarvamai/skills/tree/main/translate/document. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Document Translation?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Document Translation?

As many as you like. As long as a model supports skills, you can use Document Translation with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Document Translation AI skill free?

Yes. It is published on GitHub by sarvamai under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇