File: /home/cafsindia/ai_allyindian_com/node_modules/sarvamai/reference.md
# Reference
## Text
<details><summary><code>client.text.<a href="/src/api/resources/text/client/Client.ts">translate</a>({ ...params }) -> SarvamAI.TranslationResponse</code></summary>
<dl>
<dd>
#### 📝 Description
<dl>
<dd>
<dl>
<dd>
**Translation** converts text from one language to another while preserving its meaning.
For Example: **'मैं ऑफिस जा रहा हूँ'** translates to **'I am going to the office'** in English, where the script and language change, but the original meaning remains the same.
Available languages:
- **`bn-IN`**: Bengali
- **`en-IN`**: English
- **`gu-IN`**: Gujarati
- **`hi-IN`**: Hindi
- **`kn-IN`**: Kannada
- **`ml-IN`**: Malayalam
- **`mr-IN`**: Marathi
- **`od-IN`**: Odia
- **`pa-IN`**: Punjabi
- **`ta-IN`**: Tamil
- **`te-IN`**: Telugu
### Newly added languages:
- **`as-IN`**: Assamese
- **`brx-IN`**: Bodo
- **`doi-IN`**: Dogri
- **`kok-IN`**: Konkani
- **`ks-IN`**: Kashmiri
- **`mai-IN`**: Maithili
- **`mni-IN`**: Manipuri (Meiteilon)
- **`ne-IN`**: Nepali
- **`sa-IN`**: Sanskrit
- **`sat-IN`**: Santali
- **`sd-IN`**: Sindhi
- **`ur-IN`**: Urdu
For hands-on practice, you can explore the notebook tutorial on [Translate API Tutorial](https://github.com/sarvamai/sarvam-ai-cookbook/blob/main/notebooks/translate/Translate_API_Tutorial.ipynb).
</dd>
</dl>
</dd>
</dl>
#### 🔌 Usage
<dl>
<dd>
<dl>
<dd>
```typescript
await client.text.translate({
input: "input",
source_language_code: "auto",
target_language_code: "bn-IN",
});
```
</dd>
</dl>
</dd>
</dl>
#### ⚙️ Parameters
<dl>
<dd>
<dl>
<dd>
**request:** `SarvamAI.TranslationRequest`
</dd>
</dl>
<dl>
<dd>
**requestOptions:** `Text.RequestOptions`
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</details>
<details><summary><code>client.text.<a href="/src/api/resources/text/client/Client.ts">identifyLanguage</a>({ ...params }) -> SarvamAI.LanguageIdentificationResponse</code></summary>
<dl>
<dd>
#### 📝 Description
<dl>
<dd>
<dl>
<dd>
Identifies the language (e.g., en-IN, hi-IN) and script (e.g., Latin, Devanagari) of the input text, supporting multiple languages.
</dd>
</dl>
</dd>
</dl>
#### 🔌 Usage
<dl>
<dd>
<dl>
<dd>
```typescript
await client.text.identifyLanguage({
input: "input",
});
```
</dd>
</dl>
</dd>
</dl>
#### ⚙️ Parameters
<dl>
<dd>
<dl>
<dd>
**request:** `SarvamAI.LanguageIdentificationRequest`
</dd>
</dl>
<dl>
<dd>
**requestOptions:** `Text.RequestOptions`
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</details>
<details><summary><code>client.text.<a href="/src/api/resources/text/client/Client.ts">transliterate</a>({ ...params }) -> SarvamAI.TransliterationResponse</code></summary>
<dl>
<dd>
#### 📝 Description
<dl>
<dd>
<dl>
<dd>
**Transliteration** converts text from one script to another while preserving the original pronunciation. For example, **'नमस्ते'** becomes **'namaste'** in English, and **'how are you'** can be written as **'हाउ आर यू'** in Devanagari. This process ensures that the sound of the original text remains intact, even when written in a different script.
Transliteration is useful when you want to represent words phonetically across different writing systems, such as converting **'मैं ऑफिस जा रहा हूँ'** to **'main office ja raha hun'** in English letters.
**Translation**, on the other hand, converts text from one language to another while preserving the meaning rather than pronunciation. For example, **'मैं ऑफिस जा रहा हूँ'** translates to **'I am going to the office'** in English, changing both the script and the language while conveying the intended message.
### Examples of **Transliteration**:
- **'Good morning'** becomes **'गुड मॉर्निंग'** in Hindi, where the pronunciation is preserved but the meaning is not translated.
- **'सुप्रभात'** becomes **'suprabhat'** in English.
Available languages:
- **`en-IN`**: English
- **`hi-IN`**: Hindi
- **`bn-IN`**: Bengali
- **`gu-IN`**: Gujarati
- **`kn-IN`**: Kannada
- **`ml-IN`**: Malayalam
- **`mr-IN`**: Marathi
- **`od-IN`**: Odia
- **`pa-IN`**: Punjabi
- **`ta-IN`**: Tamil
- **`te-IN`**: Telugu
For hands-on practice, you can explore the notebook tutorial on [Transliterate API Tutorial](https://github.com/sarvamai/sarvam-ai-cookbook/blob/main/notebooks/transliterate/Transliterate_API_Tutorial.ipynb).
</dd>
</dl>
</dd>
</dl>
#### 🔌 Usage
<dl>
<dd>
<dl>
<dd>
```typescript
await client.text.transliterate({
input: "input",
source_language_code: "auto",
target_language_code: "bn-IN",
});
```
</dd>
</dl>
</dd>
</dl>
#### ⚙️ Parameters
<dl>
<dd>
<dl>
<dd>
**request:** `SarvamAI.TransliterationRequest`
</dd>
</dl>
<dl>
<dd>
**requestOptions:** `Text.RequestOptions`
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</details>
## SpeechToText
<details><summary><code>client.speechToText.<a href="/src/api/resources/speechToText/client/Client.ts">transcribe</a>(file, { ...params }) -> SarvamAI.SpeechToTextResponse</code></summary>
<dl>
<dd>
#### 📝 Description
<dl>
<dd>
<dl>
<dd>
## Real-Time Speech to Text API
This API transcribes speech to text in multiple Indian languages and English. Supports real-time transcription for interactive applications.
### Available Options:
- **Real-Time API** (Current Endpoint): For quick responses under 30 seconds with immediate results
- **Batch API**: For longer audio files, requires following a notebook script - [View Notebook](https://github.com/sarvamai/sarvam-ai-cookbook/tree/main/notebooks/stt/stt-batch-api)
- Supports diarization (speaker identification)
### Note:
- Pricing differs for Real-Time and Batch APIs
- Diarization is only available in Batch API with separate pricing
- Please refer to [dashboard.sarvam.ai](https://dashboard.sarvam.ai) for detailed pricing information
</dd>
</dl>
</dd>
</dl>
#### 🔌 Usage
<dl>
<dd>
<dl>
<dd>
```typescript
await client.speechToText.transcribe(fs.createReadStream("/path/to/your/file"), {});
```
</dd>
</dl>
</dd>
</dl>
#### ⚙️ Parameters
<dl>
<dd>
<dl>
<dd>
**file:** `File | fs.ReadStream | Blob`
</dd>
</dl>
<dl>
<dd>
**request:** `SarvamAI.SpeechToTextTranscriptionRequest`
</dd>
</dl>
<dl>
<dd>
**requestOptions:** `SpeechToText.RequestOptions`
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</details>
<details><summary><code>client.speechToText.<a href="/src/api/resources/speechToText/client/Client.ts">translate</a>(file, { ...params }) -> SarvamAI.SpeechToTextTranslateResponse</code></summary>
<dl>
<dd>
#### 📝 Description
<dl>
<dd>
<dl>
<dd>
## Real-Time Speech to Text Translation API
This API automatically detects the input language, transcribes the speech, and translates the text to English.
### Available Options:
- **Real-Time API** (Current Endpoint): For quick responses under 30 seconds with immediate results
- **Batch API**: For longer audio files, requires following a notebook script - [View Notebook](https://github.com/sarvamai/sarvam-ai-cookbook/tree/main/notebooks/stt-translate/stt-translate-batch-api)
- Supports diarization (speaker identification)
### Note:
- Pricing differs for Real-Time and Batch APIs
- Diarization is only available in Batch API with separate pricing
- Please refer to [dashboard.sarvam.ai](https://dashboard.sarvam.ai) for detailed pricing information
</dd>
</dl>
</dd>
</dl>
#### 🔌 Usage
<dl>
<dd>
<dl>
<dd>
```typescript
await client.speechToText.translate(fs.createReadStream("/path/to/your/file"), {});
```
</dd>
</dl>
</dd>
</dl>
#### ⚙️ Parameters
<dl>
<dd>
<dl>
<dd>
**file:** `File | fs.ReadStream | Blob`
</dd>
</dl>
<dl>
<dd>
**request:** `SarvamAI.SpeechToTextTranslationRequest`
</dd>
</dl>
<dl>
<dd>
**requestOptions:** `SpeechToText.RequestOptions`
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</details>
## TextToSpeech
<details><summary><code>client.textToSpeech.<a href="/src/api/resources/textToSpeech/client/Client.ts">convert</a>({ ...params }) -> SarvamAI.TextToSpeechResponse</code></summary>
<dl>
<dd>
#### 📝 Description
<dl>
<dd>
<dl>
<dd>
This is the model to convert text into spoken audio.
The output is a wave file encoded as a base64 string.
</dd>
</dl>
</dd>
</dl>
#### 🔌 Usage
<dl>
<dd>
<dl>
<dd>
```typescript
await client.textToSpeech.convert({
text: "text",
target_language_code: "bn-IN",
});
```
</dd>
</dl>
</dd>
</dl>
#### ⚙️ Parameters
<dl>
<dd>
<dl>
<dd>
**request:** `SarvamAI.TextToSpeechRequest`
</dd>
</dl>
<dl>
<dd>
**requestOptions:** `TextToSpeech.RequestOptions`
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</details>
## Chat
<details><summary><code>client.chat.<a href="/src/api/resources/chat/client/Client.ts">completions</a>({ ...params }) -> SarvamAI.CreateChatCompletionResponse</code></summary>
<dl>
<dd>
#### 📝 Description
<dl>
<dd>
<dl>
<dd>
Calls Sarvam LLM API to get the chat completion. Supported model(s): `sarvam-m`.
</dd>
</dl>
</dd>
</dl>
#### 🔌 Usage
<dl>
<dd>
<dl>
<dd>
```typescript
await client.chat.completions({
messages: [
{
role: "assistant",
content: "content",
},
],
model: "sarvam-m",
});
```
</dd>
</dl>
</dd>
</dl>
#### ⚙️ Parameters
<dl>
<dd>
<dl>
<dd>
**request:** `SarvamAI.ChatCompletionsRequest`
</dd>
</dl>
<dl>
<dd>
**requestOptions:** `Chat.RequestOptions`
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</details>