Developer Quickstart
Get started with Sarvam APIs in < 5 minutes: create a key, install the SDK, and make your first call with just a few lines of code.
Prerequisites:
- A Sarvam AI account and API key. Create one on the dashboard if you don’t have one yet.
- Python 3.9+ or Node.js 18+ (or skip both and call the REST API directly with
curl).
By the end of this quickstart, you’ll have made a live call to a Sarvam AI API and gotten back a real result: a transcript, a playable audio file, a translation, or a chat reply, depending on which API you try below.
Setup
Create an API Key
Visit the Sarvam AI dashboard and create a new API key. Keep this key secure; you’ll need it to authenticate your requests.
Install the SDK
Choose your preferred language and install our SDK. Need a different language or an older version? See Libraries & SDKs.
Make Your First API Call
Here’s a Chat Completion example using the key and SDK you just set up. Paste it in and run it:
Prefer Speech to Text, Text to Speech, or Translation instead? Jump to Try an API below, each comes with its own Python, JavaScript, and cURL example.
Keep your key safe. Store it in an environment variable or a secrets manager, and never commit it to version control. Getting a 403? See Authentication. Getting a 429? See Credits & Rate Limits. Any other error code is listed in Errors & Troubleshooting.
On Windows? The cURL examples use bash syntax. In PowerShell, curl is an alias for Invoke-WebRequest, $SARVAM_API_KEY is not expanded, and \ does not continue a line. Run the cURL examples in WSL or Git Bash, or call curl.exe and use $env:SARVAM_API_KEY with a backtick (`) for line continuation. The Python and JavaScript examples work the same on every platform.
Try an API
Sarvam AI covers eight core capabilities below. Pick a tab, and copy-paste your way to a working call.
Speech to Text
Text to Speech
Instant Voice Cloning
Text Translation
Chat Completion
Document Translation
Document AI
Dubbing
Saaras v4 is our latest speech recognition model. It supports multiple output modes: transcribe (default, original language), translate (to English), verbatim (word-for-word), translit (romanization), and codemix (mixed script).
Use transcribe for same-language output, translate to convert audio to English text, or verbatim/translit/codemix for specialized formatting. mode defaults to transcribe when omitted.
Bulbul v4 converts text into natural-sounding speech across Indian languages. The API returns base64-encoded audio, so decode it before saving or playing the file.
The audios field is base64-encoded, so always decode it before writing to a file, or the audio will be corrupted. See the TTS best practices guide for streaming and more voice options.
Same SDK shape as Bulbul TTS: create a voice, then convert (or convert_stream / WebSocket). First create a saved voice from a reference clip, then synthesize with its voice_id. Instant Voice Cloning is in beta.
Instant Voice Cloning requires the text_to_speech_voice_cloning capability on your subscription. Use sarvamai ≥ 0.1.37 (Python) or ≥ 1.1.12 (TypeScript) for convert / convert_stream / voice_cloning_streaming. These examples omit language_code so the service detects Hindi from the text. Detection can be wrong on short or code-mixed text — pass the code when pronunciation has to be exact. See the Instant Voice Cloning overview for the full request schema, quality control, and cross-lingual cloning.
Sarvam Translate converts text across English and 22 Indian languages, with automatic source-language detection when source_language_code is "auto".
speaker_gender adjusts grammatical gender agreement in the translation for languages where verb forms change by gender, such as Hindi. See the Sarvam Translate model page for the full list of supported languages.
Sarvam-105B is a chat model with hybrid reasoning and native support for Indian languages.
sarvam-105b is the flagship model for the highest-quality reasoning. See Models for the full lineup and thinking modes.
Document Translation translates a whole PDF, Word, PowerPoint, or web page file into any of 23 languages (up to 12 target languages per job), preserving the original layout. It’s an asynchronous job: create, upload, start, then poll and export.
This kicks off the job; translation happens asynchronously. Poll GET .../live-status and export each target language once its state is Completed. See Poll and Export for the full loop. No cURL SDK helper exists for the upload step, so both examples call the signed URL directly.
Document AI (powered by Sarvam Vision) turns a PDF or scanned document into structured Markdown, HTML, or JSON. parse() creates and submits the job in one call. Save any PDF as sample-document.pdf next to your script: a document you have, a sample found online, or one generated with an AI assistant.
Poll get_status() until the job reaches a terminal state (completed, partially_completed, failed, or rejected), then fetch the file with get_download_url(). See the Document AI guide for the full polling loop and the schema-based extract() alternative. Use output_format="md", not "markdown", it returns a 400. The examples need sarvamai 0.1.50 or later in Python and 1.1.23 or later in JavaScript (earlier JavaScript versions ignore output_format and return HTML).
Dubbing localizes video or audio into another Indian language, with optional voice cloning. It’s an asynchronous job: create, upload, start, then poll for downloadable exports.
That starts the dub job running asynchronously. Poll get_live_status() for progress, then get_export_status() for a signed download URL per (language, format). See Job Lifecycle for the full polling script. JavaScript and cURL examples for this flow aren’t published yet; see the Create Dub API reference for other languages.
Next Steps
Pick up where you left off, based on the API you just tried: