Skip to content

Bananaflow MCP is live.

Read the docs

Sarvam AI API for Voice Agents: A Guide

Jaseem Abbas, founder of Bananaflow, in glasses and a dark top against a pale background.Jaseem Abbas

Published
Cover for "Sarvam AI API for Voice Agents: A Guide": a white line diagram of two matching sound waves, each starting at a pill reading 8 kHz, joined by a bracket that closes on a lit node, and off to the right, past a small cross, a fainter wave twice as dense, drawn over a soft, out-of-focus tibouchina in muted sage mint, with a warm peach glow at the far left and a sky blue haze at the far right.

The Sarvam AI API is a set of web APIs from Sarvam AI for speech-to-text, text-to-speech, translation and chat models, built for Indian languages and English. A developer building a voice agent can call them one by one: hear the caller with a speech model, decide the reply with a chat model, and speak it with a voice model. This guide explains what each API does, how to sign in, what the limits are and how the pieces fit into a phone agent. It is an independent explainer, and every fact comes from Sarvam's own documentation, read on 16 November 2026. Model names and limits change, so check the linked page before you build.

Here is a small example. Anita, a tech lead at a Chennai insurance broker, wants a prototype that answers a renewal call in Tamil and Hindi. She needs three things: a way to turn the caller's speech into text, a model that writes the reply, and a voice that speaks it. She opens Sarvam's docs to see which APIs cover which job. Anita and the broker are made up for this example.

What is the Sarvam AI API?

It is a group of REST and WebSocket endpoints from Sarvam AI that turn speech into text, text into speech, and text into another language, plus chat models that write replies. Sarvam's docs describe "speech, text, and document models trained for 22 Indian languages and English" (Sarvam API docs home, read 16 November 2026). The docs list REST, WebSocket and batch endpoints and official Python and JavaScript SDKs.

Sarvam also sells a managed voice agent platform, and the docs cover it in a separate section. This guide is only about the model APIs that a developer calls directly. If you are comparing agent platforms, see our page on Sarvam AI alternatives.

What can you build with the Sarvam APIs?

You can build each stage of a voice pipeline, and some extra jobs around it. The docs group the APIs by task, and the same key works across them (Sarvam Model APIs welcome page).

  • Job: Speech to text

    Model family
    Saaras
    Model IDs in the docs
    saaras:v4 (default), saaras:v3
    How you call it
    REST, batch and WebSocket
  • Job: Text to speech

    Model family
    Bulbul
    Model IDs in the docs
    bulbul:v4-flash, bulbul:v3
    How you call it
    REST, HTTP streaming and WebSocket
  • Job: Chat and tool calling

    Model family
    Sarvam-105B
    Model IDs in the docs
    sarvam-105b, sarvam-105b-conversations
    How you call it
    Chat Completions, with streaming
  • Job: Text translation

    Model family
    Mayura
    Model IDs in the docs
    mayura:v1
    How you call it
    REST (/translate)
Which Sarvam API does which job in a voice agent: Saaras hears, a chat model decides, Bulbul speaks, and Mayura translates text when you need it.

The welcome page puts it simply: a voice agent is three calls. Saaras hears the caller, a language model decides what to say, and Bulbul says it. The same page also lists open-weight chat models that Sarvam serves, such as GLM, Gemma and DeepSeek, behind a second chat endpoint. This guide sticks to Sarvam's own models.

How do you sign in to the Sarvam API?

Create a key in the Sarvam dashboard and send it in an api-subscription-key header on every request. The authentication page says the API also accepts the same key as a standard Authorization: Bearer header, which helps with tools built for OpenAI-style APIs (Sarvam authentication, read 16 November 2026).

Three details from that page save time:

  • You generate the key yourself. After you sign up, you create it in the API Keys section of the dashboard.
  • The key is shown once. If you lose it, you delete it and make a new one.
  • Keep it on your server. The docs say never to put the key in public repositories or client-side code, and to use environment variables.

The official SDKs are sarvamai on PyPI (pip install sarvamai) and on npm (npm install sarvamai) (Sarvam SDKs). The error page notes that an invalid key returns HTTP 403, not 401, so check for 403 in your error handling (Sarvam errors and troubleshooting).

What does Sarvam's speech-to-text API do?

It turns audio into text with the Saaras model, in 22 Indian languages and English. Saaras v4 is the default and recommended model, and Saaras v3 is still available. The docs say the model supports automatic language detection, code-mixed speech and 8 kHz telephony audio (Saaras model page, read 16 November 2026).

The mode parameter changes what comes back. The docs show one sample sentence, "मेरा फोन नंबर है 9840950950", in each mode:

  • Mode: transcribe (default)

    What it returns
    Text in the spoken language, with number normalisation
    Example output from the docs
    मेरा फोन नंबर है 9840950950
  • Mode: translate

    What it returns
    English text from any supported Indian language
    Example output from the docs
    My phone number is 9840950950
  • Mode: verbatim

    What it returns
    Word for word, fillers and spoken numbers kept as said
    Example output from the docs
    मेरा फोन नंबर है नौ आठ चार zero नौ पांच zero नौ पांच zero
  • Mode: translit

    What it returns
    Latin script
    Example output from the docs
    mera phone number hai 9840950950
  • Mode: codemix

    What it returns
    English words in English, Indian words in native script
    Example output from the docs
    मेरा phone number है 9840950950

For a voice agent, the right mode depends on what the next step needs. A model that reads Hindi may be happy with transcribe. A system that must keep exactly what the caller said, fillers included, may prefer verbatim. Our guide to Hindi speech recognition on calls explains why Indian phone audio is hard, and Hinglish voice agents covers mixed speech.

The docs list three ways to call it:

  • REST for files under 30 seconds.
  • Batch for files up to 2 hours, with up to 20 files per job and speaker diarization for up to 20 speakers.
  • Realtime streaming over a WebSocket, for live audio.

The docs also mention keyterm prompting on saaras:v4, a list of up to 50 names, brands or technical terms to bias recognition. For file formats, REST and batch accept common types such as WAV, MP3, AAC, FLAC and OGG. PCM audio needs the input_audio_codec parameter and a 16 kHz sample rate (Sarvam speech-to-text overview).

How does streaming speech-to-text work on a live call?

You open a WebSocket, send audio in small chunks, and receive partial transcripts while the caller is still speaking, then a final transcript when the turn ends. Sarvam calls this the realtime streaming API. Its default model is saaras:v3-realtime, and saaras:v4 is also available on the same endpoint (Sarvam realtime streaming API, read 16 November 2026).

The parts a voice developer cares about are all connection parameters:

  • language_code is required. Use a BCP-47 code such as hi-IN, or auto to detect the language.
  • stream_type is fast, balanced (default) or simulated. The docs suggest fast for conversational agents where quick barge-in matters.
  • endpointing is vad, where the server finds turn boundaries, or manual, where your client sends speech_start, speech_end and flush.
  • VAD tuning has three settings in milliseconds: threshold (default 0.3), silence_duration_ms (default 500) and min_speech_duration_ms (default 250).
  • sample_rate is 8000 or 16000, and the encodings listed include linear16, linear32, mulaw and alaw, mono only.

You can also change some settings in the middle of a call with a config.update message, and errors arrive as structured events with a code and an is_fatal flag. Here is the short Python sketch from Sarvam's page, trimmed to the connection and the events:

from sarvamai import AsyncSarvamAI, RealtimeAudioInput, RealtimeEnd

client = AsyncSarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

async with client.speech_to_text_realtime_streaming.connect(
    language_code="hi-IN",
    stream_type="fast",
) as ws:
    # send_realtime_audio_input(RealtimeAudioInput(audio=<base64 chunk>)) for each chunk,
    # then send_realtime_end(RealtimeEnd()) when the audio is done
    async for message in ws:
        if message.event == "transcript.partial":
            print(f"partial: {message.text}")
        elif message.event == "transcript.final":
            print(f"final: {message.text}")

This is a trimmed copy of Sarvam's own example, so check the full version on the realtime streaming page before you use it. Two of those settings map to ideas we explain elsewhere. The silence setting decides when the server calls a turn finished, which is the topic of our guide to endpointing and turn detection. The threshold setting is voice activity detection, defined in our glossary entry.

What does Sarvam's text-to-speech API do?

It turns text into spoken audio with the Bulbul model. The docs list two current models. bulbul:v4-flash is the latest and has 200+ persona voices, 222 catalogue IDs in all, named like simran_en_customer. bulbul:v3 remains the API default when you leave the model out, with 30+ named speakers (Bulbul model page, read 16 November 2026).

Language coverage is not the same on both:

  • Bulbul v3 lists 11 languages: Hindi, Bengali, Tamil, Telugu, Gujarati, Kannada, Malayalam, Marathi, Punjabi, Odia and Indian English.
  • Bulbul v4 Flash voices cover Hindi, English, English–Hindi mixed (tagged enhi), Bengali, Gujarati, Kannada, Marathi, Punjabi, Tamil and Telugu. The page says Malayalam and Odia are not yet offered on v4 Flash.

So a voice for your language may be on one model and not the other. Check the voices page before you pick, and listen on your own scripts. Our guide to text to speech in Indian languages and the text-to-speech glossary entry explain what to listen for.

  • Option: REST

    Best for
    Short text, one answer back
    Limit in the docs
    2,500 characters per request
  • Option: HTTP streaming

    Best for
    Simple streaming pipelines
    Limit in the docs
    3,500 characters per request
  • Option: WebSocket

    Best for
    Interactive voice agents
    Limit in the docs
    2,500 characters per message, under 500 recommended for lowest latency

For audio formats, the docs list wav, mp3, aac, flac, linear16, mulaw and alaw among the supported codecs, and the sample rates are 8000, 16000, 22050 and 24000 Hz for streaming. The default is 22050 Hz if you leave it out (Sarvam text-to-speech overview). The Bulbul page adds that speech pace can be adjusted from 0.5x to 2.0x.

How does streaming text-to-speech work?

You open a WebSocket, send a config message first, then send text and receive audio chunks as they are made. That lets the agent start speaking before the whole sentence is synthesised. The WebSocket page says to always send the config message first, to use flush messages to force processing of buffered text, and to send ping messages to keep a long connection alive (Sarvam streaming text-to-speech, read 16 November 2026).

The config message sets the speaker, the language code, the pace and the output codec. Setting send_completion_event=True makes the API send an event when speech generation ends, which helps you close the stream cleanly.

Which chat models does Sarvam offer, and can they call tools?

Sarvam's chat endpoint serves Sarvam-105B and a conversational variant, and it follows the OpenAI chat format. Model sarvam-105b is the flagship. Model sarvam-105b-conversations is described by Sarvam as post-trained for real-time dialogue and voice agents, with a 32K-token context window, against 128K for sarvam-105b (Sarvam-105B model page, read 16 November 2026).

The Chat Completions guide documents streaming with stream: true, which sends the reply as server-sent events, and tool calling with the tools parameter: the model returns the function name and JSON arguments, you run the function, and you send the result back in a tool message (Sarvam Chat Completions, read 16 November 2026). That is the same loop we describe in tool calling on live voice calls. The conversational variant works on the /v1 endpoint only, while sarvam-105b works on /v1 and /v2, so read the feature table for the model you choose.

For background on how Indian-language models are chosen for phone agents, see our guide to Indian LLMs for voice agents and the LLM glossary entry.

What does Sarvam's translation API do?

It translates text between English and Indian languages with the Mayura model, mayura:v1. The docs list 11 languages, automatic source detection, a limit of 1,000 characters per request, and styles such as formal, modern colloquial, classic colloquial and code-mixed (Mayura model page, read 16 November 2026). The same page points to a separate model, Sarvam-Translate, for all 22 official Indian languages.

In a voice agent, translation is an extra. It is useful for logging a call in English, or for sending a text follow-up in the caller's language. It is not a required step, because Saaras can also return English directly with its translate mode.

How do you wire the Sarvam APIs into a voice agent?

Chain them: stream the caller's audio to speech-to-text, send each final transcript to the chat model, and stream the reply, sentence by sentence, to text-to-speech. Each stage can start before the last one finishes, and that overlap is where the time is saved.

One streamed turn. Partial transcripts arrive while the caller talks, the chat model streams its reply, and the first finished sentence goes to the voice before the rest is written.

Sarvam's docs include step-by-step guides for two open-source frameworks. The LiveKit guide installs the Sarvam plugin with pip install "livekit-agents[sarvam]>=1.8.6,<2" (Sarvam's LiveKit guide). The Pipecat guide uses pip install "pipecat-ai[daily,sarvam,runner]>=1.14" (Sarvam's Pipecat guide). The docs also list guides for Vapi, Twilio and Exotel.

A few habits make the pipeline behave on real phone lines:

  1. Match the sample rate. The "Building for Indian languages" page says a large share of Indian voice traffic is 8 kHz mono phone audio, often µ-law or A-law, and that for 8 kHz audio you set sample_rate=8000 both when opening the streaming connection and when sending each chunk. It warns that mismatched rates cause garbled output (Building for Indian languages).
  2. Signal the end of audio. The same page says to call ws.flush() after the last chunk, so the server emits a transcript instead of waiting.
  3. Stream every stage. Use partial transcripts, streamed chat output and a WebSocket voice. Our voice agent latency guide shows where reply time goes.
  4. Add phone handling yourself. The model APIs do not answer a phone call. You still need telephony, call control, retries and testing around them.

Do you want one model that hears and speaks in a single step, or this three-stage chain? Our guide to speech-to-speech versus cascaded voice agents lays out the trade.

What limits and errors should you plan for?

Plan for four things: rate limits, credits, request size and transient errors. The docs say rate limits apply per account, not per key, and depend on your plan. Sarvam gives free starter credits on signup and lists its prices in rupees on its own pricing page, so read that page for current rates (Sarvam pricing and rate limits, read 16 November 2026). We do not repeat prices here because they change.

  • Status: 400 or 422

    Meaning in the docs
    Invalid body, parameters or field names
    What a voice pipeline should do
    Fix the request. Do not retry blindly
  • Status: 402

    Meaning in the docs
    Credit balance exhausted
    What a voice pipeline should do
    Alert your team. Retrying does not help until credits are added
  • Status: 403

    Meaning in the docs
    Invalid API key or forbidden
    What a voice pipeline should do
    Check the key and the header name
  • Status: 429

    Meaning in the docs
    Rate limit or model capacity
    What a voice pipeline should do
    Back off and retry, or queue the call
  • Status: 500, 502 or 503

    Meaning in the docs
    Transient server or model issues
    What a voice pipeline should do
    Retry with exponential backoff

Request size matters too. The 30 second REST limit for speech-to-text is why live calls use the WebSocket, and the 500 character advice for the voice WebSocket is why you split the model's reply into sentences. The errors page covers the details.

How should you judge a Sarvam model before you pick it?

Test it on your own audio and your own scripts, with a method you can repeat. A language list says a model supports Tamil. It does not say how it handles a caller on a speakerphone in a Madurai shop. We do not rank models or quote scores here, because a score from someone else's audio does not predict yours.

A fair method has five steps: collect real call samples with permission, write the correct text by hand, run each model on the same files, compare the results, and listen to the failures. Our guide to benchmarking speech-to-text on Indian calls walks through it, and the automatic speech recognition glossary entry defines the terms. Do the same for voices: play your real sentences, with names, amounts and mixed Hindi and English, and have a native speaker listen.

What should you remember about the Sarvam AI API?

  • Saaras hears, Bulbul speaks, Sarvam-105B writes and Mayura translates. One key works across them.
  • Use the realtime WebSocket for speech-to-text on live calls and the WebSocket for text-to-speech.
  • Voice and language coverage differ between Bulbul v3 and v4 Flash, so check the catalogue for your language.
  • Match the sample rate on both sides of an 8 kHz phone stream, and flush at the end of audio.
  • Read prices and rate limits on Sarvam's own pages, since they change.
  • Test on your own call audio before you commit.

FAQ

Frequently asked questions

  • What is the Sarvam AI API?

    It is a set of REST and WebSocket APIs from Sarvam AI for speech-to-text (Saaras), text-to-speech (Bulbul), chat models (Sarvam-105B) and translation (Mayura), built for Indian languages and English. One API key works across them, and there are official Python and JavaScript SDKs.

  • How do you authenticate with the Sarvam API?

    Create an API key in the Sarvam dashboard and send it in an api-subscription-key header on every request. The API also accepts the same key as an Authorization Bearer header. The dashboard shows the key only once, so save it, and keep it on your server, never in client-side code.

  • Which languages does Sarvam speech-to-text support?

    Sarvam's docs say Saaras supports 22 Indian languages plus English, with automatic language detection and code-mixed speech. It has five output modes: transcribe, translate, verbatim, translit and codemix. Always test on your own call audio, because a language list does not tell you how a model does on your callers.

  • Can Sarvam speech-to-text stream live audio?

    Yes. The realtime streaming API uses a WebSocket and sends partial transcripts while the caller is still speaking, then a final transcript. You can tune voice activity detection in milliseconds, change settings mid-call, and choose a stream type for lower latency or higher accuracy. It accepts 8 kHz and 16 kHz audio.

  • What text-to-speech options does Sarvam offer?

    Bulbul has REST for short text, HTTP streaming, and a WebSocket for interactive agents. Per the docs, bulbul:v4-flash is the latest with 200+ persona voices, and bulbul:v3 is the API default with 30+ speakers and 11 languages. Voice coverage differs between the two, so check the voices page for your language.

  • Does Sarvam's chat model support tool calling?

    Sarvam's Chat Completions guide documents tool calling with the tools parameter, where the model returns a function name and JSON arguments, you run the function and send the result back. It also supports streaming. Check the feature table for the model you pick, since sarvam-105b and sarvam-105b-conversations differ in endpoints and context size.

  • How do you use Sarvam APIs with 8 kHz phone audio?

    Set sample_rate to 8000 both when opening the streaming connection and when sending each audio chunk, because Sarvam's docs say mismatched rates garble the output. Use a supported encoding, and call flush after the last chunk so the server emits the transcript. Phone audio is often mono and u-law or A-law encoded.

  • How much does the Sarvam AI API cost?

    Sarvam lists its prices in rupees on its own pricing page, with free starter credits on signup and plans that set rate limits. Prices change, so read that page for current rates instead of relying on a blog post. Error 402 means your credit balance is exhausted, and error 429 means a rate limit.

Written by

  • Jaseem Abbas, founder of Bananaflow, in glasses and a dark top against a pale background.

    Jaseem Abbas

    Founder, Bananaflow

    Jaseem founded Bananaflow to build voice AI that understands how people in India really speak, including the switch between languages in the middle of a call.

Similar articles

Bring us one process. We'll pilot it on your real calls, with your team as the fallback.

Plan a pilot