translate
Translation — Sarvam AI
[!IMPORTANT] Auth:
api-subscription-keyheader — NOTAuthorization: Bearer. Base URL:https://api.sarvam.ai/v1
Models
| Model | Max Input | Languages | Features |
|---|---|---|---|
sarvam-translate:v1 |
2,000 chars | 22 languages | Formal style, numerals_format |
mayura:v1 |
1,000 chars | 11 languages | mode, output_script, speaker_gender |
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
| Gotcha | Detail |
|---|---|
| Method name | Both Python & JS: client.text.translate({...}) — NOT client.translate.translate(). Same text namespace in both SDKs. |
output_script on sarvam-translate |
NOT supported — only works with mayura:v1. Silently ignored on sarvam-translate:v1. |
mode/speaker_gender |
Only work with mayura:v1. sarvam-translate:v1 only supports formal style + numerals_format. |
| Odia language code | od-IN — NOT or-IN. |
| Character limits | Exceeding returns 422. Split long text at sentence boundaries. |
Full Docs
Fetch language codes, mode examples, script options, and numeral formats from:
- https://docs.sarvam.ai/llms.txt — comprehensive docs index
- Translation Guide
- Rate Limits
More from sarvamai/skills
speech-to-text
Transcribe audio to text using Sarvam AI's Saaras model. Handles speech recognition, transcription, and voice interfaces for 23 Indian languages. Supports 5 output modes, auto language detection, WebSocket streaming, and batch diarization. Use when converting speech to text or building voice-enabled apps.
168text-to-speech
Convert text to natural speech using Sarvam AI's Bulbul v3 model. Handles audio generation, voiceovers, and voice interfaces for 11 Indian languages with 30+ voices. Supports REST, HTTP streaming, WebSocket, and pronunciation dictionaries. Use when generating spoken audio from text.
55chat
Chat completions using Sarvam AI LLMs (Sarvam-105B, Sarvam-30B). Handles AI chat, text generation, reasoning, coding, and multilingual conversations in Indian languages. OpenAI-compatible API. Use when building chatbots, Q&A systems, agents, or any LLM feature targeting Indian users.
44voice-agents
Build conversational voice agents using Sarvam AI with LiveKit or Pipecat. Handles voice assistants, phone bots, IVR, and real-time conversational AI for Indian languages. Integrates Sarvam STT (Saaras v3), TTS (Bulbul v3), and LLM (Sarvam-30B) with low-latency streaming. Use when creating voice-enabled applications or real-time speech pipelines.
42