Skip to main content
Version: 1.0.x

Sarvam AI LLM

The Sarvam AI LLM provider enables your agent to use Sarvam AI's language models for text-based conversations and processing.

Installation

Install the Sarvam AI-enabled VideoSDK Agents package:

pip install "videosdk-plugins-sarvamai"

Importing

from videosdk.plugins.sarvamai import SarvamAILLM
note

When using Sarvam AI as the LLM option, the function tool calls and MCP tool will not work.

Authentication

The Sarvam plugin requires a Sarvam API key.

Set SARVAM_API_KEY in your .env file.

Example Usage

from videosdk.plugins.sarvamai import SarvamAILLM
from videosdk.agents import Pipeline

# Initialize the Sarvam AI LLM model
llm = SarvamAILLM(
model="sarvam-105b",
# When SARVAMAI_API_KEY is set in .env - DON'T pass api_key parameter
api_key="your-sarvam-ai-api-key",
temperature=0.7,
tool_choice="auto",
max_completion_tokens=1000,
reasoning_effort="medium", # Optional: "low", "medium", "high"
wiki_grounding=False, # Optional: enable Wikipedia-grounded responses
top_p=1,
frequency_penalty=0,
presence_penalty=0,
)

# Add llm to pipeline
pipeline = Pipeline(llm=llm)
note

When using .env file for credentials, don't pass them as arguments to model instances or context objects. The SDK automatically reads environment variables, so omit api_key and other credential parameters from your code.

Configuration Options

  • model: (str) The Sarvam AI model to use (default: "sarvam-m").
  • api_key: (str) Your Sarvam AI API key. Can also be set via the SARVAMAI_API_KEY environment variable.
  • temperature: (float) Sampling temperature for response randomness (default: 0.7).
  • tool_choice: (ToolChoice) Tool selection mode (default: "auto").
  • max_completion_tokens: (int) Maximum number of tokens in the completion response (optional).
  • reasoning_effort: (str) Controls reasoning depth for the model. Allowed values: "low", "medium", "high" (default: None).
  • wiki_grounding: (bool) Enables Wikipedia search to ground responses with factual information (default: False).
  • top_p : An alternative to sampling with temperature. Defaults to None.
  • frequency_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far.
  • presence_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far
  • stop : Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

Additional Resources

The following resources provide more information about using Sarvam AI with VideoSDK Agents SDK.

Got a Question? Ask us on discord