mcpField
T
translate

translate

github.com/sarvamaiDevelopment72136 installsUpdated 2w ago
Repository

About translate

A skill for using the Sarvam AI SDK to translate text in Python or JavaScript/TypeScript. It documents model capabilities, language and character limits, and API usage details that distinguish the two translation models.

Key features

  1. 01Python and JavaScript/TypeScript SDK examples
  2. 02Two translation model options
  3. 03Model-specific translation controls
  4. 04Language detection with mayura:v1
  5. 05API authentication and endpoint guidance
  6. 06Character-limit guidance

Use cases

  1. 01Translate text through the Sarvam AI SDK
  2. 02Choose a model for language and script options
  3. 03Handle long text within model limits

MCP support

The skill covers SDK-based translation, not MCP integration. The README points to sarvam-mcp for in-chat translation and localization.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/sarvamai/skills --skill translate

After installing, type/translatein Claude Code to confirm it loaded.

Details

From the project README

Translation — Sarvam AI

Live in-chat translate/localize → sarvam-mcp (sarvam_tools_translate / _localize). This skill = SDK code.

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)

Models

ModelMax InputLanguagesFeatures
sarvam-translate:v12,000 chars23 (22 Indian + English)mode (formal only), speaker_gender, numerals_format
mayura:v11,000 chars11 (10 Indian + English)All mode values, output_script, speaker_gender, numerals_format, auto source detection

Quick Start (Python)

from sarvamai import SarvamAI
client = SarvamAI()

response = client.text.translate(
    input="Hello, how are you?",
    source_language_code="en-IN",
    target_language_code="hi-IN",
    model="sarvam-translate:v1"
)
print(response.translated_text)

Quick Start (JavaScript/TypeScript)

import { SarvamAIClient } from "sarvamai";

const client = new SarvamAIClient({ apiSubscriptionKey: "YOUR_SARVAM_API_KEY" });

const response = await client.text.translate({
    input: "Hello, how are you?",
    source_language_code: "en-IN",
    target_language_code: "hi-IN",
    model: "sarvam-translate:v1"
});
console.log(response.translated_text);

Gotchas

GotchaDetail
Method nameBoth Python & JS: client.text.translate({...}) — NOT client.translate.translate(). Same text namespace in both SDKs.
output_script on sarvam-translateNOT supported — only works with mayura:v1 (roman, fully-native, spoken-form-in-native). Silently ignored on sarvam-translate:v1.
mode valuessarvam-translate:v1 supports formal only. Colloquial modes (modern-colloquial, classic-colloquial, code-mixed) are mayura:v1 only. speaker_gender works on BOTH models.
Auto language detectionsource_language_code="auto" only works with mayura:v1. sarvam-translate:v1 requires an explicit source language.
Odia language codeod-IN — NOT or-IN.
Character limitsExceeding returns 422. Split long text at sentence boundaries.

Full Docs

Fetch language codes, mode examples, script options, and numeral formats from:

Comments

Markdown supported