Microsoft.Extensions.AI Integration
Cross-SDK comparison
See the centralized MEAI documentation for feature matrices and comparisons across all tryAGI SDKs.
The SarvamAI SDK implements IChatClient and ISpeechToTextClient and provides AIFunction tool wrappers, all compatible with Microsoft.Extensions.AI.
IChatClient
SarvamAI implements IChatClient for chat completions using the
/v1/chat/completions endpoint with Sarvam-30B and Sarvam-105B models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Chat Options
- ModelId:
"sarvam-30b"or"sarvam-105b" - Temperature, TopP, MaxOutputTokens: Standard generation parameters
- Tools: Function calling support via
AIFunctiontools - StopSequences: Custom stop sequences
- AdditionalProperties:
"reasoning_effort": Controls reasoning depth ("low","medium","high")"wiki_grounding": Enable Wikipedia grounding (true/false)
1 2 3 4 5 6 7 8 9 10 11 | |
ISpeechToTextClient
SarvamAI implements ISpeechToTextClient for speech-to-text transcription
supporting 22+ Indian languages using Saaras v3 and Saarika v2.5 models.
1 2 3 4 5 6 7 8 9 | |
Options
- SpeechLanguage: Set the transcription language using BCP-47 codes (e.g.,
"hi-IN","bn-IN","ta-IN") - ModelId: Choose the STT model (e.g.,
"saaras:v3","saarika:v2.5")
1 2 3 4 5 6 | |
Accessing the Raw Response
The full Sarvam AI response is available via RawRepresentation for language detection confidence, timestamps, and diarized transcript data:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
These provider-specific fields are also available via AdditionalProperties on the MEAI response:
1 2 3 | |
Streaming Behavior
GetStreamingTextAsync delegates to the non-streaming GetTextAsync method internally. The Sarvam AI STT API processes audio synchronously, and then the full result is converted to SpeechToTextResponseUpdate events using ToSpeechToTextResponseUpdates().
This means you will not receive incremental transcription updates as audio is processed. The entire transcript is returned at once after processing completes. For most use cases, calling GetTextAsync directly is equivalent and simpler.
Available Tools
| Method | Tool Name | Description |
|---|---|---|
AsTranslateTool() |
TranslateText |
Translates text between 22+ Indian languages and English. |
AsTransliterateTool() |
TransliterateText |
Converts text between Indic scripts and Roman script. |
AsDetectLanguageTool() |
DetectLanguage |
Detects the language and script of input text. |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Tool Details
TranslateText
Translates text between Indian languages (Hindi, Bengali, Tamil, Telugu, Kannada,
Malayalam, Marathi, Gujarati, Punjabi, Odia, and more) and English. Uses BCP-47
language codes. Accepts a mode parameter: "formal" (default), "modern-colloquial",
"classic-colloquial", or "code-mixed".
1 | |
TransliterateText
Converts text from one script to another without changing the language. For example, converts Hindi written in Devanagari to Roman script, or vice versa. Supports auto-detection of source script.
1 | |
DetectLanguage
Detects the language and script of input text. Returns the BCP-47 language code
(e.g., hi-IN for Hindi) and the script code (e.g., Deva for Devanagari,
Latn for Latin).
1 | |