Example code, guides, and end-to-end projects for building with the Sarvam AI API: chat completions, speech to text, text to speech, translation, transliteration, language identification, and document intelligence, all with first-class support for Indian languages.
- Getting started
- Repository layout
- API tutorials
- Example projects
- Integrations
- Contributing
- Resources
- License
You will need a Sarvam API key. Sign up for a free account at dashboard.sarvam.ai to get one.
Set it as an environment variable:
export SARVAM_API_KEY=<your API key>Or create a .env file in your project root:
SARVAM_API_KEY=<your API key>
Most notebooks and scripts are written in Python 3.9+, but the underlying API calls translate directly to any language with an HTTP client or the Sarvam AI SDKs.
| Folder | Contents |
|---|---|
getting-started/ |
Focused, single-API tutorial notebooks: chat, speech to text, text to speech, translation, transliteration, language identification, document intelligence |
examples/ |
Complete example projects and apps built on top of the Sarvam AI API |
integrations/ |
Guides for using Sarvam AI with third-party frameworks and platforms |
scripts/ |
CI validation tooling and the Sarvam model allowlist (sarvam_api_rules.json) |
tests/ |
Unit tests for the validation scripts |
| Capability | Notebook | Covers |
|---|---|---|
| Chat completions | Chat_Completion.ipynb | Sending messages, tuning temperature and reasoning effort, multi-turn conversations, wiki grounding |
| Speech to text | STT_API_Tutorial.ipynb | Transcribing short and long audio with the Saaras model |
| Speech to text, batch | stt-batch-api/ | Transcribing audio files at scale with synchronous and asynchronous jobs |
| Speech to text translation | STT_Translate_API_Tutorial.ipynb | Translating spoken audio directly into English text |
| Speech to text translation, batch | stt-translate-batch-api/ | Translating audio files at scale |
| Text to speech | TTS_Tutorial.ipynb | Converting text into natural-sounding speech |
| Translation | translate/ | Translating text with Mayura and Sarvam-Translate, including streaming |
| Transliteration | Transliterate_API_Tutorial.ipynb | Converting text between scripts while preserving pronunciation |
| Language identification | Language_Identification.ipynb | Detecting the language and script of input text |
| Document intelligence | Document_Intelligence.ipynb | Extracting structured data from documents with Sarvam Vision |
| Project | Description |
|---|---|
| AI Presentation Architect | Generates multilingual PowerPoint presentations, with narrated audio, from a single topic |
| AI Graph Generator | Turns natural language prompts into charts, rendered in the requested Indian language |
| Birthday Song Generator | FastAPI app that writes and narrates a custom birthday song |
| WAV to MP3 Converter | Converts .wav audio files to .mp3 |
| Government Scheme Summarizer | Summarizes Indian government welfare schemes and translates the summary into 10 languages |
| Indic Soundbox AI | Voice agent for merchant soundboxes that reports sales insights in the merchant's language |
| Live Video Transcription | Real-time transcription and translation of video audio over WebSocket |
| Multilingual Chatbot | Chatbot with context preservation and translation fallback across English and Indian languages |
| Multilingual Feedback Analyzer | Detects language, translates, and analyzes sentiment in customer feedback |
| QuickStart Chatbot | Minimal single-turn chatbot built on the Chat Completions API |
| Realtime Speech Captioning | Live captions from streaming speech to text over WebSocket |
| Regional Code Helper | Coding assistant that explains and debugs code in Indian languages |
| Regional Doubt Solver | Homework helper with automatic language detection and age-appropriate explanations |
| Sarvam Podcast Generator | Next.js app that turns uploaded PDFs into narrated podcasts |
| Song Lyrics Generator | Transcribes song audio into lyrics with the Speech to Text API |
| Subtitles Generator | Detects speech segments with voice activity detection and produces an SRT subtitle file |
| Travel Planner | Builds personalized, multilingual travel itineraries |
| Book Summary Narrator | Narrates book summaries with the Text to Speech API |
| Integration | Description |
|---|---|
| LiveKit | Real-time multilingual voice agent over WebRTC |
| Pipecat | Voice agent pipeline with Daily or browser WebRTC transport |
| Twilio | Phone voice agent over Twilio Media Streams |
| Exotel | Phone voice agent over Exotel Voice Streaming |
| n8n | No-code workflows for speech to text, text to speech, and chat completions |
| Vercel AI SDK | Using Sarvam models through the Vercel AI SDK's standard functions |
| OpenLIT | OpenTelemetry-native monitoring for Sarvam AI API calls |
We welcome new examples and fixes. Before opening a pull request:
- Read CONTRIBUTING.MD for security requirements and API standards.
- Copy
examples/TEMPLATE/as the starting point for new notebook recipes. - Run local validation with
make check.
CI checks every pull request for secret leaks and structure compliance for new notebook recipes. Current models are tracked in scripts/sarvam_api_rules.json and refreshed weekly from docs.sarvam.ai.
- Sarvam AI Documentation
- Sarvam AI Dashboard
- Sarvam AI Discord
- Sarvam AI on GitHub
- Sarvam AI on Hugging Face
This repository is licensed under the Apache License 2.0.