> ## 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.

# Sarvamai

> JavaScript API reference for the sarvamai llm plugin.

## SarvamAILLM

Sarvam AI large language model (LLM).

### Constructor

```typescript theme={null}
new SarvamAILLM(opts: SarvamAILLMOptions)
```

<ParamField path="apiKey" type="string">
  Sarvam AI API key. Defaults to the `SARVAM_API_KEY` environment variable.
</ParamField>

<ParamField path="model" type="SarvamAILLMModel | string">
  Model id. Default `'sarvam-30b'`.
</ParamField>

<ParamField path="temperature" type="number">
  Sampling temperature; higher is more random. Default `0.7`.
</ParamField>

<ParamField path="toolChoice" type="string">
  Tool-selection strategy. Default `'auto'`.
</ParamField>

<ParamField path="maxCompletionTokens" type="number">
  Maximum number of tokens to generate. Default `1024`.
</ParamField>

<ParamField path="topP" type="number | null">
  Nucleus-sampling probability mass. Default `null` (provider default).
</ParamField>

<ParamField path="frequencyPenalty" type="number | null">
  Frequency penalty. Default `null`.
</ParamField>

<ParamField path="presencePenalty" type="number | null">
  Presence penalty. Default `null`.
</ParamField>

<ParamField path="seed" type="number | null">
  Random seed for reproducible sampling. Default `null`.
</ParamField>

<ParamField path="stop" type="string | null">
  Stop sequence(s). Default `null`.
</ParamField>

<ParamField path="user" type="string | null">
  Stable end-user identifier. Default `null`.
</ParamField>

<ParamField path="parallelToolCalls" type="boolean | null">
  Allow parallel tool calls. Default `null` (provider default).
</ParamField>

<ParamField path="responseFormat" type="Record<string, any> | null">
  Structured-output response format. Default `null`.
</ParamField>

<ParamField path="reasoningEffort" type="string">
  Reasoning effort hint. Default `null`.
</ParamField>

<ParamField path="wikiGrounding" type="boolean">
  Enable wiki grounding. Default `false`.
</ParamField>

### cancelCurrentGeneration

```typescript theme={null}
cancelCurrentGeneration(): Promise<void>
```

Cancel the in-flight generation for the current session, if any.

### chat

```typescript theme={null}
chat(_messages: any, _opts?: LLMChatOptions): AsyncIterator<LLMResponse>
```

Stream a completion for the given messages, yielding LLMResponse chunks.

<ResponseField name="returns" type="AsyncIterator<LLMResponse>" />

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds
for in-flight async handlers to settle before returning.

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

***

## SarvamAILLMModel

Supported Sarvam AI LLM model names.

```typescript theme={null}
type SarvamAILLMModel = 'sarvam-30b' | 'sarvam-105b'
```
