> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sarvam AI

> Use the Sarvam AI LLM plugin in a Zero Runtime pipeline. Setup, options, and usage in Python, JavaScript, and Go.

Sarvam AI is an **LLM** plugin tuned for Indian languages. It takes the transcribed
conversation and generates the reply, with optional Wikipedia grounding.

<Note>
  Sarvam AI is also available as a [speech-to-text](/plugins/stt/sarvamai) plugin.
</Note>

## Setup

Set your Sarvam AI API key in the worker environment. Generate a key from the [Sarvam AI dashboard](https://dashboard.sarvam.ai/key-management):

```bash theme={null}
export SARVAMAI_API_KEY=<key>
```

<Note>
  The runtime picks up `SARVAMAI_API_KEY` from the worker environment. If you pass the key directly to the constructor's `api_key` parameter and leave it unset, the SDK falls back to the `SARVAM_API_KEY` environment variable instead.
</Note>

## Usage

Import the plugin and pass it to the pipeline's `llm` slot.

<CodeGroup>
  ```python Python theme={null}
  from zrt.plugins import SarvamAILLM

  llm = SarvamAILLM(
      model="sarvam-30b",
      temperature=0.7,
  )

  # Pipeline(llm=llm, ...)
  ```
</CodeGroup>

## Configuration Options

*Constructor parameters for the Python SDK (`SarvamAILLM`). The JavaScript and Go SDKs expose `model`, `temperature`, and `max_completion_tokens`/`maxCompletionTokens` in their idiomatic form (camelCase / `LLMOptions` struct).*

| Parameter               | Type    | Default        | Description                                                                            |
| ----------------------- | ------- | -------------- | -------------------------------------------------------------------------------------- |
| `api_key`               | `str`   | `None`         | Sarvam AI API key. Falls back to the `SARVAM_API_KEY` environment variable when unset. |
| `model`                 | `str`   | `"sarvam-30b"` | Sarvam model used to generate replies.                                                 |
| `temperature`           | `float` | `0.7`          | Sampling randomness; lower is more deterministic.                                      |
| `tool_choice`           | `str`   | `"auto"`       | How the model decides when to call tools.                                              |
| `max_completion_tokens` | `int`   | `None`         | Caps the length of each reply.                                                         |
| `reasoning_effort`      | `str`   | `None`         | Reasoning depth: `"low"`, `"medium"`, or `"high"`.                                     |
| `wiki_grounding`        | `bool`  | `False`        | Enable Wikipedia search to ground responses.                                           |
| `top_p`                 | `float` | `None`         | Nucleus-sampling cutoff, as an alternative to `temperature`.                           |
| `frequency_penalty`     | `float` | `None`         | Penalizes frequent tokens (range -2.0 to 2.0).                                         |
| `presence_penalty`      | `float` | `None`         | Penalizes tokens already present (range -2.0 to 2.0).                                  |
| `stop`                  | `str`   | `None`         | Up to 4 sequences that halt generation.                                                |

## Import paths

| SDK        | Import                                | Constructor                                 |
| ---------- | ------------------------------------- | ------------------------------------------- |
| Python     | `from zrt.plugins import SarvamAILLM` | `SarvamAILLM(...)`                          |
| JavaScript | `from '@zrt/js-sdk/plugins/sarvamai'` | `SarvamAILLM({ ... })`                      |
| Go         | `.../zrt-golang-sdk/plugins/sarvamai` | `sarvamai.NewLLM(sarvamai.LLMOptions{...})` |

The reply is streamed to the [text-to-speech](/plugins/tts/cartesia) plugin, which
synthesizes the agent's voice.
