Registry / llm-agents / sarvamai

sarvamai

JSON →
library0.1.28pypypi✓ verified 84d ago

Official Python SDK for Sarvam AI APIs, providing access to text-to-speech, speech-to-text, translation, and text generation models. Current version 0.1.28. Actively maintained with monthly releases.

pip install sarvamai
INSTALL
IMPORT
SIG · SARVAMAI
S
sarvamai
llm-agentspythonv0.1.28
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SarvamAI
from sarvamai import SarvamAI

Initialize client with API key and call TTS endpoint.

from sarvamai import SarvamAI client = SarvamAI(api_key=os.environ.get('SARVAM_API_KEY', '')) response = client.text_to_speech(text='Hello world', target_language_code='hi-IN') print(response.audio_content)
Debug
Known issues
gotchaapi_key parameter is required; no default key or fallback. Must be set via environment variable or passed explicitly.
fix
Export SARVAM_API_KEY environment variable or pass api_key to constructor.
affects: all
gotchaAll text inputs should be provided in the target language script; no automatic transliteration.
fix
Ensure text is already in the target language's script (e.g., Devanagari for Hindi).
affects: all
breakingIn v0.1.20, the `client.tts` method was renamed to `client.text_to_speech`. Old code using `.tts` will break.
fix
Replace `client.tts(...)` with `client.text_to_speech(...)`.
affects: >=0.1.20
Errors
Common errors & fixes
sarvamai.exceptions.AuthenticationError: Invalid API key
Missing or incorrect API key.
fix
Set SARVAM_API_KEY environment variable to a valid key from Sarvam AI dashboard.
TypeError: __init__() got an unexpected keyword argument 'api_key'
Installed version <0.1.0 which uses positional argument for key.
fix
Upgrade to >=0.1.0: pip install --upgrade sarvamai
AttributeError: 'SarvamAI' object has no attribute 'tts'
Code uses deprecated `.tts` method.
fix
Use `.text_to_speech()` instead.
Upgrade
Version history
0.1.28latest on PyPI · released Apr 20, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
sarvamai — pip install sarvamai · libregistry