Skip to main content

Overview

Sarvam AI is a voice and LLM provider focused on Indian languages (10 Indic languages + English). Bifrost supports both its text and voice workloads:
  • OpenAI-compatible chat - Chat completions delegate to the shared OpenAI implementation (base URL only differs)
  • Text-to-Speech (Bulbul) - Custom mapping; Sarvam returns base64-encoded audio in a JSON audios[] array rather than raw binary
  • Speech-to-Text (Saaras/Saarika) - Custom mapping; multipart upload with Sarvam-specific response fields (transcript, timestamps, diarized_transcript)
  • Dual authentication - Chat uses Authorization: Bearer; voice endpoints use the api-subscription-key header

Supported Operations

OperationNon-StreamingStreamingEndpoint
Chat Completions/v1/chat/completions
Responses API/v1/chat/completions
Speech (TTS)/text-to-speech, /text-to-speech/stream
Transcription (STT)/speech-to-text
List Models-/v1/models
Text Completions-
Embeddings-
Unsupported Operations (❌): Text Completions, Embeddings, Images, Files, Batch, and streaming transcription are not offered by the upstream Sarvam API. These return UnsupportedOperationError.

Setup & Configuration

Configure Sarvam AI as a provider. The same API key works for both chat and voice.
  1. Navigate to Models > Model Providers. Look for Sarvam AI under Configured Providers. If it is missing, click on Add New Provider and select Sarvam AI.
  2. Click Add Key or edit an existing key.
  3. Set a name for your key.
  4. Paste your API key directly or use an environment variable (for example, env.SARVAM_API_KEY).
  5. Set Allowed Models to All Models (default) or the specific model allowlist you want this key to serve.
  6. Save the provider configuration.

1. Chat Completions

Sarvam’s chat completions endpoint is OpenAI-compatible, so Bifrost delegates to the shared OpenAI implementation. For full parameter reference, message handling, tool conversion, and streaming behavior, see OpenAI Chat Completions. Available chat models include sarvam-30b and sarvam-105b.
curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sarvam/sarvam-30b",
    "messages": [{"role": "user", "content": "Namaste!"}]
  }'

2. Responses API

Bifrost converts the Responses API format to Chat Completions internally, then converts the response back:
BifrostResponsesRequest
  → ToChatRequest()
  → ChatCompletion
  → ToBifrostResponsesResponse()
Same parameter support as Chat Completions with response format differences (output items instead of message content).

3. Speech (Text-to-Speech, Bulbul)

Sarvam’s TTS endpoint is not OpenAI-compatible: it returns JSON with base64-encoded audio in an audios[] array, which Bifrost decodes into raw audio bytes.

Parameter Mapping

Bifrost fieldSarvam fieldNotes
inputtextText to synthesize (required)
voicespeakere.g. anushka (v2), shubh (v3)
speedpacePlayback speed
language_codetarget_language_codeBCP-47 Indic code, e.g. hi-IN (required)
Sarvam-specific fields are read from ExtraParams: pitch, loudness, temperature, speech_sample_rate, output_audio_codec, enable_preprocessing, dict_id, enable_cached_responses.
curl -X POST http://localhost:8080/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sarvam/bulbul:v2",
    "input": "Namaste, aap kaise hain?",
    "voice": "anushka",
    "target_language_code": "hi-IN"
  }' --output speech.wav
target_language_code is required by Sarvam. Pass it as language_code or as an extra field; without it the request is rejected.

4. Transcription (Speech-to-Text, Saaras/Saarika)

Sarvam’s STT endpoint accepts a multipart audio upload and returns a custom response shape that Bifrost maps onto its standard transcription format.

Response Mapping

Sarvam fieldBifrost fieldNotes
transcripttextTranscribed text
language_codelanguageDetected BCP-47 language
timestamps (parallel arrays)words[]Flattened into per-word {word, start, end}
diarized_transcript.entriesdiarized segmentsSpeaker-attributed segments
Request fields mode and input_audio_codec are read from ExtraParams; language maps to Sarvam’s language_code.
timestamps and diarized_transcript are only returned by Sarvam’s Batch speech-to-text API; the synchronous /speech-to-text endpoint used here returns transcript and language_code. Bifrost maps words/diarized segments when present, so the standard path typically populates only text and language.
curl -X POST http://localhost:8080/v1/audio/transcriptions \
  -F "model=sarvam/saaras:v3" \
  -F "[email protected]"

Authentication

Sarvam uses different authentication for chat and voice, but the same API key works for both:
  • Chat / Responses: Authorization: Bearer <key>
  • Speech / Transcription: api-subscription-key: <key>
Bifrost applies the correct header per operation automatically.

Configuration

HTTP Settings:
  • Base URL: https://api.sarvam.ai (default)
  • Chat endpoint: /v1/chat/completions
  • Voice endpoints: /text-to-speech, /speech-to-text

Caveats

Severity: Low Behavior: TTS returns base64 JSON (not raw audio) and STT returns Indic-specific fields. Impact: Handled by Bifrost’s custom mapping; no action needed by callers beyond passing target_language_code for TTS.
Severity: Low Behavior: Speech and transcription streaming are not offered by Sarvam. Impact: SpeechStream / TranscriptionStream return UnsupportedOperationError.