Skip to main content

Gnani

Since v1.112.0

LiteLLM supports Gnani's Prisma REST speech-to-text API for a single recording of up to 30 seconds, and the proxy will stream the live audio to Gnani via the OpenAI-compatible /v1/realtime WebSocket (see below).

PropertyDetails
DescriptionGnani's Prisma models transcribe Indic and English speech, including mixed-language audio.
Provider Route on LiteLLMgnani/
Supported Modelsgnani/prisma-v3.0, gnani/prisma-v2.5
Provider DocGnani REST reference ↗
Supported OpenAI Endpoints/audio/transcriptions, /realtime (transcription only, proxy)

Gnani accepts WAV, MP3, OGG, FLAC, AAC and M4A. Keep the correct extension on the upload because Gnani selects its decoder from the filename. For in-memory compressed audio, pass a tuple such as ("clip.mp3", audio_bytes).

Set GNANI_API_KEY to your Gnani key or pass api_key. To use a different provider host, set GNANI_API_BASE or pass api_base. LiteLLM appends /stt/v3 to it, and the default host is https://api.vachana.ai.

Quick Start​

import asyncio
import os
from pathlib import Path

import litellm

os.environ["GNANI_API_KEY"] = ""

audio = Path("lecture.wav")
result = litellm.transcription(model="gnani/prisma-v3.0", file=audio)
print(result.text)

result_v25 = litellm.transcription(model="gnani/prisma-v2.5", file=audio, language="hi")
print(result_v25.text)


async def transcribe():
result = await litellm.atranscription(
model="gnani/prisma-v3.0",
file=audio,
language="hi,en",
format="codemix",
keyterms=["fractions"],
)
print(result.text)


asyncio.run(transcribe())

LiteLLM Proxy Usage​

Save this as config.yaml, set GNANI_API_KEY and LITELLM_MASTER_KEY, and start the proxy with litellm --config config.yaml.

model_list:
- model_name: gnani-prisma-v3
litellm_params:
model: gnani/prisma-v3.0
api_key: os.environ/GNANI_API_KEY
model_info:
mode: audio_transcription
- model_name: gnani-prisma-v2-5
litellm_params:
model: gnani/prisma-v2.5
api_key: os.environ/GNANI_API_KEY
language: hi
model_info:
mode: audio_transcription

general_settings:
master_key: os.environ/LITELLM_MASTER_KEY

Prisma v2.5 needs exactly one language, so set language on its deployment. Requests that pass no language use it, and the proxy's /health check needs it to call the model.

Send a recording with curl.

curl http://localhost:4000/v1/audio/transcriptions \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-F model=gnani-prisma-v3 \
-F file=@lecture.wav

Or use the OpenAI SDK. Multipart clients send arrays as JSON strings.

import os
from pathlib import Path

from openai import OpenAI

client = OpenAI(base_url="http://localhost:4000/v1", api_key=os.environ["LITELLM_MASTER_KEY"])
result = client.audio.transcriptions.create(
model="gnani-prisma-v3",
file=Path("lecture.wav"),
extra_body={"format": "codemix", "keyterms": '["fractions"]'},
)
print(result.text)

Parameters and response​

On v3.0, omit language for automatic detection or supply one to four comma-separated hints such as en, hi-IN or hi,en. On v2.5, pass exactly one language such as hi or en-IN. Gnani's own language_code field also works and takes priority over language. OpenAI's languages list works too, so languages=["hi", "en"] sends hi-IN,en-IN. It takes priority over language, including a deployment's default language, and language_code takes priority over both. LiteLLM sends a two-letter code as its Indian locale, so hi becomes hi-IN, and fixes the case of a region code, so hi-in becomes hi-IN. Other gnani/ model names, such as a newer Prisma release, use the v3.0 parameters.

Both models return JSON with a text field. When Gnani reports them, the response also has language (the detected language code), request_id, and truncated, which is true when Gnani transcribed only part of the audio. A successful silent clip can return an empty string.

Both models accept format=transcribe for conventional number formatting and format=verbatim for spoken forms. Prisma v3.0 also accepts codemix for mixed scripts and transliterate for Latin script. Omit format to use the provider's default. OpenAI's separate response_format accepts only json.

Prisma v3.0 accepts up to 200 keyterms, a topic of up to 1,600 characters, previous_text (it uses the last 600 characters), and one to four speaker_names. On v3.0, LiteLLM sends OpenAI's prompt as previous_text unless you also pass previous_text. For word boosting on v2.5, pass bias_list=["Prisma"] and bias_score=1.5. OpenAI's keywords list becomes keyterms on v3.0 and bias_list on v2.5, unless you also pass that field. On v2.5, LiteLLM adds Gnani's recommended bias_score of 1.0 when you leave it out, since Gnani boosts nothing without a score. v2.5 boosts only single words made of letters, so a keyword such as HDFC Bank or COVID-19 gets a 400 there, and drop_params drops the keywords instead. Use v3.0 for phrases. On v3.0, a bias_list you pass wins over keywords, since Gnani uses keyterms over bias_list. For digits in the target script on v2.5, use format="transcribe" and itn_native_numerals=True. See the Prisma v3.0 model guide and the Prisma v2.5 model guide.

Both models support find-and-replace. Pass enable_substitution=True and a substitution_map of up to ten rules, for example [{"patterns": ["maths"], "replacement": "mathematics"}]. Gnani validates audio and context limits and LiteLLM returns its errors to the caller. LiteLLM sends other options it does not know, such as an option Gnani adds later, to Gnani as form fields. With caching on, Gnani's own options such as format, language_code and keyterms are part of the cache key only when enable_caching_on_provider_specific_optional_params: true is set under litellm_settings, so set it when the same audio is sent with different options.

To trace a request, set X-API-Request-ID in extra_headers, in the SDK call or in the deployment's litellm_params. LiteLLM sends extra_headers to Gnani as HTTP headers, and Gnani returns the id as request_id. LiteLLM always sends the configured key as X-API-Key-ID and drops any X-API-Key-ID in extra_headers, in any letter case. A number or boolean value, such as 1 in YAML, is sent as text.

model_list:
- model_name: gnani-prisma-v3
litellm_params:
model: gnani/prisma-v3.0
api_key: os.environ/GNANI_API_KEY
extra_headers:
X-API-Request-ID: support-desk-7
model_info:
mode: audio_transcription

A transcription request to gnani-prisma-v3 then returns "request_id": "support-desk-7" next to text.

Limitations​

These limits apply to REST transcription. Prisma REST has no word timestamps, no speaker diarisation and no streaming. For live audio use realtime transcription. OpenAI temperature, timestamp_granularities, chunking_strategy, include, known_speaker_names, known_speaker_references and stream=True have no equivalent here and neither does prompt on v2.5 so LiteLLM will return a 400 for those. It will also return a 400 for a Gnani option that the model in question doesn't accept (e.g. topic on v2.5). To drop those instead you can pass drop_params=True in the SDK or set drop_params: true under litellm_settings on the proxy.

Gnani limits how many requests an account can run at once and answers an overlapping request with a 429. The account used in testing ran one request at a time, and keys on the same account share the limit. The proxy retries a 429 twice by default, which covered three overlapping requests in testing. For more parallel traffic, raise num_retries under router_settings. The SDK functions litellm.transcription and litellm.atranscription do not retry, so SDK code that sends overlapping requests should call atranscription on a litellm.Router with num_retries set.

import asyncio
import os

import litellm

router = litellm.Router(
model_list=[
{
"model_name": "gnani-prisma-v3",
"litellm_params": {"model": "gnani/prisma-v3.0", "api_key": os.environ["GNANI_API_KEY"]},
}
],
num_retries=4,
)


async def main() -> None:
results = await asyncio.gather(
*(router.atranscription(model="gnani-prisma-v3", file=open("lecture.wav", "rb")) for _ in range(3))
)
print([result.text for result in results])


asyncio.run(main())

Gnani has no published per-second rate in the LiteLLM model cost map, so spend shows as zero until you set your contracted rate as input_cost_per_second in the deployment's litellm_params. LiteLLM multiplies it by the length of the uploaded recording, which it reads with the soundfile package. pip install 'litellm[proxy]' includes it, but a plain pip install litellm does not, so install soundfile for SDK spend. LiteLLM cannot read the length of AAC and M4A uploads or of OGG files that hold FLAC audio, so those requests still bill zero. While spend is zero, key and team budgets do not limit Gnani traffic.

model_list:
- model_name: gnani-prisma-v3
litellm_params:
model: gnani/prisma-v3.0
api_key: os.environ/GNANI_API_KEY
input_cost_per_second: 0.0001
model_info:
mode: audio_transcription

Realtime Transcription​

Since v1.113.0

The proxy is serving Prisma v3.0 and v2.5 for live audio via its OpenAI-compatible /v1/realtime WebSocket. Clients are using the OpenAI Realtime transcription protocol. LiteLLM is taking the audio and passing it on to Gnani's streaming API. Gnani does the VAD (voice activity detection) to determine where each utterance ends and so each utterance gets its own final transcript.

1. Add the model to your config​

config.yaml
model_list:
- model_name: gnani-prisma
litellm_params:
model: gnani/prisma-v3.0
api_key: os.environ/GNANI_API_KEY
input_cost_per_second: 0.0001

general_settings:
master_key: os.environ/LITELLM_MASTER_KEY

api_key falls back to GNANI_API_KEY. api_base falls back to GNANI_API_BASE and then to https://api.vachana.ai. It has to be an https:// or wss:// URL (LiteLLM puts the key in the WebSocket handshake). LiteLLM connects over wss:// and appends /stt/v3/stream to the path. Set the Gnani connection options (e.g. format, x-idle-timeout-sec) in the deployment's extra_headers.

The cost map has no Gnani price so set your contracted rate as input_cost_per_second to track spend and enforce both key and team budgets.

Start LiteLLM Proxy
litellm --config config.yaml

# RUNNING on http://0.0.0.0:4000

2. Transcribe a recording​

Connect via intent=transcription in the query string. This example reads a 24kHz mono PCM16 WAV file and outputs its first final transcript.

import asyncio
import base64
import os
import wave

from openai import AsyncOpenAI


async def transcribe(path):
async with AsyncOpenAI(base_url="http://localhost:4000/v1", api_key=os.environ["LITELLM_API_KEY"]) as client:
async with client.realtime.connect(model="gnani-prisma", extra_query={"intent": "transcription"}) as ws:
await ws.session.update(session={
"type": "transcription",
"audio": {"input": {"transcription": {"model": "gnani-prisma", "language": "en"}}},
})
with wave.open(path, "rb") as audio:
assert (audio.getframerate(), audio.getnchannels(), audio.getsampwidth()) == (24000, 1, 2)
while chunk := audio.readframes(768):
await ws.input_audio_buffer.append(audio=base64.b64encode(chunk).decode())
await ws.input_audio_buffer.commit()
async for event in ws:
if event.type == "error":
raise RuntimeError(event.error.message)
if event.type == "conversation.item.input_audio_transcription.completed":
print(event.transcript)
return


asyncio.run(transcribe("speech.wav"))

3. Configure the session​

FieldRules
formattype must be audio/pcm with one channel. rate must be 8000, 16000, 24000, 44100 or 48000, and omitted means 24 kHz. LiteLLM resamples the audio to the 16 kHz Gnani expects.
transcription.languageOne language such as hi or en-IN, or indic-auto on Prisma v3.0 to detect the language, which is the default. Prisma v2.5 needs one explicit language before the first audio append. A comma-separated list is rejected.
turn_detectionOmitted or {"type": "server_vad"}. Gnani's server VAD has fixed settings, so threshold, prefix_padding_ms, silence_duration_ms, any other turn detection type and turn_detection: null are rejected.
transcription.promptRejected.

With drop_params set on deployment, LiteLLM drops the rejected settings and keeps Gnani's server VAD. A rejected session.update returns an error event and the session remains open so the client can send a corrected update.

4. Stream audio​

input_audio_buffer.append carries base64 mono PCM16 at the session rate (at most 4 seconds of audio per append). Gnani needs the audio at real time so LiteLLM is forwarding it at real time. Send each append as the audio comes in (a recording sent faster than real time still takes its own length to get to Gnani).

input_audio_buffer.commit terminates the current utterance immediately. A commit with no speech since the last transcript (i.e. one which occurs after Gnani has already terminated the utterance on its own, or one which occurs over just silence) will generate no reply so don't wait for an input_audio_buffer.committed after that. All other client events (including input_audio_buffer.clear and response.create) will result in an error event and the session will remain open.

5. Read transcripts​

EventFieldsWhen
session.createdsession.type: transcriptionGnani accepted the connection
session.updatedEffective settings, same session.idGnani accepted your session.update
input_audio_buffer.speech_starteditem_idGnani detected speech
input_audio_buffer.speech_stoppeditem_idRight before the utterance's transcript
input_audio_buffer.committeditem_id, previous_item_idRight before the utterance's transcript
conversation.item.input_audio_transcription.completeditem_id, transcript, usage: {"type": "duration", "seconds": 4.032}, detected_language_code when Gnani reports itFinal transcript of each utterance
errorerror.messageGnani or LiteLLM rejected an event

All four utterance events have one item_id. usage.seconds is the length of the utterance and silence between utterances is charged up with the next transcript or when the session closes.

Session limits​

Gnani closes a session after 15 minutes or after 60 seconds of no detected speech. To change the idle limit in the deployment's extra_headers, set x-idle-timeout-sec (5 to 900). LiteLLM will not automatically re-open a closed session so you'll need to open a new one and continue from the last completed utterance.

model_list:
- model_name: gnani-prisma
litellm_params:
model: gnani/prisma-v3.0
api_key: os.environ/GNANI_API_KEY
input_cost_per_second: 0.0001
extra_headers:
x-idle-timeout-sec: "300"

A session on gnani-prisma will remain open for up to 5 minutes without any speech.

On Python 3.13 and above the resampler requires the audioop-lts package, which is installed by pip install 'litellm[proxy]'.