Document Translationのロゴ

Document Translation

組織
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.

概要

公開者sarvamai
リポジトリskills
スキル名document-translation
スター
72
フォーク
24
同梱ファイル
1
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    sarvamaiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Document Translation」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/sarvamai/skills/tree/main/translate/document
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでDocument Translationを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にDocument Translationを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Document Translationは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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:

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「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.

TypingMindでDocument Translationを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Document Translationはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにDocument Translationをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/sarvamai/skills/tree/main/translate/documentを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Document Translationを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Document Translationで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもDocument Translationを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Document Translation」は無料ですか?

はい。sarvamaiがApache-2.0ライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇