Keyterm Prompting

View as Markdown

saaras:v4 only. Keyterms are supported only with model="saaras:v4", on both the REST and Batch APIs.

Keyterms help Saaras v4 recognize important names, places, brands, and technical terms that may occur in an audio file — for example:

1["Sarvam", "New Delhi", "Vistaar"]

Keyterms bias recognition; they do not guarantee that a term will appear in the transcript.

Rules

RuleDetail
Model supportOnly model="saaras:v4"
FormatJSON list of strings under keyterms
Max terms50 distinct keyterms
Max length64 characters per keyterm
PhrasesPut phrases such as New Delhi in one list item
DelimitingDo not send comma-separated terms in one string
Deprecated fieldsDo not use the older keyterm or hotwords fields

Use mode="codemix" instead of mode="transcribe" when a keyterm such as PhonePe must remain in Latin script — the keyterms format is unchanged across all supported modes. See Choosing the transcription mode below.

Upgrade your SDK before using keyterms. Python: verified on sarvamai>=0.1.33a1 for REST, sarvamai>=0.1.33a3 for speech_to_text_job.create_job(). JavaScript: verified on sarvamai>=1.1.10-alpha.1 for speechToTextJob.createJob() — a fix for REST speechToText.transcribe() has not shipped to npm yet; until it’s released, use the JavaScript Batch example below, or the REST cURL/Python examples.

REST API

REST requests use multipart/form-data. Send keyterms as a JSON-encoded array in one form field.

1import os
2from sarvamai import SarvamAI
3
4client = SarvamAI(api_subscription_key=os.environ["SARVAM_API_KEY"])
5response = client.speech_to_text.transcribe(
6 file=open("audio.wav", "rb"),
7 model="saaras:v4",
8 mode="transcribe",
9 language_code="hi-IN",
10 keyterms=["Sarvam", "New Delhi", "Vistaar"],
11)
12print(response.transcript)

Omit language_code to use automatic language detection.

Batch API

For batch jobs, keyterms is a normal JSON array inside job_parameters.

1job = client.speech_to_text_job.create_job(
2 model="saaras:v4",
3 mode="transcribe",
4 language_code="hi-IN",
5 with_diarization=True,
6 keyterms=["Sarvam", "New Delhi", "Vistaar"],
7)
8job.upload_files(file_paths=["interview.wav"])
9job.start()
10job.wait_until_complete()
11job.download_outputs(output_dir="./output")

After creating the job, use the returned job ID to upload the audio, start the job, poll its status, and download the output using the standard Batch API workflow.

Batch with diarization

Add with_diarization. The same keyterms are applied while transcribing every audio chunk in the job — the downloaded result includes the full transcript and, when requested, speaker-attributed entries under diarized_transcript.

1job = client.speech_to_text_job.create_job(
2 model="saaras:v4",
3 mode="transcribe",
4 language_code="hi-IN",
5 with_diarization=True,
6 with_timestamps=True,
7 keyterms=["Sarvam", "New Delhi", "Vistaar"],
8)

See Enable Speaker Diarization for the full diarization output format.

Choosing the transcription mode

The keyterms format is unchanged across all supported modes:

ModeBehavior
transcribeNative-script transcription; English words use native script
codemixNative-script transcription; English words remain in Latin script
verbatimSpeech as spoken, without punctuation
translitTranscription in Latin script
translateEnglish translation

For example, use mode="codemix" instead of mode="transcribe" when a keyterm such as PhonePe must remain in Latin script.

Need help choosing between REST and Batch? See Which API to Use.